diff options
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r-- | compiler/vmgen.nim | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 3c0f8dbc9..7c0c3d4f5 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -328,6 +328,7 @@ proc canonValue*(n: PNode): PNode = proc rawGenLiteral(c: PCtx; n: PNode): int = result = c.constants.len + assert(n.kind != nkCall) c.constants.add n.canonValue internalAssert result < 0x7fff @@ -1033,6 +1034,7 @@ proc genAsgn(c: PCtx; dest: TDest; ri: PNode; requiresCopy: bool) = proc setSlot(c: PCtx; v: PSym) = # XXX generate type initialization here? if v.position == 0: + if c.prc.maxSlots == 0: c.prc.maxSlots = 1 v.position = c.prc.maxSlots c.prc.slots[v.position] = (inUse: true, kind: if v.kind == skLet: slotFixedLet else: slotFixedVar) @@ -1285,16 +1287,13 @@ proc genVarSection(c: PCtx; n: PNode) = if s.position == 0: if sfImportc in s.flags: c.importcSym(a.info, s) else: - let sa = if s.ast.isNil: getNullValue(s.typ, a.info) - else: canonValue(s.ast) + let sa = getNullValue(s.typ, a.info) + #if s.ast.isNil: getNullValue(s.typ, a.info) + #else: canonValue(s.ast) + assert sa.kind != nkCall c.globals.add(sa) s.position = c.globals.len - if a.sons[2].kind == nkEmpty: - when false: - withTemp(tmp, s.typ): - c.gABx(a, opcLdNull, tmp, c.genType(s.typ)) - c.gABx(a, whichAsgnOpc(a.sons[0], opcWrGlobal), tmp, s.position) - else: + if a.sons[2].kind != nkEmpty: let tmp = c.genx(a.sons[0], {gfAddrOf}) let val = c.genx(a.sons[2]) c.gABC(a, opcWrDeref, tmp, val) @@ -1502,7 +1501,7 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) = else: localError(n.info, errGenerated, "VM is not allowed to 'cast'") else: - internalError n.info, "too implement " & $n.kind + internalError n.info, "cannot generate VM code for " & n.renderTree proc removeLastEof(c: PCtx) = let last = c.code.len-1 |