C variables are created in their enclosing block instead of their enclosing function
This commit is contained in:
parent
238202ccbc
commit
d2b45dbe85
8 changed files with 180 additions and 151 deletions
|
|
@ -6,6 +6,8 @@
|
|||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
#
|
||||
# included from cgen.nim
|
||||
|
||||
proc leftAppearsOnRightSide(le, ri: PNode): bool =
|
||||
if le != nil:
|
||||
|
|
@ -34,15 +36,15 @@ proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc, pl: PRope) =
|
|||
resetLoc(p, d)
|
||||
app(pl, addrLoc(d))
|
||||
app(pl, ")")
|
||||
app(p.s[cpsStmts], pl)
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
app(p.s(cpsStmts), pl)
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
else:
|
||||
var tmp: TLoc
|
||||
getTemp(p, typ.sons[0], tmp)
|
||||
app(pl, addrLoc(tmp))
|
||||
app(pl, ")")
|
||||
app(p.s[cpsStmts], pl)
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
app(p.s(cpsStmts), pl)
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
genAssignment(p, d, tmp, {}) # no need for deep copying
|
||||
else:
|
||||
app(pl, ")")
|
||||
|
|
@ -54,8 +56,8 @@ proc fixupCall(p: BProc, le, ri: PNode, d: var TLoc, pl: PRope) =
|
|||
genAssignment(p, d, list, {}) # no need for deep copying
|
||||
else:
|
||||
app(pl, ")")
|
||||
app(p.s[cpsStmts], pl)
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
app(p.s(cpsStmts), pl)
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
|
||||
proc isInCurrentFrame(p: BProc, n: PNode): bool =
|
||||
# checks if `n` is an expression that refers to the current frame;
|
||||
|
|
@ -164,7 +166,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
|||
if i < length - 1: app(pl, ", ")
|
||||
|
||||
template genCallPattern =
|
||||
appf(p.s[cpsStmts], CallPattern, op.r, pl, pl.addComma, rawProc)
|
||||
appf(p.s(cpsStmts), CallPattern, op.r, pl, pl.addComma, rawProc)
|
||||
|
||||
let rawProc = getRawProcType(p, typ)
|
||||
if typ.sons[0] != nil:
|
||||
|
|
@ -179,13 +181,13 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
|||
resetLoc(p, d)
|
||||
app(pl, addrLoc(d))
|
||||
genCallPattern()
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
else:
|
||||
var tmp: TLoc
|
||||
getTemp(p, typ.sons[0], tmp)
|
||||
app(pl, addrLoc(tmp))
|
||||
genCallPattern()
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
genAssignment(p, d, tmp, {}) # no need for deep copying
|
||||
else:
|
||||
if d.k == locNone: getTemp(p, typ.sons[0], d)
|
||||
|
|
@ -196,7 +198,7 @@ proc genClosureCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
|||
genAssignment(p, d, list, {}) # no need for deep copying
|
||||
else:
|
||||
genCallPattern()
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
|
||||
proc genInfixCall(p: BProc, le, ri: PNode, d: var TLoc) =
|
||||
var op, a: TLoc
|
||||
|
|
@ -261,15 +263,15 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) =
|
|||
app(pl, "Result: ")
|
||||
app(pl, addrLoc(d))
|
||||
app(pl, "]")
|
||||
app(p.s[cpsStmts], pl)
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
app(p.s(cpsStmts), pl)
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
else:
|
||||
var tmp: TLoc
|
||||
getTemp(p, typ.sons[0], tmp)
|
||||
app(pl, addrLoc(tmp))
|
||||
app(pl, "]")
|
||||
app(p.s[cpsStmts], pl)
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
app(p.s(cpsStmts), pl)
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
genAssignment(p, d, tmp, {}) # no need for deep copying
|
||||
else:
|
||||
app(pl, "]")
|
||||
|
|
@ -281,8 +283,8 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) =
|
|||
genAssignment(p, d, list, {}) # no need for deep copying
|
||||
else:
|
||||
app(pl, "]")
|
||||
app(p.s[cpsStmts], pl)
|
||||
appf(p.s[cpsStmts], ";$n")
|
||||
app(p.s(cpsStmts), pl)
|
||||
appf(p.s(cpsStmts), ";$n")
|
||||
|
||||
proc genCall(p: BProc, e: PNode, d: var TLoc) =
|
||||
if e.sons[0].typ.callConv == ccClosure:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue