fixes #1323
This commit is contained in:
parent
39ce17a73e
commit
d80d8aa74d
3 changed files with 18 additions and 5 deletions
|
|
@ -1244,12 +1244,15 @@ proc genRdVar(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
|
||||||
# see tests/t99bott for an example that triggers it:
|
# see tests/t99bott for an example that triggers it:
|
||||||
cannotEval(n)
|
cannotEval(n)
|
||||||
|
|
||||||
|
template needsRegLoad(): expr =
|
||||||
|
gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar}))
|
||||||
|
|
||||||
proc genArrAccess2(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
|
proc genArrAccess2(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
|
||||||
flags: TGenFlags) =
|
flags: TGenFlags) =
|
||||||
let a = c.genx(n.sons[0], flags)
|
let a = c.genx(n.sons[0], flags)
|
||||||
let b = c.genIndex(n.sons[1], n.sons[0].typ)
|
let b = c.genIndex(n.sons[1], n.sons[0].typ)
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
if dest < 0: dest = c.getTemp(n.typ)
|
||||||
if gfAddrOf notin flags and fitsRegister(n.typ):
|
if needsRegLoad():
|
||||||
var cc = c.getTemp(n.typ)
|
var cc = c.getTemp(n.typ)
|
||||||
c.gABC(n, opc, cc, a, b)
|
c.gABC(n, opc, cc, a, b)
|
||||||
c.gABC(n, opcNodeToReg, dest, cc)
|
c.gABC(n, opcNodeToReg, dest, cc)
|
||||||
|
|
@ -1265,7 +1268,7 @@ proc genObjAccess(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
|
||||||
let a = c.genx(n.sons[0], flags)
|
let a = c.genx(n.sons[0], flags)
|
||||||
let b = genField(n.sons[1])
|
let b = genField(n.sons[1])
|
||||||
if dest < 0: dest = c.getTemp(n.typ)
|
if dest < 0: dest = c.getTemp(n.typ)
|
||||||
if gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar})):
|
if needsRegLoad():
|
||||||
var cc = c.getTemp(n.typ)
|
var cc = c.getTemp(n.typ)
|
||||||
c.gABC(n, opcLdObj, cc, a, b)
|
c.gABC(n, opcLdObj, cc, a, b)
|
||||||
c.gABC(n, opcNodeToReg, dest, cc)
|
c.gABC(n, opcNodeToReg, dest, cc)
|
||||||
|
|
@ -1700,7 +1703,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 == "get_data":
|
#if s.name.s == "calc":
|
||||||
# echo renderTree(body)
|
# echo renderTree(body)
|
||||||
# c.echoCode(result)
|
# c.echoCode(result)
|
||||||
c.prc = oldPrc
|
c.prc = oldPrc
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ true
|
||||||
true
|
true
|
||||||
nil'''
|
nil'''
|
||||||
|
|
||||||
output: '''test'''
|
output: '''test
|
||||||
|
2'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -78,3 +79,12 @@ macro testnilcheck(): stmt =
|
||||||
discard nilcheck()
|
discard nilcheck()
|
||||||
|
|
||||||
testnilcheck()
|
testnilcheck()
|
||||||
|
|
||||||
|
# bug #1323
|
||||||
|
|
||||||
|
proc calc(): array[1, int] =
|
||||||
|
result[0].inc()
|
||||||
|
result[0].inc()
|
||||||
|
|
||||||
|
const c = calc()
|
||||||
|
echo c[0]
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -7,13 +7,13 @@ version 0.9.6
|
||||||
Concurrency
|
Concurrency
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
- 'gcsafe' inferrence needs to be fixed
|
||||||
- the disjoint checker needs to deal with 'a = spawn f(); g = spawn f()'
|
- the disjoint checker needs to deal with 'a = spawn f(); g = spawn f()'
|
||||||
- implement 'deepCopy' builtin
|
- implement 'deepCopy' builtin
|
||||||
- implement 'foo[1..4] = spawn(f[4..7])'
|
- implement 'foo[1..4] = spawn(f[4..7])'
|
||||||
- support for exception propagation
|
- support for exception propagation
|
||||||
- Minor: The copying of the 'ref Promise' into the thead local storage only
|
- Minor: The copying of the 'ref Promise' into the thead local storage only
|
||||||
happens to work due to the write barrier's implementation
|
happens to work due to the write barrier's implementation
|
||||||
- 'gcsafe' inferrence needs to be fixed
|
|
||||||
- implement lock levels --> first without the more complex race avoidance
|
- implement lock levels --> first without the more complex race avoidance
|
||||||
- document the new 'spawn' and 'parallel' statements
|
- document the new 'spawn' and 'parallel' statements
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue