GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit 3cbed6c6 authored by Kunshan Wang's avatar Kunshan Wang

Fixed IRBuilder bug when building expfunc nodes

Now BundleConstructor will construct ExposedFunc objects after all
functions are created.
parent 0c68c435
...@@ -81,6 +81,7 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod ...@@ -81,6 +81,7 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod
val typeNodes = new ArrayBuffer[IRTypeNode] val typeNodes = new ArrayBuffer[IRTypeNode]
val sigNodes = new ArrayBuffer[IRSigNode] val sigNodes = new ArrayBuffer[IRSigNode]
val constNodes = new ArrayBuffer[IRConstNode] val constNodes = new ArrayBuffer[IRConstNode]
val expFuncNodes = new ArrayBuffer[NodeExpFunc]
val otherTopLevelNodes = new ArrayBuffer[OtherTopLevelNode] val otherTopLevelNodes = new ArrayBuffer[OtherTopLevelNode]
val funcVers = new ArrayBuffer[NodeFuncVer]() val funcVers = new ArrayBuffer[NodeFuncVer]()
val otherNodes = new ArrayBuffer[IRBuilderNode] val otherNodes = new ArrayBuffer[IRBuilderNode]
...@@ -89,6 +90,7 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod ...@@ -89,6 +90,7 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod
case n: IRTypeNode => typeNodes += n case n: IRTypeNode => typeNodes += n
case n: IRSigNode => sigNodes += n case n: IRSigNode => sigNodes += n
case n: IRConstNode => constNodes += n case n: IRConstNode => constNodes += n
case n: NodeExpFunc => expFuncNodes += n
case n: OtherTopLevelNode => otherTopLevelNodes += n case n: OtherTopLevelNode => otherTopLevelNodes += n
case n: NodeFuncVer => funcVers += n case n: NodeFuncVer => funcVers += n
case n => otherNodes += n case n => otherNodes += n
...@@ -181,6 +183,10 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod ...@@ -181,6 +183,10 @@ class BundleConstructor(idNameMap: Map[MuID, MuName], nodeList: Seq[IRBuilderNod
setIDAndMaybeName(muNode, id) setIDAndMaybeName(muNode, id)
bundle.funcNs.add(muNode) bundle.funcNs.add(muNode)
} }
}
// Build ExposedFunc instances after building Function instances.
expFuncNodes foreach {
case NodeExpFunc(id: MuID, func: MuFuncNode, callconv: Flag, cookie: MuConstIntNode) => { case NodeExpFunc(id: MuID, func: MuFuncNode, callconv: Flag, cookie: MuConstIntNode) => {
val muNode = new ExposedFunc(func, callconv, resConstInt(cookie)) val muNode = new ExposedFunc(func, callconv, resConstInt(cookie))
setIDAndMaybeName(muNode, id) setIDAndMaybeName(muNode, id)
......
...@@ -544,4 +544,27 @@ class MuCtxIRBuilderTest extends UvmBundleTesterBase with ExtraMatchers { ...@@ -544,4 +544,27 @@ class MuCtxIRBuilderTest extends UvmBundleTesterBase with ExtraMatchers {
ctx.close() ctx.close()
} }
it should "create functions exposed functions" in {
val ctx = microVM.newContext()
val b = ctx.newIRBuilder()
val ns = new ConvenientNs(b, "funcsandexpfuncs")
implicit def _lookup = ns.symLookup _
b.newTypeInt('i64, 64)
b.newFuncSig('sig1, Seq(), Seq())
b.newConstInt('i64_0, 'i64, 0L)
b.newExpFunc('expfunc1, 'func1, Flag("#DEFAULT"), 'i64_0)
b.newFunc('func1, 'sig1)
b.newFunc('func2, 'sig1)
b.newExpFunc('expfunc2, 'func2, Flag("#DEFAULT"), 'i64_0)
b.load()
ctx.closeContext()
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment