diff --git a/languages/lang0.md b/languages/lang0.md index a5dd4983..52277736 100644 --- a/languages/lang0.md +++ b/languages/lang0.md @@ -54,15 +54,14 @@ conv ::= (Reinterp ) memops ::= (Load ) -call ::= (Call *) - | (Call +) +call ::= (Call +) intVal ::= (IntVal ) floatVal ::= (FloatVal ) simple ::= | - | (ProcVal ) + | | (Copy ) | (Copy (Global )) expr ::= @@ -89,9 +88,7 @@ exit ::= | (Raise ) | (Branch false: true:) | (Select +) - | (CheckedCall * ) | (CheckedCall + ) - | (CheckedCallAsgn * ) | (CheckedCallAsgn + ) stmt ::= (Asgn ) diff --git a/languages/lang25.md b/languages/lang25.md index c055db59..2752a97f 100644 --- a/languages/lang25.md +++ b/languages/lang25.md @@ -17,12 +17,9 @@ procdef += (ProcDef (Params *) (Locals *) (Stmts +) Control-flow statements can now appear in a normal statement context: ```grammar -exit -= (CheckedCall * ) - | (CheckedCall + ) +exit -= (CheckedCall + ) -exit += (CheckedCall * ) - | (CheckedCall + ) - | (CheckedCallAsgn * ) +exit += (CheckedCall + ) | (CheckedCallAsgn + ) stmt += diff --git a/languages/lang30.md b/languages/lang30.md index 4b4a5d38..ce5643e9 100644 --- a/languages/lang30.md +++ b/languages/lang30.md @@ -35,7 +35,6 @@ stmt += (Block ) | (Loop ) | (If ?) | (Case +) - | (CheckedCall *) | (CheckedCall +) | (CheckedCallAsgn *) | (CheckedCallAsgn +) diff --git a/passes/ir.nim b/passes/ir.nim index c9cde44e..39736e14 100644 --- a/passes/ir.nim +++ b/passes/ir.nim @@ -145,8 +145,6 @@ proc use*(n: IrNode, lit: var Literals, bu: var Builder[NodeKind]) = bu.subTree Load: convert(n[0], lit, bu) use(n[1], lit, bu) - of Proc: - bu.add Node(kind: ProcVal, val: n.id) else: convert(n, lit, bu) diff --git a/passes/pass0.nim b/passes/pass0.nim index bfa8d6cb..c384f581 100644 --- a/passes/pass0.nim +++ b/passes/pass0.nim @@ -61,7 +61,7 @@ func imm(n: TreeNode[NodeKind]): int32 {.inline.} = cast[int32](n.val) func id(n: TreeNode[NodeKind]): int32 {.inline.} = - assert n.kind in {Local, Global, Proc, ProcVal} + assert n.kind in {Local, Global, Proc} cast[int32](n.val) func typ(n: TreeNode[NodeKind]): TypeId {.inline.} = @@ -159,12 +159,12 @@ proc genCall(c; tree; call: NodeIndex, template numArgs(bias: int): int16 = int16((tree.len(call) - ord(fin)) - start - bias) - if tree[call, start].kind == Proc: + if tree[call, start + 1].kind == Proc: # it's a static call - for it in tree.items(call, start + 1, fin): + for it in tree.items(call, start + 2, fin): c.genExpr(tree, it) - c.instr(opcCall, tree[call, start].id, numArgs(0)) + c.instr(opcCall, tree[call, start + 1].id, numArgs(1)) else: # it's an indirect call for it in tree.items(call, start + 2, fin): @@ -222,7 +222,7 @@ proc genExpr(c; tree; val: NodeIndex) = c.loadInt(tree.getInt(val)) of FloatVal: c.loadFloat(tree.getFloat(val)) - of ProcVal: + of Proc: # turn into a procedure address by adding 1 c.loadInt(tree[val].id + 1) of Copy: diff --git a/passes/pass_aggregateParams.nim b/passes/pass_aggregateParams.nim index e5e0c077..bc18f46b 100644 --- a/passes/pass_aggregateParams.nim +++ b/passes/pass_aggregateParams.nim @@ -26,10 +26,6 @@ type Context = object addrType: Node - cache: seq[NodeIndex] - ## indexed by procedure IDs. Caches the signature type for every - ## procedure. This greatly speeds up type computation of calls, as it - ## eliminates the tree traversal necessary for seeking to the procdef # per-procedure state: locals: NodeIndex @@ -70,11 +66,9 @@ proc isAggregate(tree; n: Node): bool = n = tree[tree.child(0), n.val] n.kind in {Record, Union, Array} -proc signature(c; tree; n): NodeIndex = - case tree[n].kind - of Type: tree.child(tree.child(0), tree[n].val) - of Proc: c.cache[tree[n].val] - else: unreachable() +proc signature(tree; n): NodeIndex = + ## Returns the index of the `ProcTy` node for the call at `n`. + tree.child(tree.child(0), tree[n].val) proc typeof(c; tree; n): Node = case tree[n].kind @@ -92,7 +86,7 @@ proc typeof(c; tree; n): Node = tree[c.locals, tree[n].val] of Call: # fetch the return type from the callee's signature - tree[c.signature(tree, tree.child(n, 0)), 0] + tree[signature(tree, tree.child(n, 0)), 0] of Global: # fetch the type from the ``GlobalDef`` tree[tree.child(tree.child(1), tree[n].val), 0] @@ -167,7 +161,7 @@ proc lowerOperand(c; tree; n; reference: int, bu) = # code and/or more work for later passes (more locals usually equals more # work and bookkeeping). case tree[n].kind - of IntVal, FloatVal, ProcVal: + of IntVal, FloatVal, NodeKind.Proc: discard "nothing to do" of Addr: c.lowerAddr(tree, n, reference, bu) @@ -180,8 +174,7 @@ proc lowerOperand(c; tree; n; reference: int, bu) = c.lowerExpr(tree, n, bu) proc lowerCallArgs(c; tree; n; start: int, last: BackwardsIndex; bu) = - let sig = c.signature(tree, tree.child(n, start)) - assert tree[sig].kind == ProcTy + let sig = signature(tree, tree.child(n, start)) let reference = c.stmts.len # don't consider the dynamic callee value, if any, during the loop, as it's @@ -219,7 +212,7 @@ proc lowerCallArgs(c; tree; n; start: int, last: BackwardsIndex; bu) = proc lowerExpr(c; tree; n, bu) = case tree[n].kind - of IntVal, FloatVal, ProcVal: + of IntVal, FloatVal, NodeKind.Proc: discard "nothing to do" of Copy: let x = tree.child(n, 0) @@ -351,11 +344,12 @@ proc addStmts(c; tree; m: var TreeRef, at: NodeIndex, bu) = bu.insert m, at, c.stmts[i] c.stmts.shrink(0) -proc lowerProc(c; tree; n; sig: NodeIndex, bu) = +proc lowerProc(c; tree; n; bu) = c.temps.shrink(0) c.params.clear() - let (_, locals, blocks) = tree.triplet(n) + let (typ, locals, blocks) = tree.triplet(n) + let sig = tree.child(tree.child(0), tree[typ].val) c.locals = locals c.firstTemp = tree.len(locals) @@ -425,12 +419,7 @@ proc lower*(tree; ptrSize: int): ChangeSet[NodeKind] = let procs = tree.child(2) - # cache the signature type for each procedure: - c.cache.newSeq(tree.len(procs)) - for i, it in tree.pairs(procs): - c.cache[i] = tree.child(tree.child(0), tree[it, 0].val.int) - # lower the procedures: for i, it in tree.pairs(procs): if tree[it].kind == ProcDef: - c.lowerProc(tree, it, c.cache[i], result) + c.lowerProc(tree, it, result) diff --git a/passes/source2il.nim b/passes/source2il.nim index 93cefff2..e7ed06d5 100644 --- a/passes/source2il.nim +++ b/passes/source2il.nim @@ -1043,12 +1043,8 @@ proc userCallToIL(c; t; n: NodeIndex, expr; stmts): SemType = stmts.add callee.stmts var call = IrNode(kind: Call) - if callee.expr.kind == Proc: - # the callee is a statically-known procedure; it's a static call - call.add callee.expr - else: - call.add IrNode(kind: Type, id: c.genProcType(callee.typ)) - call.add callee.expr + call.add IrNode(kind: Type, id: c.genProcType(callee.typ)) + call.add callee.expr call.addArgs(c, t, n, callee.typ, stmts) @@ -1189,8 +1185,6 @@ proc exprToIL(c; t: InTree, n: NodeIndex, expr, stmts): ExprType = expr = newLocal(ent.id.uint32) result = c.locals[ent.id] + {} of ekProc: - # expand to a procedure address (`ProcVal`), which is always correct; - # the callsite can turn it into a static reference (`Proc`) as needed expr = IrNode(kind: Proc, id: ent.id.uint32) result = c.procList[ent.id].typ + {} of ekNone: diff --git a/passes/syntax.nim b/passes/syntax.nim index ffc0d083..c44a2f73 100644 --- a/passes/syntax.nim +++ b/passes/syntax.nim @@ -9,7 +9,7 @@ import type NodeKind* = enum - Immediate, IntVal, FloatVal, StringVal, ProcVal, Proc, Type, Local, Global + Immediate, IntVal, FloatVal, StringVal, Proc, Type, Local, Global Int, UInt, Float List @@ -56,7 +56,6 @@ proc toSexp*(tree: PackedTree[NodeKind], idx: NodeIndex, of IntVal: sexp([newSSymbol("IntVal"), sexp tree.getInt(idx)]) of FloatVal: sexp([newSSymbol("FloatVal"), sexp tree.getFloat(idx)]) of StringVal: sexp([newSSymbol("StringVal"), sexp tree.getString(idx)]) - of ProcVal: sexp([newSSymbol("ProcVal"), sexp n.val.int]) of Proc: sexp([newSSymbol("Proc"), sexp n.val.int]) of Type: sexp([newSSymbol("Type"), sexp n.val.int]) of Local: sexp([newSSymbol("Local"), sexp n.val.int]) @@ -73,7 +72,7 @@ proc fromSexp*(kind: NodeKind, val: BiggestInt, lit): Node = case kind of IntVal: Node(kind: kind, val: lit.pack(val)) - of ProcVal, Proc, Type, Local, Global, Int, UInt, Float: + of Proc, Type, Local, Global, Int, UInt, Float: Node(kind: kind, val: val.uint32) else: unreachable() diff --git a/skully/backend.nim b/skully/backend.nim index 41622850..7beb7e99 100644 --- a/skully/backend.nim +++ b/skully/backend.nim @@ -266,13 +266,6 @@ proc registerProc(c; prc: ProcedureId): uint32 = if result == c.nextProc: # is it a not-yet-seen procedure? inc c.nextProc -proc compilerProc(c; env: var MirEnv, name: string): Node = - ## Returns a ``Proc`` reference to the compilerproc with the given `name`. - ## The compilerproc is added to `c` and `env` first, if it hasn't been - ## already. - let p = c.graph.getCompilerProc(name) - result = node(Proc, c.registerProc(env.procedures.add(p))) - proc typeRef(c; env: TypeEnv, typ: TypeId): Node = node(Type, c.genType(env, typ)) @@ -471,6 +464,15 @@ proc genType(c; env: TypeEnv, typ: TypeId): uint32 = result = c.types.mgetOrPut(finish(bu), c.types.len.uint32) c.typeCache[typ] = result +proc emitCompilerProcCallee(c; env: var MirEnv, name: string, bu) = + ## Emits the type and proc value for the compilerproc with the given + ## `name`. The procedure is registered first if it hasn't been already. + let + p = c.graph.getCompilerProc(name) + typ = env.types.add(p.typ) + bu.add c.genProcType(env, typ, true) + bu.add node(Proc, c.registerProc(env.procedures.add(p))) + proc genField(c; env: MirEnv; e: Expr; pos: int32, bu) = ## Emits a field access for field `pos`. let typ = env.types.canonical(e.typ) @@ -575,7 +577,7 @@ proc genConst(c; env; tree; n; dest: Expr, stmts) = of mnkFloatLit: putIntoDest node(FloatVal, c.lit.pack(env.getFloat(tree[n].number))) of mnkProcVal: - putIntoDest node(ProcVal, c.registerProc(tree[n].prc)) + putIntoDest node(Proc, c.registerProc(tree[n].prc)) of mnkArrayConstr: for i, it in tree.args(n): let nDest = makeExpr tree[it].typ: @@ -835,7 +837,7 @@ proc translateValue(c; env: MirEnv, tree: MirTree, n: NodePosition, bu.subTree Copy: bu.add node(Global, c.constMap[tree[n].cnst]) of mnkProcVal: - bu.add node(ProcVal, c.registerProc(tree[n].prc)) + bu.add node(Proc, c.registerProc(tree[n].prc)) of mnkDeref, mnkDerefView: bu.subTree (if wantValue: Load else: Deref): bu.add typeRef(c, env, tree[n].typ) @@ -996,7 +998,7 @@ proc genField(c; env: MirEnv; tree; n; pos: int32, bu) = proc genOf(c; env: var MirEnv, tree; e: Expr, typ: TypeId; bu) = bu.subTree Call: - bu.add compilerProc(c, env, "isObj") + c.emitCompilerProcCallee(env, "isObj", bu) bu.subTree Copy: c.genField(env, e, -1, bu) @@ -1049,7 +1051,7 @@ proc genLength(c; env: var MirEnv; tree; n; dest: Expr, stmts) = stmts.goto exit stmts.join els stmts.putInto dest, Call: - bu.add compilerProc(c, env, "nimCStrLen") + c.emitCompilerProcCallee(env, "nimCStrLen", bu) c.translateValue(env, tree, n, true, bu) stmts.join exit else: @@ -1117,7 +1119,7 @@ proc genSetOp(c; env: var MirEnv, tree; n; dest: Expr, stmts) = mPlusSet: "skullyPlusSet", mMinusSet: "skullMinusSet"] stmts.addStmt Call: - bu.add compilerProc(c, env, Ops[m]) + c.emitCompilerProcCallee(env, Ops[m], bu) takeAddr(dest, bu) takeAddr a takeAddr b @@ -1126,7 +1128,7 @@ proc genSetOp(c; env: var MirEnv, tree; n; dest: Expr, stmts) = stmts.putInto dest, Eq: bu.add typeRef(c, env, BoolType) bu.subTree Call: - bu.add compilerProc(c, env, "nimCmpMem") + c.emitCompilerProcCallee(env, "nimCmpMem", bu) takeAddr a takeAddr b lenValue() @@ -1134,19 +1136,19 @@ proc genSetOp(c; env: var MirEnv, tree; n; dest: Expr, stmts) = of mLeSet, mLtSet: const Ops = [mLeSet: "skullyLeSet", mLtSet: "skullyLtSet"] stmts.putInto dest, Call: - bu.add compilerProc(c, env, Ops[m]) + c.emitCompilerProcCallee(env, Ops[m], bu) takeAddr a takeAddr b lenValue() of mIncl, mExcl: const Ops = [mIncl: "skullyIncl", mExcl: "skullyExcl"] stmts.putInto dest, Call: - bu.add compilerProc(c, env, Ops[m]) + c.emitCompilerProcCallee(env, Ops[m], bu) takeAddr a elem b of mInSet: stmts.putInto dest, Call: - bu.add compilerProc(c, env, "skullyInSet") + c.emitCompilerProcCallee(env, "skullyInSet", bu) takeAddr a elem b else: @@ -1393,21 +1395,21 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = let desc = env.types.headerFor(env.types.canonical(tree[a].typ), Lowered) if desc.kind == tkArray: wrapAsgn Call: - bu.add compilerProc(c, env, "skullyCard") + c.emitCompilerProcCallee(env, "skullyCard", bu) takeAddr NodePosition(a) bu.add node(IntVal, c.lit.pack(desc.size(env.types))) elif desc.size(env.types) == 8: wrapAsgn Call: - bu.add compilerProc(c, env, "countBits64") + c.emitCompilerProcCallee(env, "countBits64", bu) value a elif desc.size(env.types) == 4: wrapAsgn Call: - bu.add compilerProc(c, env, "countBits32") + c.emitCompilerProcCallee(env, "countBits32", bu) value a else: # also use countBits32, but widen the operand first wrapAsgn Call: - bu.add compilerProc(c, env, "countBits32") + c.emitCompilerProcCallee(env, "countBits32", bu) bu.subTree Conv: bu.add node(UInt, 4) bu.add typeRef(c, env, tree[a].typ) @@ -1457,21 +1459,21 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = unreachable() of mEqStr: wrapAsgn Call: - bu.add compilerProc(c, env, "eqStrings") + c.emitCompilerProcCallee(env, "eqStrings", bu) value(tree.argument(n, 0)) value(tree.argument(n, 1)) of mLeStr: wrapAsgn Le: bu.add typeRef(c, env, env.types.sizeType) bu.subTree Call: - bu.add compilerProc(c, env, "cmpStrings") + c.emitCompilerProcCallee(env, "cmpStrings", bu) value(tree.argument(n, 0)) bu.add node(IntVal, 0) of mLtStr: wrapAsgn Lt: bu.add typeRef(c, env, env.types.sizeType) bu.subTree Call: - bu.add compilerProc(c, env, "cmpStrings") + c.emitCompilerProcCallee(env, "cmpStrings", bu) value(tree.argument(n, 0)) bu.add node(IntVal, 0) of mFinished: @@ -1513,7 +1515,7 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = bu.useLvalue dest bu.add node(Immediate, 1) bu.subTree Call: - bu.add compilerProc(c, env, "newSeqPayload") + c.emitCompilerProcCallee(env, "newSeqPayload", bu) bu.add node(IntVal, c.lit.pack len) bu.add node(IntVal, c.lit.pack elemDesc.size(env.types)) bu.add node(IntVal, c.lit.pack elemDesc.align) @@ -1568,39 +1570,39 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = bu.add node(IntVal, 1) of mSetLengthStr: stmts.addStmt Call: - bu.add compilerProc(c, env, "setLengthStrV2") + c.emitCompilerProcCallee(env, "setLengthStrV2", bu) takeAddr NodePosition(tree.argument(n, 0)) value(tree.argument(n, 1)) of mNewString: wrapAsgn Call: - bu.add compilerProc(c, env, "mnewString") + c.emitCompilerProcCallee(env, "mnewString", bu) value(tree.argument(n, 0)) of mNewStringOfCap: wrapAsgn Call: - bu.add compilerProc(c, env, "rawNewString") + c.emitCompilerProcCallee(env, "rawNewString", bu) value(tree.argument(n, 0)) of mBoolToStr: wrapAsgn Call: - bu.add compilerProc(c, env, "nimBoolToStr") + c.emitCompilerProcCallee(env, "nimBoolToStr", bu) value(tree.argument(n, 0)) of mCharToStr: wrapAsgn Call: - bu.add compilerProc(c, env, "nimCharToStr") + c.emitCompilerProcCallee(env, "nimCharToStr", bu) value(tree.argument(n, 0)) of mCStrToStr: wrapAsgn Call: - bu.add compilerProc(c, env, "cstrToNimstr") + c.emitCompilerProcCallee(env, "cstrToNimstr", bu) value(tree.argument(n, 0)) of mStrToCStr: wrapAsgn Call: - bu.add compilerProc(c, env, "nimToCStringConv") + c.emitCompilerProcCallee(env, "nimToCStringConv", bu) value(tree.argument(n, 0)) of mAppendStrStr: # in theory, the appendStrStr magic supports being merged, but this never # happens in practice, meaning that the call expression only ever has # two parameters here stmts.addStmt Call: - bu.add compilerProc(c, env, "prepareAdd") + c.emitCompilerProcCallee(env, "prepareAdd", bu) takeAddr NodePosition(tree.argument(n, 0)) bu.subTree Add: bu.add typeRef(c, env, env.types.sizeType) @@ -1614,7 +1616,7 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = bu.add node(Immediate, 0) stmts.addStmt Call: - bu.add compilerProc(c, env, "appendString") + c.emitCompilerProcCallee(env, "appendString", bu) takeAddr NodePosition(tree.argument(n, 0)) value(tree.argument(n, 1)) of mConStrStr: @@ -1643,20 +1645,20 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = stmts.addStmt Asgn: bu.useLvalue(temp) bu.subTree Call: - bu.add compilerProc(c, env, "rawNewString") + c.emitCompilerProcCallee(env, "rawNewString", bu) bu.add nodes # the length expression # emit the append calls: for (_, _, it) in tree.arguments(n): if tree[it].typ == CharType: stmts.addStmt Call: - bu.add compilerProc(c, env, "appendChar") + c.emitCompilerProcCallee(env, "appendChar", bu) bu.subTree Addr: bu.useLvalue(temp) value(it) else: stmts.addStmt Call: - bu.add compilerProc(c, env, "appendString") + c.emitCompilerProcCallee(env, "appendString", bu) bu.subTree Addr: bu.useLvalue(temp) value(it) @@ -1664,13 +1666,13 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = genAsgn(dest, temp, stmts) of mParseBiggestFloat: wrapAsgn Call: - bu.add compilerProc(c, env, "nimParseBiggestFloat") + c.emitCompilerProcCallee(env, "nimParseBiggestFloat", bu) value(tree.argument(n, 0)) takeAddr NodePosition(tree.argument(n, 1)) value(tree.argument(n, 2)) of mAppendStrCh: stmts.addStmt Call: - bu.add compilerProc(c, env, "nimAddCharV1") + c.emitCompilerProcCallee(env, "nimAddCharV1", bu) takeAddr NodePosition(tree.argument(n, 0)) value(tree.argument(n, 1)) of mDestroy: @@ -1719,14 +1721,14 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = case env.types.headerFor(typ, Canonical).kind of tkString: stmts.addStmt Call: - bu.add compilerProc(c, env, "dealloc") + c.emitCompilerProcCallee(env, "dealloc", bu) bu.subTree Copy: bu.subTree Field: lvalue(tree.argument(n, 0)) bu.add node(Immediate, 1) of tkSeq: stmts.addStmt Call: - bu.add compilerProc(c, env, "alignedDealloc") + c.emitCompilerProcCallee(env, "alignedDealloc", bu) bu.subTree Copy: bu.subTree Field: lvalue(tree.argument(n, 0)) @@ -1767,7 +1769,7 @@ proc genMagic(c; env: var MirEnv, tree; n; dest: Expr, stmts) = bu.add node(IntVal, c.lit.pack(tree.numArgs(n) - 1)) stmts.addStmt Call: - bu.add compilerProc(c, env, "echoBinSafe") + c.emitCompilerProcCallee(env, "echoBinSafe", bu) bu.use oa of mOf: var typ = tree[tree.argument(n, 1)].typ @@ -1845,6 +1847,7 @@ proc genCall(c; env: var MirEnv; tree; n; dest: Expr, stmts; withEnv = false) = if tree[n, 1].kind == mnkProc: # a static call typ = env.types.add(env[tree[n, 1].prc].typ) + bu.add c.genProcType(env, typ, false) bu.add node(Proc, c.registerProc(tree[n, 1].prc)) else: # a dynamic call @@ -2035,7 +2038,7 @@ proc translateExpr(c; env: var MirEnv, tree; n; dest: Expr, stmts) = bu.useLvalue dest bu.add node(Immediate, 1) bu.subTree Call: - bu.add c.compilerProc(env, "newSeqPayload") + c.emitCompilerProcCallee(env, "newSeqPayload", bu) bu.add node(IntVal, c.lit.pack(tree.len(n))) bu.add node(IntVal, c.lit.pack(size(elem, env.types))) bu.add node(IntVal, c.lit.pack(elem.align)) @@ -2183,7 +2186,7 @@ proc translateExpr(c; env: var MirEnv, tree; n; dest: Expr, stmts) = let desc = env.types.headerFor(dest.typ, Lowered) if desc.kind == tkArray: stmts.addStmt Call: - bu.add compilerProc(c, env, "skullyIncl") + c.emitCompilerProcCallee(env, "skullyIncl", bu) takeAddr(dest, bu) bu.use elem else: @@ -2469,7 +2472,7 @@ proc translateStmt(env: var MirEnv, tree; n; stmts; c) = bu.use ex stmts.putInto ex, Call: - bu.add compilerProc(c, env, "nimBorrowCurrentException") + c.emitCompilerProcCallee(env, "nimBorrowCurrentException", bu) for it in tree.items(n, 1, ^2): stmts.join(els) diff --git a/tests/pass0/t03_call_with_result.test b/tests/pass0/t03_call_with_result.test index 634b66c6..fa9bbc93 100644 --- a/tests/pass0/t03_call_with_result.test +++ b/tests/pass0/t03_call_with_result.test @@ -13,7 +13,7 @@ discard """ )) (ProcDef (Type 0) 0 (Locals) (List (Block (Params) - (Return (Call (Proc 0))) + (Return (Call (Type 0) (Proc 0))) ) )) -) \ No newline at end of file +) diff --git a/tests/pass0/t03_checked_call.test b/tests/pass0/t03_checked_call.test index b1a7065a..2344ada2 100644 --- a/tests/pass0/t03_checked_call.test +++ b/tests/pass0/t03_checked_call.test @@ -14,7 +14,7 @@ discard """ (ProcDef (Type 0) 0 (Locals) (List (Block (Params) - (CheckedCall (Proc 0) (Goto 1) (Unwind)) + (CheckedCall (Type 0) (Proc 0) (Goto 1) (Unwind)) ) (Block (Params) (Return)) ) diff --git a/tests/pass0/t03_checked_call_with_result.test b/tests/pass0/t03_checked_call_with_result.test index 562666df..d5ae7bd4 100644 --- a/tests/pass0/t03_checked_call_with_result.test +++ b/tests/pass0/t03_checked_call_with_result.test @@ -13,7 +13,7 @@ discard """ (Locals (Int 8)) (List (Block (Params) - (CheckedCallAsgn (Local 0) (Proc 0) (Goto 1) (Unwind))) + (CheckedCallAsgn (Local 0) (Type 0) (Proc 0) (Goto 1) (Unwind))) (Block (Params) (Return (Copy (Local 0))))))) diff --git a/tests/pass0/t03_checked_indirect_call.expected b/tests/pass0/t03_checked_indirect_call.expected index 841a6a0a..860f2f8f 100644 --- a/tests/pass0/t03_checked_indirect_call.expected +++ b/tests/pass0/t03_checked_indirect_call.expected @@ -3,7 +3,10 @@ Ret .end .start t0 p1 +.local lo0 int LdImmInt 1 + PopLocal lo0 + GetLocal lo0 IndCall t0 0 Ret .end diff --git a/tests/pass0/t03_checked_indirect_call.test b/tests/pass0/t03_checked_indirect_call.test index e84ba955..a67387c8 100644 --- a/tests/pass0/t03_checked_indirect_call.test +++ b/tests/pass0/t03_checked_indirect_call.test @@ -9,9 +9,12 @@ discard """ (List (Block (Params) (Return)))) - (ProcDef (Type 0) 0 (Locals) + (ProcDef (Type 0) 0 + (Locals (Int 8)) (List (Block (Params) - (CheckedCall (Type 0) (ProcVal 0) (Goto 1) (Unwind))) + (Asgn (Local 0) (Proc 0)) + (CheckedCall (Type 0) (Copy (Local 0)) + (Goto 1) (Unwind))) (Block (Params) (Return))))) diff --git a/tests/pass0/t03_checked_indirect_call_with_result.expected b/tests/pass0/t03_checked_indirect_call_with_result.expected index 04ea3146..e4f98771 100644 --- a/tests/pass0/t03_checked_indirect_call_with_result.expected +++ b/tests/pass0/t03_checked_indirect_call_with_result.expected @@ -5,7 +5,10 @@ .end .start t0 p1 .local lo0 int +.local lo1 int LdImmInt 1 + PopLocal lo1 + GetLocal lo1 IndCall t0 0 PopLocal lo0 GetLocal lo0 diff --git a/tests/pass0/t03_checked_indirect_call_with_result.test b/tests/pass0/t03_checked_indirect_call_with_result.test index 54cdb6e0..a153f0b9 100644 --- a/tests/pass0/t03_checked_indirect_call_with_result.test +++ b/tests/pass0/t03_checked_indirect_call_with_result.test @@ -10,10 +10,12 @@ discard """ (Block (Params) (Return (IntVal 100))))) (ProcDef (Type 0) 0 - (Locals (Int 8)) + (Locals (Int 8) (Int 8)) (List (Block (Params) - (CheckedCallAsgn (Local 0) (Type 0) (ProcVal 0) + (Asgn (Local 1) (Proc 0)) + (CheckedCallAsgn (Local 0) (Type 0) + (Copy (Local 1)) (Goto 1) (Unwind))) (Block (Params) (Return diff --git a/tests/pass0/t03_proc_value.test b/tests/pass0/t03_proc_value.test index 6fccdbac..37bf8bbc 100644 --- a/tests/pass0/t03_proc_value.test +++ b/tests/pass0/t03_proc_value.test @@ -9,7 +9,7 @@ discard """ (ProcDef (Type 0) 0 (Locals) (List (Block (Params) - (Return (ProcVal 0)) + (Return (Proc 0)) ) ) ) diff --git a/tests/pass0/t03_void_call.test b/tests/pass0/t03_void_call.test index 7ad2a447..537b0d1c 100644 --- a/tests/pass0/t03_void_call.test +++ b/tests/pass0/t03_void_call.test @@ -11,8 +11,8 @@ discard """ )) (ProcDef (Type 0) 0 (Locals) (List (Block (Params) - (Call (Proc 0)) + (Call (Type 0) (Proc 0)) (Return) ) )) -) \ No newline at end of file +) diff --git a/tests/pass0/t04_checked_call_asgn.test b/tests/pass0/t04_checked_call_asgn.test index 17fb0775..bd56a326 100644 --- a/tests/pass0/t04_checked_call_asgn.test +++ b/tests/pass0/t04_checked_call_asgn.test @@ -17,7 +17,7 @@ discard """ (Locals (Int 8)) (List (Block (Params) - (CheckedCallAsgn (Local 0) (Proc 0) (Goto 1) (Unwind)) + (CheckedCallAsgn (Local 0) (Type 0) (Proc 0) (Goto 1) (Unwind)) ) (Block (Params) (Return (Copy (Local 0))) diff --git a/tests/pass0/t04_indirect_call.expected b/tests/pass0/t04_indirect_call.expected index 4dff56c9..dfd28578 100644 --- a/tests/pass0/t04_indirect_call.expected +++ b/tests/pass0/t04_indirect_call.expected @@ -4,7 +4,10 @@ Ret .end .start t0 p1 +.local lo0 int LdImmInt 1 + PopLocal lo0 + GetLocal lo0 IndCall t0 0 Ret .end diff --git a/tests/pass0/t04_indirect_call.test b/tests/pass0/t04_indirect_call.test index 0d82b811..b10a43fc 100644 --- a/tests/pass0/t04_indirect_call.test +++ b/tests/pass0/t04_indirect_call.test @@ -13,10 +13,12 @@ discard """ ) ) ) - (ProcDef (Type 0) 0 (Locals) + (ProcDef (Type 0) 0 + (Locals (Int 8)) (List (Block (Params) - (Return (Call (Type 0) (ProcVal 0))) + (Asgn (Local 0) (Proc 0)) + (Return (Call (Type 0) (Copy (Local 0)))) ) ) ) diff --git a/tests/pass0/t04_parameters.test b/tests/pass0/t04_parameters.test index f1697c42..4ba5bf58 100644 --- a/tests/pass0/t04_parameters.test +++ b/tests/pass0/t04_parameters.test @@ -21,7 +21,7 @@ discard """ ) (ProcDef (Type 1) 0 (Locals) (List (Block (Params) - (Return (Call (Proc 0) (IntVal 1) (IntVal 2))) + (Return (Call (Type 0) (Proc 0) (IntVal 1) (IntVal 2))) ) )) -) \ No newline at end of file +) diff --git a/tests/pass0/t05_foreign_procedure.test b/tests/pass0/t05_foreign_procedure.test index 7f442323..b457fe2d 100644 --- a/tests/pass0/t05_foreign_procedure.test +++ b/tests/pass0/t05_foreign_procedure.test @@ -11,4 +11,4 @@ discard """ (List (Block (Params) (Return - (Call (Proc 0) (IntVal 100))))))) + (Call (Type 0) (Proc 0) (IntVal 100))))))) diff --git a/tests/pass0/t05_parameters_and_stack.test b/tests/pass0/t05_parameters_and_stack.test index f011a79e..f5bd8df2 100644 --- a/tests/pass0/t05_parameters_and_stack.test +++ b/tests/pass0/t05_parameters_and_stack.test @@ -25,4 +25,4 @@ discard """ (List (Block (Params) (Return - (Call (Proc 0) (IntVal 1) (IntVal 2))))))) + (Call (Type 0) (Proc 0) (IntVal 1) (IntVal 2))))))) diff --git a/tests/pass25/t02_checked_call.expected b/tests/pass25/t02_checked_call.expected index e5e77d9a..fe31371c 100644 --- a/tests/pass25/t02_checked_call.expected +++ b/tests/pass25/t02_checked_call.expected @@ -11,7 +11,7 @@ (ProcDef (Type 1) (Locals) (List (Block (Params) - (CheckedCall (Proc 0) + (CheckedCall (Type 1) (Proc 0) (Goto 1) (Unwind))) (Block (Params) diff --git a/tests/pass25/t02_checked_call.test b/tests/pass25/t02_checked_call.test index 81677763..8de925cb 100644 --- a/tests/pass25/t02_checked_call.test +++ b/tests/pass25/t02_checked_call.test @@ -8,5 +8,5 @@ (Return))) (ProcDef (Type 1) (Params) (Locals) (Stmts - (CheckedCall (Proc 0) (Unwind)) + (CheckedCall (Type 1) (Proc 0) (Unwind)) (Return)))) diff --git a/tests/pass25/t02_checked_call_asgn.expected b/tests/pass25/t02_checked_call_asgn.expected index 731ffb39..a314eecf 100644 --- a/tests/pass25/t02_checked_call_asgn.expected +++ b/tests/pass25/t02_checked_call_asgn.expected @@ -13,7 +13,7 @@ (Locals (Type 0)) (List (Block (Params) - (CheckedCallAsgn (Local 0) (Proc 0) + (CheckedCallAsgn (Local 0) (Type 1) (Proc 0) (Goto 1) (Unwind))) (Block (Params) diff --git a/tests/pass25/t02_checked_call_asgn.test b/tests/pass25/t02_checked_call_asgn.test index 4960b8cb..afb95aed 100644 --- a/tests/pass25/t02_checked_call_asgn.test +++ b/tests/pass25/t02_checked_call_asgn.test @@ -10,5 +10,5 @@ (ProcDef (Type 2) (Params) (Locals (Type 0)) (Stmts - (CheckedCallAsgn (Local 0) (Proc 0) (Unwind)) + (CheckedCallAsgn (Local 0) (Type 1) (Proc 0) (Unwind)) (Return)))) diff --git a/tests/pass25/t02_parameters.expected b/tests/pass25/t02_parameters.expected index b4e2a51e..0257ad82 100644 --- a/tests/pass25/t02_parameters.expected +++ b/tests/pass25/t02_parameters.expected @@ -16,5 +16,5 @@ (ProcDef (Type 2) (Locals) (List (Block (Params) - (Call (Proc 0) (IntVal 100) (IntVal 200)) + (Call (Type 1) (Proc 0) (IntVal 100) (IntVal 200)) (Return))))) diff --git a/tests/pass25/t02_parameters.test b/tests/pass25/t02_parameters.test index 48bc2c60..83874243 100644 --- a/tests/pass25/t02_parameters.test +++ b/tests/pass25/t02_parameters.test @@ -14,5 +14,5 @@ (ProcDef (Type 2) (Params) (Locals) (Stmts - (Call (Proc 0) (IntVal 100) (IntVal 200)) + (Call (Type 1) (Proc 0) (IntVal 100) (IntVal 200)) (Return)))) diff --git a/tests/pass25/t02_return_value.expected b/tests/pass25/t02_return_value.expected index 8bcfde79..49360a71 100644 --- a/tests/pass25/t02_return_value.expected +++ b/tests/pass25/t02_return_value.expected @@ -13,5 +13,5 @@ (List (Block (Params) (Drop - (Call (Proc 0))) + (Call (Type 1) (Proc 0))) (Return))))) diff --git a/tests/pass25/t02_return_value.test b/tests/pass25/t02_return_value.test index ba14bc00..fdbc7adf 100644 --- a/tests/pass25/t02_return_value.test +++ b/tests/pass25/t02_return_value.test @@ -10,5 +10,5 @@ (ProcDef (Type 2) (Params) (Locals) (Stmts - (Drop (Call (Proc 0))) + (Drop (Call (Type 1) (Proc 0))) (Return)))) diff --git a/tests/pass25/t03_checked_call_except.expected b/tests/pass25/t03_checked_call_except.expected index af55e8f4..f3d42bbb 100644 --- a/tests/pass25/t03_checked_call_except.expected +++ b/tests/pass25/t03_checked_call_except.expected @@ -12,7 +12,7 @@ (Locals (Type 0)) (List (Block (Params) - (CheckedCall (Proc 0) + (CheckedCall (Type 1) (Proc 0) (Goto 1) (Goto 2))) (Block (Params) diff --git a/tests/pass25/t03_checked_call_except.test b/tests/pass25/t03_checked_call_except.test index db18f750..0fbd4329 100644 --- a/tests/pass25/t03_checked_call_except.test +++ b/tests/pass25/t03_checked_call_except.test @@ -9,7 +9,7 @@ (ProcDef (Type 1) (Params) (Locals (Type 0)) (Stmts - (CheckedCall (Proc 0) (Goto 0)) + (CheckedCall (Type 1) (Proc 0) (Goto 0)) (Return) (Except 0 (Local 0)) (Return)))) diff --git a/tests/pass30/t02_checked_call.expected b/tests/pass30/t02_checked_call.expected index 0e2938cc..4672c051 100644 --- a/tests/pass30/t02_checked_call.expected +++ b/tests/pass30/t02_checked_call.expected @@ -7,5 +7,5 @@ (Stmts (Return))) (ProcDef (Type 0) (Params) (Locals) (Stmts - (CheckedCall (Proc 0) (Unwind)) + (CheckedCall (Type 0) (Proc 0) (Unwind)) (Return)))) diff --git a/tests/pass30/t02_checked_call.test b/tests/pass30/t02_checked_call.test index 358e0838..b1f3bfc6 100644 --- a/tests/pass30/t02_checked_call.test +++ b/tests/pass30/t02_checked_call.test @@ -6,5 +6,5 @@ (Return)) (ProcDef (Type 0) (Params) (Locals) (Stmts - (CheckedCall (Proc 0)) + (CheckedCall (Type 0) (Proc 0)) (Return)))) diff --git a/tests/pass30/t02_checked_call_asgn.expected b/tests/pass30/t02_checked_call_asgn.expected index 82303a58..e05dec7e 100644 --- a/tests/pass30/t02_checked_call_asgn.expected +++ b/tests/pass30/t02_checked_call_asgn.expected @@ -11,5 +11,5 @@ (ProcDef (Type 2) (Params) (Locals (Type 0)) (Stmts - (CheckedCallAsgn (Local 0) (Proc 0) (Unwind)) + (CheckedCallAsgn (Local 0) (Type 1) (Proc 0) (Unwind)) (Return)))) diff --git a/tests/pass30/t02_checked_call_asgn.test b/tests/pass30/t02_checked_call_asgn.test index 7361176b..c51422cb 100644 --- a/tests/pass30/t02_checked_call_asgn.test +++ b/tests/pass30/t02_checked_call_asgn.test @@ -9,5 +9,5 @@ (ProcDef (Type 2) (Params) (Locals (Type 0)) (Stmts - (CheckedCallAsgn (Local 0) (Proc 0)) + (CheckedCallAsgn (Local 0) (Type 1) (Proc 0)) (Return)))) diff --git a/tests/pass30/t02_return_value.expected b/tests/pass30/t02_return_value.expected index 19bc7564..764ca1be 100644 --- a/tests/pass30/t02_return_value.expected +++ b/tests/pass30/t02_return_value.expected @@ -11,5 +11,5 @@ (ProcDef (Type 2) (Params) (Locals) (Stmts (Drop - (Call (Proc 0))) + (Call (Type 1) (Proc 0))) (Return)))) diff --git a/tests/pass30/t02_return_value.test b/tests/pass30/t02_return_value.test index 791e4747..14f44643 100644 --- a/tests/pass30/t02_return_value.test +++ b/tests/pass30/t02_return_value.test @@ -8,5 +8,5 @@ (Return (IntVal 100))) (ProcDef (Type 2) (Params) (Locals) (Stmts - (Drop (Call (Proc 0))) + (Drop (Call (Type 1) (Proc 0))) (Return)))) diff --git a/tests/passes/aggregate_params/aggregate_parameters.expected b/tests/passes/aggregate_params/aggregate_parameters.expected index 975359be..c7e47aa7 100644 --- a/tests/passes/aggregate_params/aggregate_parameters.expected +++ b/tests/passes/aggregate_params/aggregate_parameters.expected @@ -40,15 +40,15 @@ (Block (Params) (Asgn (Local 1) (Copy (Local 0))) - (Call (Proc 1) + (Call (Type 2) (Proc 1) (Addr (Local 1))) (Asgn (Local 2) (Load (Type 0) (Addr (Local 0)))) - (Call (Proc 1) + (Call (Type 2) (Proc 1) (Addr (Local 2))) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 3))) - (Call (Proc 1) + (Call (Type 2) (Proc 1) (Addr (Local 3))) (Return))))) diff --git a/tests/passes/aggregate_params/aggregate_parameters.test b/tests/passes/aggregate_params/aggregate_parameters.test index c5b35f8a..46e443c3 100644 --- a/tests/passes/aggregate_params/aggregate_parameters.test +++ b/tests/passes/aggregate_params/aggregate_parameters.test @@ -38,11 +38,11 @@ discard """ (Locals (Type 0)) (List (Block (Params) - (Call (Proc 1) + (Call (Type 2) (Proc 1) (Copy (Local 0))) - (Call (Proc 1) + (Call (Type 2) (Proc 1) (Load (Type 0) (Addr (Local 0)))) - (Call (Proc 1) - (Call (Proc 0))) + (Call (Type 2) (Proc 1) + (Call (Type 1) (Proc 0))) (Return))))) diff --git a/tests/passes/aggregate_params/call_argument_hoisting.expected b/tests/passes/aggregate_params/call_argument_hoisting.expected index 1ecc71fc..4f72b647 100644 --- a/tests/passes/aggregate_params/call_argument_hoisting.expected +++ b/tests/passes/aggregate_params/call_argument_hoisting.expected @@ -18,18 +18,18 @@ (Block (Params) (Asgn (Local 3) (Copy (Local 0))) - (Call (Proc 0) (IntVal 100) + (Call (Type 1) (Proc 0) (IntVal 100) (Addr (Local 3)) (Copy (Local 1))) (Asgn (Local 5) (Copy (Local 1))) (Asgn (Local 4) (Copy (Local 0))) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Copy (Local 5)) (Addr (Local 4)) (IntVal 100)) - (Asgn (Local 2) (ProcVal 0)) + (Asgn (Local 2) (Proc 0)) (Asgn (Local 7) (Copy (Local 2))) (Asgn (Local 6) @@ -43,7 +43,7 @@ (Copy (Local 1))) (Asgn (Local 8) (Copy (Local 0))) - (CheckedCall (Proc 0) + (CheckedCall (Type 1) (Proc 0) (Copy (Local 9)) (Addr (Local 8)) (Copy (Local 1)) diff --git a/tests/passes/aggregate_params/call_argument_hoisting.test b/tests/passes/aggregate_params/call_argument_hoisting.test index bbff24fe..5c0b13e4 100644 --- a/tests/passes/aggregate_params/call_argument_hoisting.test +++ b/tests/passes/aggregate_params/call_argument_hoisting.test @@ -23,24 +23,24 @@ discard """ (Locals (Type 0) (Int 4) (UInt 8)) (List (Block (Params) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (IntVal 100) (Copy (Local 0)) (Copy (Local 1))) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Copy (Local 1)) (Copy (Local 0)) (IntVal 100)) - (Asgn (Local 2) (ProcVal 0)) + (Asgn (Local 2) (Proc 0)) (Call (Type 1) (Copy (Local 2)) (IntVal 100) (Copy (Local 0)) (IntVal 100)) - (CheckedCall (Proc 0) + (CheckedCall (Type 1) (Proc 0) (Copy (Local 1)) (Copy (Local 0)) (Copy (Local 1)) diff --git a/tests/passes/aggregate_params/operand_hoisting.expected b/tests/passes/aggregate_params/operand_hoisting.expected index b4c690e2..e1864b79 100644 --- a/tests/passes/aggregate_params/operand_hoisting.expected +++ b/tests/passes/aggregate_params/operand_hoisting.expected @@ -27,7 +27,7 @@ (Drop (Add (Int 4) (Copy (Local 3)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 2))))) (Asgn (Local 5) (Copy (Local 1))) @@ -36,7 +36,7 @@ (Drop (Sub (Int 4) (Copy (Local 5)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 4))))) (Asgn (Local 7) (Copy (Local 1))) @@ -45,7 +45,7 @@ (Drop (Mul (Int 4) (Copy (Local 7)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 6))))) (Asgn (Local 9) (Copy (Local 1))) @@ -54,7 +54,7 @@ (Drop (Div (Int 4) (Copy (Local 9)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 8))))) (Asgn (Local 11) (Copy (Local 1))) @@ -63,7 +63,7 @@ (Drop (Mod (Int 4) (Copy (Local 11)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 10))))) (Asgn (Local 13) (Copy (Local 1))) @@ -72,7 +72,7 @@ (Drop (AddChck (Int 4) (Copy (Local 13)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 12))) (Local 1))) (Asgn (Local 15) @@ -82,7 +82,7 @@ (Drop (SubChck (Int 4) (Copy (Local 15)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 14))) (Local 1))) (Asgn (Local 17) @@ -92,7 +92,7 @@ (Drop (BitAnd (Int 4) (Copy (Local 17)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 16))))) (Asgn (Local 19) (Copy (Local 1))) @@ -101,7 +101,7 @@ (Drop (BitOr (Int 4) (Copy (Local 19)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 18))))) (Asgn (Local 21) (Copy (Local 1))) @@ -110,7 +110,7 @@ (Drop (BitXor (Int 4) (Copy (Local 21)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 20))))) (Asgn (Local 23) (Copy (Local 1))) @@ -119,7 +119,7 @@ (Drop (Eq (Int 4) (Copy (Local 23)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 22))))) (Asgn (Local 25) (Copy (Local 1))) @@ -128,7 +128,7 @@ (Drop (Lt (Int 4) (Copy (Local 25)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 24))))) (Asgn (Local 27) (Copy (Local 1))) @@ -137,7 +137,7 @@ (Drop (Le (Int 4) (Copy (Local 27)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 26))))) (Asgn (Local 29) (Copy (Local 1))) @@ -146,7 +146,7 @@ (Drop (Shl (Int 4) (Copy (Local 29)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 28))))) (Asgn (Local 31) (Copy (Local 1))) @@ -155,7 +155,7 @@ (Drop (Shr (Int 4) (Copy (Local 31)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 30))))) (Asgn (Local 34) (Copy (Local 1))) @@ -166,7 +166,7 @@ (Blit (Copy (Local 34)) (Copy (Local 33)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 32)))) (Asgn (Local 36) (Copy (Local 1))) @@ -174,6 +174,6 @@ (Copy (Local 0))) (Clear (Copy (Local 36)) - (Call (Proc 0) + (Call (Type 1) (Proc 0) (Addr (Local 35)))) (Return))))) diff --git a/tests/passes/aggregate_params/operand_hoisting.test b/tests/passes/aggregate_params/operand_hoisting.test index d76dcbc3..561fd16e 100644 --- a/tests/passes/aggregate_params/operand_hoisting.test +++ b/tests/passes/aggregate_params/operand_hoisting.test @@ -27,71 +27,71 @@ discard """ (Drop (Add (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Sub (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Mul (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Div (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Mod (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (AddChck (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))) + (Call (Type 1) (Proc 0) (Copy (Local 0))) (Local 1))) (Drop (SubChck (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))) + (Call (Type 1) (Proc 0) (Copy (Local 0))) (Local 1))) (Drop (BitAnd (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (BitOr (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (BitXor (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Eq (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Lt (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Le (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Shl (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Drop (Shr (Int 4) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0))))) + (Call (Type 1) (Proc 0) (Copy (Local 0))))) (Blit (Copy (Local 1)) (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0)))) + (Call (Type 1) (Proc 0) (Copy (Local 0)))) (Clear (Copy (Local 1)) - (Call (Proc 0) (Copy (Local 0)))) + (Call (Type 1) (Proc 0) (Copy (Local 0)))) (Return))))) diff --git a/tests/passes/aggregate_params/path_operand_hoisting.expected b/tests/passes/aggregate_params/path_operand_hoisting.expected index 0843902d..ee8b2446 100644 --- a/tests/passes/aggregate_params/path_operand_hoisting.expected +++ b/tests/passes/aggregate_params/path_operand_hoisting.expected @@ -33,7 +33,7 @@ (Asgn (Path (Int 4) (Local 1) (Copy (Local 5))) - (Call (Proc 0) + (Call (Type 3) (Proc 0) (Addr (Local 4)))) (Asgn (Local 7) (Copy (Local 3))) @@ -46,7 +46,7 @@ (Path (Type 0) (Local 2) (Copy (Local 7))))) 0) - (Call (Proc 0) + (Call (Type 3) (Proc 0) (Addr (Local 6)))) (Asgn (Local 9) (Copy (Local 3))) @@ -56,13 +56,13 @@ (Addr (Path (Int 4) (Local 1) (Copy (Local 9)))) - (Call (Proc 0) + (Call (Type 3) (Proc 0) (Addr (Local 8)))) (Asgn (Local 11) (Copy (Local 3))) (Asgn (Local 10) (Copy (Local 0))) - (Call (Proc 1) + (Call (Type 4) (Proc 1) (Addr (Path (Int 4) (Local 1) (Copy (Local 11)))) diff --git a/tests/passes/aggregate_params/path_operand_hoisting.test b/tests/passes/aggregate_params/path_operand_hoisting.test index 9446d689..8139516e 100644 --- a/tests/passes/aggregate_params/path_operand_hoisting.test +++ b/tests/passes/aggregate_params/path_operand_hoisting.test @@ -36,7 +36,7 @@ discard """ (Asgn (Path (Int 4) (Local 1) (Copy (Local 3))) - (Call (Proc 0) + (Call (Type 3) (Proc 0) (Copy (Local 0)))) (Asgn @@ -46,16 +46,16 @@ discard """ (Path (Type 0) (Local 2) (Copy (Local 3))))) 0) - (Call (Proc 0) + (Call (Type 3) (Proc 0) (Copy (Local 0)))) (Store (Int 4) (Addr (Path (Int 4) (Local 1) (Copy (Local 3)))) - (Call (Proc 0) (Copy (Local 0)))) + (Call (Type 3) (Proc 0) (Copy (Local 0)))) - (Call (Proc 1) + (Call (Type 4) (Proc 1) (Addr (Path (Int 4) (Local 1) (Copy (Local 3)))) diff --git a/tests/passes/aggregate_params/return_aggregate.expected b/tests/passes/aggregate_params/return_aggregate.expected index 6e527b2c..4be1c084 100644 --- a/tests/passes/aggregate_params/return_aggregate.expected +++ b/tests/passes/aggregate_params/return_aggregate.expected @@ -21,23 +21,23 @@ (List (Block (Params (Local 0)) - (Call (Proc 0) (IntVal 100) + (Call (Type 2) (Proc 0) (IntVal 100) (Copy (Local 0))) (Return)))) (ProcDef (Type 3) (Locals (Type 0) (Type 0) (Type 0) (Type 0)) (List (Block (Params) - (Call (Proc 0) (IntVal 100) + (Call (Type 2) (Proc 0) (IntVal 100) (Addr (Local 1))) (Asgn (Local 0) (Copy (Local 1))) - (Call (Proc 0) (IntVal 100) + (Call (Type 2) (Proc 0) (IntVal 100) (Addr (Local 2))) (Store (Type 0) (Addr (Local 0)) (Copy (Local 2))) - (CheckedCall (Proc 0) (IntVal 100) + (CheckedCall (Type 2) (Proc 0) (IntVal 100) (Addr (Local 3)) (Goto 1) (Unwind))) (Block (Params) diff --git a/tests/passes/aggregate_params/return_aggregate.test b/tests/passes/aggregate_params/return_aggregate.test index 28ba797c..85e650b9 100644 --- a/tests/passes/aggregate_params/return_aggregate.test +++ b/tests/passes/aggregate_params/return_aggregate.test @@ -29,18 +29,18 @@ discard """ (List (Block (Params) (Return - (Call (Proc 0) (IntVal 100)))))) + (Call (Type 2) (Proc 0) (IntVal 100)))))) (ProcDef (Type 3) (Locals (Type 0)) (List (Block (Params) (Asgn (Local 0) - (Call (Proc 0) (IntVal 100))) + (Call (Type 2) (Proc 0) (IntVal 100))) (Store (Type 0) (Addr (Local 0)) - (Call (Proc 0) (IntVal 100))) - (CheckedCallAsgn (Local 0) (Proc 0) (IntVal 100) + (Call (Type 2) (Proc 0) (IntVal 100))) + (CheckedCallAsgn (Local 0) (Type 2) (Proc 0) (IntVal 100) (Goto 1) (Unwind))) (Block (Params) (Return))))) diff --git a/tests/passes/inline_types/inline.expected b/tests/passes/inline_types/inline.expected index 5b099933..16e7176a 100644 --- a/tests/passes/inline_types/inline.expected +++ b/tests/passes/inline_types/inline.expected @@ -17,5 +17,5 @@ (List (Block (Params) (Drop - (Call (Type 0) (ProcVal 0) (FloatVal 2.0))) + (Call (Type 0) (Proc 0) (FloatVal 2.0))) (Return))))) diff --git a/tests/passes/inline_types/inline.test b/tests/passes/inline_types/inline.test index 7fc9b2c3..ec93beeb 100644 --- a/tests/passes/inline_types/inline.test +++ b/tests/passes/inline_types/inline.test @@ -30,5 +30,5 @@ discard """ (List (Block (Params) (Drop - (Call (Type 3) (ProcVal 0) (FloatVal 2.0))) + (Call (Type 3) (Proc 0) (FloatVal 2.0))) (Return)))))