From ccf052fe6ff39c2b7a4e19d05488e9d2c3d1cfcb Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Wed, 12 Feb 2020 08:30:35 -0700 Subject: [PATCH] WIP2 --- compiler/evalffi.nim | 5 ----- compiler/sizealignoffsetimpl.nim | 4 ++-- compiler/vm.nim | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/compiler/evalffi.nim b/compiler/evalffi.nim index 3c47251c1..856410eda 100644 --- a/compiler/evalffi.nim +++ b/compiler/evalffi.nim @@ -130,7 +130,6 @@ template `+!`(x, y: untyped): untyped = proc packSize(conf: ConfigRef, v: PNode, typ: PType): int = ## computes the size of the blob - echo typ.kind case typ.kind of tyPtr, tyRef, tyVar, tyLent: if v.kind in {nkNilLit, nkPtrLit}: @@ -145,13 +144,9 @@ proc packSize(conf: ConfigRef, v: PNode, typ: PType): int = if v.kind in {nkNilLit, nkPtrLit}: result = sizeof(pointer) elif typ.sons.len != 0: - echo v.kind let trange = typ.sons[0].n let ttypenode = typ.sons[1] let anode = trange.sons[1] - echo anode.intVal - echo "adfadf" - echo typ.kind result += (anode.intVal.int + 1) * packSize(conf, ttypenode.n, ttypenode) # for ts in trange.sons: # result += ts.intVal * packSize(conf, typ.sons[1], typ.sons[1].typ) diff --git a/compiler/sizealignoffsetimpl.nim b/compiler/sizealignoffsetimpl.nim index 92cfcb0c3..455bbd3a2 100644 --- a/compiler/sizealignoffsetimpl.nim +++ b/compiler/sizealignoffsetimpl.nim @@ -196,8 +196,8 @@ proc computeUnionObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode; accum: var proc computeSizeAlign(conf: ConfigRef; typ: PType) = ## computes and sets ``size`` and ``align`` members of ``typ`` assert typ != nil - echo "In size align!!" - echo typ.kind + # echo "In size align!!" + # echo typ.kind let hasSize = typ.size != szUncomputedSize let hasAlign = typ.align != szUncomputedSize diff --git a/compiler/vm.nim b/compiler/vm.nim index df646f509..9d4ef298c 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -592,7 +592,17 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = of 1: # PtrLikeKinds case regs[rb].kind of rkNode: - regs[ra].intVal = cast[int](regs[rb].node.intVal) + case regs[rb].node.kind + of nkCharLit..nkUInt64Lit: + regs[ra].intVal = regs[rb].node.intVal + of nkFloatLit..nkFloat128Lit: + regs[ra].intVal = int64(regs[rb].floatVal) + else: + # echo regs[rb].node.kind + # echo regs[rb].node.typ.kind + # for son in regs[rb].node.sons: + # echo son.kind + regs[ra].intVal = cast[int](regs[rb].node.addr) of rkNodeAddr: regs[ra].intVal = cast[int](regs[rb].nodeAddr) else: @@ -609,8 +619,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = of rkNode: if regs[rb].node.typ.kind notin PtrLikeKinds: stackTrace(c, tos, pc, "opcCastIntToPtr: regs[rb].node.typ: " & $regs[rb].node.typ.kind) - echo node2.kind - echo regs[rb].node.kind + # echo node2.kind + # echo regs[rb].node.kind node2.intVal = regs[rb].node.intVal else: stackTrace(c, tos, pc, "opcCastIntToPtr: regs[rb].kind: " & $regs[rb].kind) regs[ra].node = node2