diff options
author | Araq <rumpf_a@web.de> | 2014-03-13 02:52:40 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-03-13 02:52:40 +0100 |
commit | 2fc84325c7cfba82c54c652a5f1a795845b169a9 (patch) | |
tree | 3d9dfdbe0e7030028124495d21c97645773c0346 /compiler/vmgen.nim | |
parent | 3270676e77676335446287fcff05aa6a6b9b4919 (diff) | |
download | Nim-2fc84325c7cfba82c54c652a5f1a795845b169a9.tar.gz |
should fix the nkExprColonExpr bug in the vm
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r-- | compiler/vmgen.nim | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index b1a751723..0fc71189d 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -308,12 +308,20 @@ 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 = - result = n +proc canonConst(n: PNode): PNode = + if n.kind == nkExprColonExpr: + result = n.sons[1] + elif n.hasSubnodeWith(nkExprColonExpr): + result = n.copyNode + newSeq(result.sons, n.len) + for i in 0.. <n.len: + result.sons[i] = canonConst(n.sons[i]) + else: + result = n proc rawGenLiteral(c: PCtx; n: PNode): int = result = c.constants.len - c.constants.add n.nilLiteral + c.constants.add n.canonConst internalAssert result < 0x7fff proc sameConstant*(a, b: PNode): bool = @@ -329,10 +337,10 @@ proc sameConstant*(a, b: PNode): bool = of nkStrLit..nkTripleStrLit: result = a.strVal == b.strVal of nkType: result = a.typ == b.typ of nkEmpty, nkNilLit: result = true - else: - if sonsLen(a) == sonsLen(b): - for i in countup(0, sonsLen(a) - 1): - if not sameConstant(a.sons[i], b.sons[i]): return + else: + if sonsLen(a) == sonsLen(b): + for i in countup(0, sonsLen(a) - 1): + if not sameConstant(a.sons[i], b.sons[i]): return result = true proc genLiteral(c: PCtx; n: PNode): int = |