MuCtxIRBuilderPart.scala 848 Bytes
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
package uvm.refimpl

import uvm._
import uvm.refimpl.itpr._

/**
 * Mix-in to MuCtx to support the IR building API.
 */
trait MuCtxIRBuilderPart {
  protected def microVM: MicroVM
  
  protected def addHandle[T <: MuValue](h: T): T

  @inline
  def IRNODEREF = InternalTypes.IRNODEREF
  
  def newBundle(): MuBundleNode = {
    val b = new TrantientBundle()
    val node = new BundleNode(b)
    addHandle(MuBundleNode(IRNODEREF, BoxIRNode(Some(node))))
  }

  def loadBundleFromNode(b: MuBundleNode): Unit = {
    require(!b.isNull, "bundle must not be NULL")
    val bundle = b.bundle
    microVM.addBundle(bundle)
  }
  
  def abortBundleNode(b: MuBundleNode): Unit = {
    // no op
  }
  
  def getNode(b: MuBundleNode, id: Int): MuIRNode = {
    ???
  }
  
  def getID(node: MuChildNode): Int = {
    require(!node.isNull)
    node.obj.id
  }
}