should fix the nkExprColonExpr bug in the vm
This commit is contained in:
parent
3270676e77
commit
2fc84325c7
4 changed files with 18 additions and 11 deletions
|
|
@ -151,7 +151,7 @@ proc getField(n: PNode; position: int): PSym =
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
proc packObject(x: PNode, typ: PType, res: pointer) =
|
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:
|
# compute the field's offsets:
|
||||||
discard typ.getSize
|
discard typ.getSize
|
||||||
for i in countup(ord(x.kind == nkObjConstr), sonsLen(x) - 1):
|
for i in countup(ord(x.kind == nkObjConstr), sonsLen(x) - 1):
|
||||||
|
|
|
||||||
|
|
@ -426,8 +426,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
let src = regs[rb].node
|
let src = regs[rb].node
|
||||||
if src.kind notin {nkEmpty..nkNilLit}:
|
if src.kind notin {nkEmpty..nkNilLit}:
|
||||||
let n = src.sons[rc]
|
let n = src.sons[rc]
|
||||||
regs[ra].node = if n.kind == nkExprColonExpr: n[1]
|
regs[ra].node = n
|
||||||
else: n
|
|
||||||
else:
|
else:
|
||||||
stackTrace(c, tos, pc, errIndexOutOfBounds)
|
stackTrace(c, tos, pc, errIndexOutOfBounds)
|
||||||
of opcWrObj:
|
of opcWrObj:
|
||||||
|
|
|
||||||
|
|
@ -308,12 +308,20 @@ proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) =
|
||||||
c.gen(n.sons[2], dest)
|
c.gen(n.sons[2], dest)
|
||||||
c.patch(L1)
|
c.patch(L1)
|
||||||
|
|
||||||
proc nilLiteral(n: PNode): PNode =
|
proc canonConst(n: PNode): PNode =
|
||||||
result = n
|
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 =
|
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
||||||
result = c.constants.len
|
result = c.constants.len
|
||||||
c.constants.add n.nilLiteral
|
c.constants.add n.canonConst
|
||||||
internalAssert result < 0x7fff
|
internalAssert result < 0x7fff
|
||||||
|
|
||||||
proc sameConstant*(a, b: PNode): bool =
|
proc sameConstant*(a, b: PNode): bool =
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ elif defined(windows) or defined(dos):
|
||||||
proc unloadLib(lib: TLibHandle) = FreeLibrary(cast[THINSTANCE](lib))
|
proc unloadLib(lib: TLibHandle) = FreeLibrary(cast[THINSTANCE](lib))
|
||||||
|
|
||||||
proc symAddr(lib: TLibHandle, name: cstring): pointer =
|
proc symAddr(lib: TLibHandle, name: cstring): pointer =
|
||||||
result = GetProcAddress(cast[THINSTANCE](lib), name)
|
result = getProcAddress(cast[THINSTANCE](lib), name)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
{.error: "no implementation for dynlib".}
|
{.error: "no implementation for dynlib".}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue