bugfix: stack traces; first class iterators almost working

This commit is contained in:
Araq 2012-11-15 01:27:25 +01:00
commit 814fcb2639
13 changed files with 186 additions and 51 deletions

View file

@ -106,10 +106,17 @@ proc genGotoState(p: BProc, n: PNode) =
var a: TLoc
initLocExpr(p, n.sons[0], a)
lineF(p, cpsStmts, "switch ($1) {$n", [rdLoc(a)])
p.BeforeRetNeeded = true
lineF(p, cpsStmts, "case -1: goto BeforeRet;$n", [])
for i in 0 .. lastOrd(n.sons[0].typ):
lineF(p, cpsStmts, "case $1: goto STATE$1;$n", [toRope(i)])
lineF(p, cpsStmts, "}$n", [])
proc genBreakState(p: BProc, n: PNode) =
var a: TLoc
initLocExpr(p, n.sons[0], a)
lineF(p, cpsStmts, "if (($1) < 0) break;$n", [rdLoc(a)])
proc genSingleVar(p: BProc, a: PNode) =
var v = a.sons[0].sym
if sfCompileTime in v.flags: return
@ -713,7 +720,7 @@ proc genAsmOrEmitStmt(p: BProc, t: PNode): PRope =
app(result, t.sons[i].strVal)
of nkSym:
var sym = t.sons[i].sym
if sym.kind in {skProc, skMethod}:
if sym.kind in {skProc, skIterator, skMethod}:
var a: TLoc
initLocExpr(p, t.sons[i], a)
app(result, rdLoc(a))
@ -884,5 +891,6 @@ proc genStmts(p: BProc, t: PNode) =
of nkParForStmt: genParForStmt(p, t)
of nkState: genState(p, t)
of nkGotoState: genGotoState(p, t)
of nkBreakState: genBreakState(p, t)
else: internalError(t.info, "genStmts(" & $t.kind & ')')