diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-10-09 21:11:53 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-09 21:12:40 +0200 |
commit | d8746398c43cae51d80b32ac182ab12a64710286 (patch) | |
tree | 7ed752d9613e0180fc3f13c803c6833a4b159435 /compiler | |
parent | c81e9069f201365ea42e3d674f3f18e6f88573df (diff) | |
download | Nim-d8746398c43cae51d80b32ac182ab12a64710286.tar.gz |
allow macros to produce nnkGotoState and nkState
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgstmts.nim | 5 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 2 | ||||
-rw-r--r-- | compiler/semexprs.nim | 4 |
3 files changed, 9 insertions, 2 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index eb32e7dd0..74779f598 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -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", []) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 254b13429..c9705e784 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -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 diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 439f2772a..c336afc89 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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})) |