allow macros to produce nnkGotoState and nkState
This commit is contained in:
parent
c81e9069f2
commit
d8746398c4
3 changed files with 9 additions and 2 deletions
|
|
@ -156,7 +156,10 @@ proc genGotoState(p: BProc, n: PNode) =
|
|||
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):
|
||||
var statesCounter = lastOrd(n.sons[0].typ)
|
||||
if n.len == 2 and n[1].kind == nkIntLit:
|
||||
statesCounter = n[1].intVal
|
||||
for i in 0 .. statesCounter:
|
||||
lineF(p, cpsStmts, "case $1: goto STATE$1;$n", [rope(i)])
|
||||
lineF(p, cpsStmts, "}$n", [])
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ proc mangleParamName(m: BModule; s: PSym): Rope =
|
|||
|
||||
proc mangleLocalName(p: BProc; s: PSym): Rope =
|
||||
assert s.kind in skLocalVars+{skTemp}
|
||||
assert sfGlobal notin s.flags
|
||||
#assert sfGlobal notin s.flags
|
||||
result = s.loc.r
|
||||
if result == nil:
|
||||
var key = s.name.s.mangle
|
||||
|
|
|
|||
|
|
@ -2357,6 +2357,10 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
|||
if not n.sons[0].typ.isEmptyType and not implicitlyDiscardable(n.sons[0]):
|
||||
localError(n.info, errGenerated, "'defer' takes a 'void' expression")
|
||||
#localError(n.info, errGenerated, "'defer' not allowed in this context")
|
||||
of nkGotoState, nkState:
|
||||
if n.len != 1 and n.len != 2: illFormedAst(n)
|
||||
for i in 0 ..< n.len:
|
||||
n.sons[i] = semExpr(c, n.sons[i])
|
||||
else:
|
||||
localError(n.info, errInvalidExpressionX,
|
||||
renderTree(n, {renderNoComments}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue