new VM: next steps

This commit is contained in:
Araq 2013-08-03 21:14:57 +02:00
commit 30bb68d48a
7 changed files with 72 additions and 28 deletions

View file

@ -144,7 +144,8 @@ proc processSym(c: PPassContext, n: PNode): PNode =
cannotRename.incl(s.id)
return
let last = first+identLen(line, first)-1
if last-first+1 != newName.len or differ(line, first, last, newName):
if differ(line, first, last, newName):
# last-first+1 != newName.len or
var x = line.subStr(0, first-1) & newName & line.substr(last+1)
when removeTP:
# the WinAPI module is full of 'TX = X' which after the substitution

View file

@ -663,6 +663,10 @@ proc execute(c: PCtx, start: int) =
of opcCallSite:
if c.callsite != nil: regs[ra] = c.callsite
else: stackTrace(c, tos, pc, errFieldXNotFound, "callsite")
of opcNLineInfo:
let rb = instr.regB
let n = regs[rb]
regs[ra] = newStrNodeT(n.info.toFileLineCol, n)
else:
InternalError(c.debug[pc], "unknown opcode " & $instr.opcode)
inc pc

View file

@ -85,6 +85,7 @@ type
opcNError,
opcNWarning,
opcNHint,
opcNLineInfo,
opcEcho,
opcIndCall, # dest = call regStart, n; where regStart = fn, arg1, ...

View file

@ -540,7 +540,8 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
of mLtF64: genBinaryABC(c, n, dest, opcLtFloat)
of mLePtr, mLeU, mLeU64: genBinaryABC(c, n, dest, opcLeu)
of mLtPtr, mLtU, mLtU64: genBinaryABC(c, n, dest, opcLtu)
of mEqProc, mEqRef, mEqUntracedRef: genBinaryABC(c, n, dest, opcEqRef)
of mEqProc, mEqRef, mEqUntracedRef, mEqCString:
genBinaryABC(c, n, dest, opcEqRef)
of mXor: genBinaryABC(c, n, dest, opcXor)
of mNot: genUnaryABC(c, n, dest, opcNot)
of mUnaryMinusI, mUnaryMinusI64: genUnaryABC(c, n, dest, opcUnaryMinusInt)
@ -645,7 +646,8 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
genUnaryABC(c, n, dest, opcParseExprToAst)
of mParseStmtToAst:
genUnaryABC(c, n, dest, opcParseStmtToAst)
of mExpandToAst: InternalError(n.info, "cannot generate code for: " & $m)
of mExpandToAst:
InternalError(n.info, "cannot generate code for: " & $m)
of mTypeTrait: InternalError(n.info, "cannot generate code for: " & $m)
of mIs: InternalError(n.info, "cannot generate code for: " & $m)
of mSlurp: genUnaryABC(c, n, dest, opcSlurp)
@ -700,9 +702,10 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest) =
of mNCallSite:
if dest < 0: dest = c.getTemp(n.typ)
c.gABC(n, opcCallSite, dest)
of mMinI, mMaxI, mMinI64, mMaxI64, mAbsF64, mMinF64, mMaxF64, mAbsI, mAbsI64:
c.genCall(n, dest)
else:
# XXX get rid of these: mMinI, mMaxI, mMinI64, mMaxI64, mMinF64, mMaxF64
# mGCref, mGCunref, mEqCString, mAbsI, mAbsI64, mAbsF64
# mGCref, mGCunref,
InternalError(n.info, "cannot generate code for: " & $m)
const