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 | |
parent | 3270676e77676335446287fcff05aa6a6b9b4919 (diff) | |
download | Nim-2fc84325c7cfba82c54c652a5f1a795845b169a9.tar.gz |
should fix the nkExprColonExpr bug in the vm
-rw-r--r-- | compiler/evalffi.nim | 2 | ||||
-rw-r--r-- | compiler/vm.nim | 3 | ||||
-rw-r--r-- | compiler/vmgen.nim | 22 | ||||
-rw-r--r-- | lib/pure/dynlib.nim | 2 |
4 files changed, 18 insertions, 11 deletions
diff --git a/compiler/evalffi.nim b/compiler/evalffi.nim index 54be0ccb2..db78da714 100644 --- a/compiler/evalffi.nim +++ b/compiler/evalffi.nim @@ -151,7 +151,7 @@ proc getField(n: PNode; position: int): PSym = else: discard proc packObject(x: PNode, typ: PType, res: pointer) = - InternalAssert x.kind in {nkObjConstr, nkPar} + internalAssert x.kind in {nkObjConstr, nkPar} # compute the field's offsets: discard typ.getSize for i in countup(ord(x.kind == nkObjConstr), sonsLen(x) - 1): diff --git a/compiler/vm.nim b/compiler/vm.nim index 2a80106a5..5c8e533f1 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -426,8 +426,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = let src = regs[rb].node if src.kind notin {nkEmpty..nkNilLit}: let n = src.sons[rc] - regs[ra].node = if n.kind == nkExprColonExpr: n[1] - else: n + regs[ra].node = n else: stackTrace(c, tos, pc, errIndexOutOfBounds) of opcWrObj: 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 = diff --git a/lib/pure/dynlib.nim b/lib/pure/dynlib.nim index 889912052..54a553173 100644 --- a/lib/pure/dynlib.nim +++ b/lib/pure/dynlib.nim @@ -92,7 +92,7 @@ elif defined(windows) or defined(dos): proc unloadLib(lib: TLibHandle) = FreeLibrary(cast[THINSTANCE](lib)) proc symAddr(lib: TLibHandle, name: cstring): pointer = - result = GetProcAddress(cast[THINSTANCE](lib), name) + result = getProcAddress(cast[THINSTANCE](lib), name) else: {.error: "no implementation for dynlib".} |