diff options
author | Araq <rumpf_a@web.de> | 2014-02-16 19:17:12 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-02-16 19:17:12 +0100 |
commit | 3ef92a34ee0712139d7527d0b3d3f8e725d9d549 (patch) | |
tree | f8c527cda03624da3d5cb55380e35db55b5ea66c /compiler/vmgen.nim | |
parent | 228d5173ffe3f7b0b474448994c8d520d916bb77 (diff) | |
download | Nim-3ef92a34ee0712139d7527d0b3d3f8e725d9d549.tar.gz |
fixes #922
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r-- | compiler/vmgen.nim | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index a6d044e24..6fca7f907 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -321,9 +321,18 @@ proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) = c.gen(n.sons[2], dest) c.patch(L1) +proc nilLiteral(n: PNode): PNode = + if n.kind == nkNilLit and n.typ.sym != nil and + n.typ.sym.magic == mPNimrodNode: + let nilo = newNodeIT(nkNilLit, n.info, n.typ) + result = newNodeIT(nkMetaNode, n.info, n.typ) + result.add nilo + else: + result = n + proc rawGenLiteral(c: PCtx; n: PNode): int = result = c.constants.len - c.constants.add n + c.constants.add n.nilLiteral internalAssert result < 0x7fff proc sameConstant*(a, b: PNode): bool = @@ -1109,7 +1118,12 @@ proc getNullValue(typ: PType, info: TLineInfo): PNode = result = newNodeIT(nkFloatLit, info, t) of tyVar, tyPointer, tyPtr, tyCString, tySequence, tyString, tyExpr, tyStmt, tyTypeDesc, tyStatic, tyRef: - result = newNodeIT(nkNilLit, info, t) + if t.sym != nil and t.sym.magic == mPNimrodNode: + let nilo = newNodeIT(nkNilLit, info, t) + result = newNodeIT(nkMetaNode, info, t) + result.add nilo + else: + result = newNodeIT(nkNilLit, info, t) of tyProc: if t.callConv != ccClosure: result = newNodeIT(nkNilLit, info, t) |