fixed another vm bug
This commit is contained in:
parent
dc2b21e9b2
commit
befdce51b4
2 changed files with 11 additions and 9 deletions
|
|
@ -328,6 +328,7 @@ proc canonValue*(n: PNode): PNode =
|
||||||
|
|
||||||
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
||||||
result = c.constants.len
|
result = c.constants.len
|
||||||
|
assert(n.kind != nkCall)
|
||||||
c.constants.add n.canonValue
|
c.constants.add n.canonValue
|
||||||
internalAssert result < 0x7fff
|
internalAssert result < 0x7fff
|
||||||
|
|
||||||
|
|
@ -1285,16 +1286,13 @@ proc genVarSection(c: PCtx; n: PNode) =
|
||||||
if s.position == 0:
|
if s.position == 0:
|
||||||
if sfImportc in s.flags: c.importcSym(a.info, s)
|
if sfImportc in s.flags: c.importcSym(a.info, s)
|
||||||
else:
|
else:
|
||||||
let sa = if s.ast.isNil: getNullValue(s.typ, a.info)
|
let sa = getNullValue(s.typ, a.info)
|
||||||
else: canonValue(s.ast)
|
#if s.ast.isNil: getNullValue(s.typ, a.info)
|
||||||
|
#else: canonValue(s.ast)
|
||||||
|
assert sa.kind != nkCall
|
||||||
c.globals.add(sa)
|
c.globals.add(sa)
|
||||||
s.position = c.globals.len
|
s.position = c.globals.len
|
||||||
if a.sons[2].kind == nkEmpty:
|
if a.sons[2].kind != nkEmpty:
|
||||||
when false:
|
|
||||||
withTemp(tmp, s.typ):
|
|
||||||
c.gABx(a, opcLdNull, tmp, c.genType(s.typ))
|
|
||||||
c.gABx(a, whichAsgnOpc(a.sons[0], opcWrGlobal), tmp, s.position)
|
|
||||||
else:
|
|
||||||
let tmp = c.genx(a.sons[0], {gfAddrOf})
|
let tmp = c.genx(a.sons[0], {gfAddrOf})
|
||||||
let val = c.genx(a.sons[2])
|
let val = c.genx(a.sons[2])
|
||||||
c.gABC(a, opcWrDeref, tmp, val)
|
c.gABC(a, opcWrDeref, tmp, val)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ bb
|
||||||
22
|
22
|
||||||
aa
|
aa
|
||||||
bb
|
bb
|
||||||
24'''
|
24
|
||||||
|
2147483647 2147483647'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
const s = @[1,2,3]
|
const s = @[1,2,3]
|
||||||
|
|
@ -76,3 +77,6 @@ const y = fac()
|
||||||
static:
|
static:
|
||||||
echo y
|
echo y
|
||||||
|
|
||||||
|
static:
|
||||||
|
var foo = int32.high
|
||||||
|
echo foo, " ", int32.high
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue