cleaned up whitespace
This commit is contained in:
parent
1ca2db0273
commit
8ade324b8c
1 changed files with 22 additions and 22 deletions
|
|
@ -239,7 +239,7 @@ proc pushSafePoint(f: PStackFrame; pc: int) =
|
||||||
|
|
||||||
proc popSafePoint(f: PStackFrame) = discard f.safePoints.pop()
|
proc popSafePoint(f: PStackFrame) = discard f.safePoints.pop()
|
||||||
|
|
||||||
proc cleanUpOnException(c: PCtx; tos: PStackFrame):
|
proc cleanUpOnException(c: PCtx; tos: PStackFrame):
|
||||||
tuple[pc: int, f: PStackFrame] =
|
tuple[pc: int, f: PStackFrame] =
|
||||||
let raisedType = c.currentExceptionA.typ.skipTypes(abstractPtrs)
|
let raisedType = c.currentExceptionA.typ.skipTypes(abstractPtrs)
|
||||||
var f = tos
|
var f = tos
|
||||||
|
|
@ -257,7 +257,7 @@ proc cleanUpOnException(c: PCtx; tos: PStackFrame):
|
||||||
let exceptType = c.types[c.code[pc2].regBx-wordExcess].skipTypes(
|
let exceptType = c.types[c.code[pc2].regBx-wordExcess].skipTypes(
|
||||||
abstractPtrs)
|
abstractPtrs)
|
||||||
if inheritanceDiff(exceptType, raisedType) <= 0:
|
if inheritanceDiff(exceptType, raisedType) <= 0:
|
||||||
# mark exception as handled but keep it in B for
|
# mark exception as handled but keep it in B for
|
||||||
# the getCurrentException() builtin:
|
# the getCurrentException() builtin:
|
||||||
c.currentExceptionB = c.currentExceptionA
|
c.currentExceptionB = c.currentExceptionA
|
||||||
c.currentExceptionA = nil
|
c.currentExceptionA = nil
|
||||||
|
|
@ -349,14 +349,14 @@ proc opConv*(dest: var TFullReg, src: TFullReg, desttyp, srctyp: PType): bool =
|
||||||
if dest.kind != rkFloat:
|
if dest.kind != rkFloat:
|
||||||
myreset(dest); dest.kind = rkFloat
|
myreset(dest); dest.kind = rkFloat
|
||||||
case skipTypes(srctyp, abstractRange).kind
|
case skipTypes(srctyp, abstractRange).kind
|
||||||
of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyBool, tyChar:
|
of tyInt..tyInt64, tyUInt..tyUInt64, tyEnum, tyBool, tyChar:
|
||||||
dest.floatVal = toFloat(src.intVal.int)
|
dest.floatVal = toFloat(src.intVal.int)
|
||||||
else:
|
else:
|
||||||
dest.floatVal = src.floatVal
|
dest.floatVal = src.floatVal
|
||||||
else:
|
else:
|
||||||
asgnComplex(dest, src)
|
asgnComplex(dest, src)
|
||||||
|
|
||||||
proc compile(c: PCtx, s: PSym): int =
|
proc compile(c: PCtx, s: PSym): int =
|
||||||
result = vmgen.genProc(c, s)
|
result = vmgen.genProc(c, s)
|
||||||
when debugEchoCode: c.echoCode result
|
when debugEchoCode: c.echoCode result
|
||||||
#c.echoCode
|
#c.echoCode
|
||||||
|
|
@ -396,10 +396,10 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
pc = tos.comesFrom
|
pc = tos.comesFrom
|
||||||
tos = tos.next
|
tos = tos.next
|
||||||
let retVal = regs[0]
|
let retVal = regs[0]
|
||||||
if tos.isNil:
|
if tos.isNil:
|
||||||
#echo "RET ", retVal.rendertree
|
#echo "RET ", retVal.rendertree
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
move(regs, tos.slots)
|
move(regs, tos.slots)
|
||||||
assert c.code[pc].opcode in {opcIndCall, opcIndCallAsgn}
|
assert c.code[pc].opcode in {opcIndCall, opcIndCallAsgn}
|
||||||
if c.code[pc].opcode == opcIndCallAsgn:
|
if c.code[pc].opcode == opcIndCallAsgn:
|
||||||
|
|
@ -653,7 +653,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcSubu:
|
of opcSubu:
|
||||||
decodeBC(rkInt)
|
decodeBC(rkInt)
|
||||||
regs[ra].intVal = regs[rb].intVal -% regs[rc].intVal
|
regs[ra].intVal = regs[rb].intVal -% regs[rc].intVal
|
||||||
of opcMulu:
|
of opcMulu:
|
||||||
decodeBC(rkInt)
|
decodeBC(rkInt)
|
||||||
regs[ra].intVal = regs[rb].intVal *% regs[rc].intVal
|
regs[ra].intVal = regs[rb].intVal *% regs[rc].intVal
|
||||||
of opcDivu:
|
of opcDivu:
|
||||||
|
|
@ -726,7 +726,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcLeSet:
|
of opcLeSet:
|
||||||
decodeBC(rkInt)
|
decodeBC(rkInt)
|
||||||
regs[ra].intVal = ord(containsSets(regs[rb].node, regs[rc].node))
|
regs[ra].intVal = ord(containsSets(regs[rb].node, regs[rc].node))
|
||||||
of opcEqSet:
|
of opcEqSet:
|
||||||
decodeBC(rkInt)
|
decodeBC(rkInt)
|
||||||
regs[ra].intVal = ord(equalSets(regs[rb].node, regs[rc].node))
|
regs[ra].intVal = ord(equalSets(regs[rb].node, regs[rc].node))
|
||||||
of opcLtSet:
|
of opcLtSet:
|
||||||
|
|
@ -737,9 +737,9 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcMulSet:
|
of opcMulSet:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
createSet(regs[ra])
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
nimsets.intersectSets(regs[rb].node, regs[rc].node).sons)
|
nimsets.intersectSets(regs[rb].node, regs[rc].node).sons)
|
||||||
of opcPlusSet:
|
of opcPlusSet:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
createSet(regs[ra])
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
|
|
@ -753,7 +753,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
createSet(regs[ra])
|
createSet(regs[ra])
|
||||||
move(regs[ra].node.sons,
|
move(regs[ra].node.sons,
|
||||||
nimsets.symdiffSets(regs[rb].node, regs[rc].node).sons)
|
nimsets.symdiffSets(regs[rb].node, regs[rc].node).sons)
|
||||||
of opcConcatStr:
|
of opcConcatStr:
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
createStr regs[ra]
|
createStr regs[ra]
|
||||||
|
|
@ -793,7 +793,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
assert c.code[pc].opcode == opcSubStr
|
assert c.code[pc].opcode == opcSubStr
|
||||||
let rd = c.code[pc].regA
|
let rd = c.code[pc].regA
|
||||||
createStr regs[ra]
|
createStr regs[ra]
|
||||||
regs[ra].node.strVal = substr(regs[rb].node.strVal,
|
regs[ra].node.strVal = substr(regs[rb].node.strVal,
|
||||||
regs[rc].intVal.int, regs[rd].intVal.int)
|
regs[rc].intVal.int, regs[rd].intVal.int)
|
||||||
of opcParseFloat:
|
of opcParseFloat:
|
||||||
decodeBC(rkInt)
|
decodeBC(rkInt)
|
||||||
|
|
@ -896,12 +896,12 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
# we know the next instruction is a 'fjmp':
|
# we know the next instruction is a 'fjmp':
|
||||||
let branch = c.constants[instr.regBx-wordExcess]
|
let branch = c.constants[instr.regBx-wordExcess]
|
||||||
var cond = false
|
var cond = false
|
||||||
for j in countup(0, sonsLen(branch) - 2):
|
for j in countup(0, sonsLen(branch) - 2):
|
||||||
if overlap(regs[ra].regToNode, branch.sons[j]):
|
if overlap(regs[ra].regToNode, branch.sons[j]):
|
||||||
cond = true
|
cond = true
|
||||||
break
|
break
|
||||||
assert c.code[pc+1].opcode == opcFJmp
|
assert c.code[pc+1].opcode == opcFJmp
|
||||||
inc pc
|
inc pc
|
||||||
# we skip this instruction so that the final 'inc(pc)' skips
|
# we skip this instruction so that the final 'inc(pc)' skips
|
||||||
# the following jump
|
# the following jump
|
||||||
if not cond:
|
if not cond:
|
||||||
|
|
@ -1273,7 +1273,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcNSetIntVal:
|
of opcNSetIntVal:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
var dest = regs[ra].node
|
var dest = regs[ra].node
|
||||||
if dest.kind in {nkCharLit..nkInt64Lit} and
|
if dest.kind in {nkCharLit..nkInt64Lit} and
|
||||||
regs[rb].kind in {rkInt}:
|
regs[rb].kind in {rkInt}:
|
||||||
dest.intVal = regs[rb].intVal
|
dest.intVal = regs[rb].intVal
|
||||||
else:
|
else:
|
||||||
|
|
@ -1281,24 +1281,24 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcNSetFloatVal:
|
of opcNSetFloatVal:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
var dest = regs[ra].node
|
var dest = regs[ra].node
|
||||||
if dest.kind in {nkFloatLit..nkFloat64Lit} and
|
if dest.kind in {nkFloatLit..nkFloat64Lit} and
|
||||||
regs[rb].kind in {rkFloat}:
|
regs[rb].kind in {rkFloat}:
|
||||||
dest.floatVal = regs[rb].floatVal
|
dest.floatVal = regs[rb].floatVal
|
||||||
else:
|
else:
|
||||||
stackTrace(c, tos, pc, errFieldXNotFound, "floatVal")
|
stackTrace(c, tos, pc, errFieldXNotFound, "floatVal")
|
||||||
of opcNSetSymbol:
|
of opcNSetSymbol:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
var dest = regs[ra].node
|
var dest = regs[ra].node
|
||||||
if dest.kind == nkSym and regs[rb].node.kind == nkSym:
|
if dest.kind == nkSym and regs[rb].node.kind == nkSym:
|
||||||
dest.sym = regs[rb].node.sym
|
dest.sym = regs[rb].node.sym
|
||||||
else:
|
else:
|
||||||
stackTrace(c, tos, pc, errFieldXNotFound, "symbol")
|
stackTrace(c, tos, pc, errFieldXNotFound, "symbol")
|
||||||
of opcNSetIdent:
|
of opcNSetIdent:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
var dest = regs[ra].node
|
var dest = regs[ra].node
|
||||||
if dest.kind == nkIdent and regs[rb].node.kind == nkIdent:
|
if dest.kind == nkIdent and regs[rb].node.kind == nkIdent:
|
||||||
dest.ident = regs[rb].node.ident
|
dest.ident = regs[rb].node.ident
|
||||||
else:
|
else:
|
||||||
stackTrace(c, tos, pc, errFieldXNotFound, "ident")
|
stackTrace(c, tos, pc, errFieldXNotFound, "ident")
|
||||||
of opcNSetType:
|
of opcNSetType:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
|
|
@ -1309,7 +1309,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
of opcNSetStrVal:
|
of opcNSetStrVal:
|
||||||
decodeB(rkNode)
|
decodeB(rkNode)
|
||||||
var dest = regs[ra].node
|
var dest = regs[ra].node
|
||||||
if dest.kind in {nkStrLit..nkTripleStrLit} and
|
if dest.kind in {nkStrLit..nkTripleStrLit} and
|
||||||
regs[rb].kind in {rkNode}:
|
regs[rb].kind in {rkNode}:
|
||||||
dest.strVal = regs[rb].node.strVal
|
dest.strVal = regs[rb].node.strVal
|
||||||
else:
|
else:
|
||||||
|
|
@ -1436,7 +1436,7 @@ proc evalConstExprAux(module, prc: PSym, n: PNode, mode: TEvalMode): PNode =
|
||||||
#for i in 0 .. <c.prc.maxSlots: tos.slots[i] = newNode(nkEmpty)
|
#for i in 0 .. <c.prc.maxSlots: tos.slots[i] = newNode(nkEmpty)
|
||||||
result = rawExecute(c, start, tos).regToNode
|
result = rawExecute(c, start, tos).regToNode
|
||||||
|
|
||||||
proc evalConstExpr*(module: PSym, e: PNode): PNode =
|
proc evalConstExpr*(module: PSym, e: PNode): PNode =
|
||||||
result = evalConstExprAux(module, nil, e, emConst)
|
result = evalConstExprAux(module, nil, e, emConst)
|
||||||
|
|
||||||
proc evalStaticExpr*(module: PSym, e: PNode, prc: PSym): PNode =
|
proc evalStaticExpr*(module: PSym, e: PNode, prc: PSym): PNode =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue