VM: minor fixes to make lexim work
This commit is contained in:
parent
dc3a0bc009
commit
7be092bba5
4 changed files with 75 additions and 67 deletions
|
|
@ -142,7 +142,7 @@ proc swapOperands*(op: PNode) =
|
||||||
op.sons[2] = tmp
|
op.sons[2] = tmp
|
||||||
|
|
||||||
proc isRange*(n: PNode): bool {.inline.} =
|
proc isRange*(n: PNode): bool {.inline.} =
|
||||||
if n.kind == nkInfix:
|
if n.kind in nkCallKinds:
|
||||||
if n[0].kind == nkIdent and n[0].ident.id == ord(wDotDot) or
|
if n[0].kind == nkIdent and n[0].ident.id == ord(wDotDot) or
|
||||||
n[0].kind in {nkClosedSymChoice, nkOpenSymChoice} and
|
n[0].kind in {nkClosedSymChoice, nkOpenSymChoice} and
|
||||||
n[0][1].sym.name.id == ord(wDotDot):
|
n[0][1].sym.name.id == ord(wDotDot):
|
||||||
|
|
|
||||||
|
|
@ -1043,7 +1043,14 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
let newLen = regs[rb].intVal.int
|
let newLen = regs[rb].intVal.int
|
||||||
if regs[ra].node.isNil: stackTrace(c, tos, pc, errNilAccess)
|
if regs[ra].node.isNil: stackTrace(c, tos, pc, errNilAccess)
|
||||||
else: setLen(regs[ra].node.sons, newLen)
|
else:
|
||||||
|
let oldLen = regs[ra].node.len
|
||||||
|
setLen(regs[ra].node.sons, newLen)
|
||||||
|
if oldLen < newLen:
|
||||||
|
# XXX This is still not entirely correct
|
||||||
|
# set to default value:
|
||||||
|
for i in oldLen .. <newLen:
|
||||||
|
regs[ra].node.sons[i] = newNodeI(nkEmpty, c.debug[pc])
|
||||||
of opcSwap:
|
of opcSwap:
|
||||||
let rb = instr.regB
|
let rb = instr.regB
|
||||||
if regs[ra].kind == regs[rb].kind:
|
if regs[ra].kind == regs[rb].kind:
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const
|
||||||
byteExcess* = 128 # we use excess-K for immediates
|
byteExcess* = 128 # we use excess-K for immediates
|
||||||
wordExcess* = 32768
|
wordExcess* = 32768
|
||||||
|
|
||||||
MaxLoopIterations* = 500_000 # max iterations of all loops
|
MaxLoopIterations* = 1500_000 # max iterations of all loops
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1364,7 +1364,7 @@ proc getNullValue(typ: PType, info: TLineInfo): PNode =
|
||||||
of tyCString, tyString:
|
of tyCString, tyString:
|
||||||
result = newNodeIT(nkStrLit, info, t)
|
result = newNodeIT(nkStrLit, info, t)
|
||||||
of tyVar, tyPointer, tyPtr, tySequence, tyExpr,
|
of tyVar, tyPointer, tyPtr, tySequence, tyExpr,
|
||||||
tyStmt, tyTypeDesc, tyStatic, tyRef:
|
tyStmt, tyTypeDesc, tyStatic, tyRef, tyNil:
|
||||||
result = newNodeIT(nkNilLit, info, t)
|
result = newNodeIT(nkNilLit, info, t)
|
||||||
of tyProc:
|
of tyProc:
|
||||||
if t.callConv != ccClosure:
|
if t.callConv != ccClosure:
|
||||||
|
|
@ -1391,7 +1391,7 @@ proc getNullValue(typ: PType, info: TLineInfo): PNode =
|
||||||
addSon(result, getNullValue(t.sons[i], info))
|
addSon(result, getNullValue(t.sons[i], info))
|
||||||
of tySet:
|
of tySet:
|
||||||
result = newNodeIT(nkCurly, info, t)
|
result = newNodeIT(nkCurly, info, t)
|
||||||
else: internalError("getNullValue: " & $t.kind)
|
else: internalError(info, "getNullValue: " & $t.kind)
|
||||||
|
|
||||||
proc ldNullOpcode(t: PType): TOpcode =
|
proc ldNullOpcode(t: PType): TOpcode =
|
||||||
if fitsRegister(t): opcLdNullReg else: opcLdNull
|
if fitsRegister(t): opcLdNullReg else: opcLdNull
|
||||||
|
|
@ -1610,7 +1610,8 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) =
|
||||||
genBreak(c, n)
|
genBreak(c, n)
|
||||||
of nkTryStmt: genTry(c, n, dest)
|
of nkTryStmt: genTry(c, n, dest)
|
||||||
of nkStmtList:
|
of nkStmtList:
|
||||||
unused(n, dest)
|
#unused(n, dest)
|
||||||
|
# XXX Fix this bug properly, lexim triggers it
|
||||||
for x in n: gen(c, x)
|
for x in n: gen(c, x)
|
||||||
of nkStmtListExpr:
|
of nkStmtListExpr:
|
||||||
let L = n.len-1
|
let L = n.len-1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue