fixed opcConv
This commit is contained in:
parent
6e584c42c2
commit
ee74706c3b
4 changed files with 35 additions and 13 deletions
|
|
@ -337,7 +337,10 @@ proc treeToYamlAux(n: PNode, marker: var TIntSet, indent: int,
|
||||||
appf(result, ",$N$1\"floatVal\": $2",
|
appf(result, ",$N$1\"floatVal\": $2",
|
||||||
[istr, toRope(n.floatVal.toStrMaxPrecision)])
|
[istr, toRope(n.floatVal.toStrMaxPrecision)])
|
||||||
of nkStrLit..nkTripleStrLit:
|
of nkStrLit..nkTripleStrLit:
|
||||||
appf(result, ",$N$1\"strVal\": $2", [istr, makeYamlString(n.strVal)])
|
if n.strVal.isNil:
|
||||||
|
appf(result, ",$N$1\"strVal\": null", [istr])
|
||||||
|
else:
|
||||||
|
appf(result, ",$N$1\"strVal\": $2", [istr, makeYamlString(n.strVal)])
|
||||||
of nkSym:
|
of nkSym:
|
||||||
appf(result, ",$N$1\"sym\": $2",
|
appf(result, ",$N$1\"sym\": $2",
|
||||||
[istr, symToYamlAux(n.sym, marker, indent + 2, maxRecDepth)])
|
[istr, symToYamlAux(n.sym, marker, indent + 2, maxRecDepth)])
|
||||||
|
|
@ -407,7 +410,10 @@ proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope =
|
||||||
appf(result, ",$N$1\"floatVal\": $2",
|
appf(result, ",$N$1\"floatVal\": $2",
|
||||||
[istr, toRope(n.floatVal.toStrMaxPrecision)])
|
[istr, toRope(n.floatVal.toStrMaxPrecision)])
|
||||||
of nkStrLit..nkTripleStrLit:
|
of nkStrLit..nkTripleStrLit:
|
||||||
appf(result, ",$N$1\"strVal\": $2", [istr, makeYamlString(n.strVal)])
|
if n.strVal.isNil:
|
||||||
|
appf(result, ",$N$1\"strVal\": null", [istr])
|
||||||
|
else:
|
||||||
|
appf(result, ",$N$1\"strVal\": $2", [istr, makeYamlString(n.strVal)])
|
||||||
of nkSym:
|
of nkSym:
|
||||||
appf(result, ",$N$1\"sym\": $2_$3",
|
appf(result, ",$N$1\"sym\": $2_$3",
|
||||||
[istr, toRope(n.sym.name.s), toRope(n.sym.id)])
|
[istr, toRope(n.sym.name.s), toRope(n.sym.id)])
|
||||||
|
|
|
||||||
|
|
@ -257,11 +257,25 @@ proc opConv*(dest: var TRegister, src: TRegister, desttyp, srctyp: PType): bool
|
||||||
myreset(dest)
|
myreset(dest)
|
||||||
dest.kind = rkStr
|
dest.kind = rkStr
|
||||||
dest.node = newNode(nkStrLit)
|
dest.node = newNode(nkStrLit)
|
||||||
case srctyp.skipTypes(abstractRange).kind
|
let styp = srctyp.skipTypes(abstractRange)
|
||||||
of tyEnum:
|
case styp.kind
|
||||||
dest.node.strVal = "too implement" #ordinalValToString(src)
|
of tyEnum:
|
||||||
of tyInt..tyInt64, tyUInt..tyUInt64:
|
let n = styp.n
|
||||||
|
let x = src.intVal.int
|
||||||
|
if x <% n.len and (let f = n.sons[x].sym; f.position == x):
|
||||||
|
dest.node.strVal = if f.ast.isNil: f.name.s else: f.ast.strVal
|
||||||
|
else:
|
||||||
|
for i in 0.. <n.len:
|
||||||
|
if n.sons[i].kind != nkSym: internalError("opConv for enum")
|
||||||
|
let f = n.sons[i].sym
|
||||||
|
if f.position == x:
|
||||||
|
dest.node.strVal = if f.ast.isNil: f.name.s else: f.ast.strVal
|
||||||
|
return
|
||||||
|
internalError("opConv for enum")
|
||||||
|
of tyInt..tyInt64:
|
||||||
dest.node.strVal = $src.intVal
|
dest.node.strVal = $src.intVal
|
||||||
|
of tyUInt..tyUInt64:
|
||||||
|
dest.node.strVal = $uint64(src.intVal)
|
||||||
of tyBool:
|
of tyBool:
|
||||||
dest.node.strVal = if src.intVal == 0: "false" else: "true"
|
dest.node.strVal = if src.intVal == 0: "false" else: "true"
|
||||||
of tyFloat..tyFloat128:
|
of tyFloat..tyFloat128:
|
||||||
|
|
@ -1007,7 +1021,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TRegister =
|
||||||
else:
|
else:
|
||||||
stackTrace(c, tos, pc, errFieldXNotFound, "ident")
|
stackTrace(c, tos, pc, errFieldXNotFound, "ident")
|
||||||
of opcSetType:
|
of opcSetType:
|
||||||
if regs[ra].kind != rkNode: globalError(c.debug[pc], "cannot set type")
|
if regs[ra].kind != rkNode:
|
||||||
|
internalError(c.debug[pc], "cannot set type")
|
||||||
regs[ra].node.typ = c.types[instr.regBx - wordExcess]
|
regs[ra].node.typ = c.types[instr.regBx - wordExcess]
|
||||||
of opcConv:
|
of opcConv:
|
||||||
let rb = instr.regB
|
let rb = instr.regB
|
||||||
|
|
@ -1023,9 +1038,12 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TRegister =
|
||||||
of opcCast:
|
of opcCast:
|
||||||
let rb = instr.regB
|
let rb = instr.regB
|
||||||
inc pc
|
inc pc
|
||||||
let typ = c.types[c.code[pc].regBx - wordExcess]
|
let desttyp = c.types[c.code[pc].regBx - wordExcess]
|
||||||
|
inc pc
|
||||||
|
let srctyp = c.types[c.code[pc].regBx - wordExcess]
|
||||||
|
|
||||||
when hasFFI:
|
when hasFFI:
|
||||||
let dest = fficast(regs[rb], typ)
|
let dest = fficast(regs[rb], desttyp)
|
||||||
asgnRef(regs[ra], dest)
|
asgnRef(regs[ra], dest)
|
||||||
else:
|
else:
|
||||||
globalError(c.debug[pc], "cannot evaluate cast")
|
globalError(c.debug[pc], "cannot evaluate cast")
|
||||||
|
|
|
||||||
|
|
@ -579,11 +579,10 @@ proc genAddSubInt(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode) =
|
||||||
|
|
||||||
proc genConv(c: PCtx; n, arg: PNode; dest: var TDest; opc=opcConv) =
|
proc genConv(c: PCtx; n, arg: PNode; dest: var TDest; opc=opcConv) =
|
||||||
let tmp = c.genx(arg)
|
let tmp = c.genx(arg)
|
||||||
c.gABx(n, opcSetType, tmp, genType(c, arg.typ))
|
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
if dest < 0: dest = c.getTemp(n.typ)
|
||||||
c.gABC(n, opc, dest, tmp)
|
c.gABC(n, opc, dest, tmp)
|
||||||
c.gABx(n, opc, 0, genType(c, n.typ))
|
c.gABx(n, opc, 0, genType(c, n.typ))
|
||||||
if opc == opcConv: c.gABx(n, opc, 0, genType(c, arg.typ))
|
c.gABx(n, opc, 0, genType(c, arg.typ))
|
||||||
c.freeTemp(tmp)
|
c.freeTemp(tmp)
|
||||||
|
|
||||||
proc genCard(c: PCtx; n: PNode; dest: var TDest) =
|
proc genCard(c: PCtx; n: PNode; dest: var TDest) =
|
||||||
|
|
@ -1504,7 +1503,7 @@ proc genProc(c: PCtx; s: PSym): int =
|
||||||
c.gABC(body, opcEof, eofInstr.regA)
|
c.gABC(body, opcEof, eofInstr.regA)
|
||||||
c.optimizeJumps(result)
|
c.optimizeJumps(result)
|
||||||
s.offset = c.prc.maxSlots
|
s.offset = c.prc.maxSlots
|
||||||
#if s.name.s == "concatStyleInterpolation":
|
#if s.name.s == "traverse":
|
||||||
# c.echoCode(result)
|
# c.echoCode(result)
|
||||||
# echo renderTree(body)
|
# echo renderTree(body)
|
||||||
c.prc = oldPrc
|
c.prc = oldPrc
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -1,7 +1,6 @@
|
||||||
version 0.9.4
|
version 0.9.4
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- make vmgen insert opcNodeToReg, opcRegToNode
|
|
||||||
- fix macros\tstringinterp.nim
|
- fix macros\tstringinterp.nim
|
||||||
- fix GC issues
|
- fix GC issues
|
||||||
- test and fix showoff
|
- test and fix showoff
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue