should fix the nkExprColonExpr bug in the vm

This commit is contained in:
Araq
2014-03-13 02:52:40 +01:00
parent 3270676e77
commit 2fc84325c7
4 changed files with 18 additions and 11 deletions

View File

@@ -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):

View File

@@ -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:

View File

@@ -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 =

View File

@@ -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".}