Fixes #1093.
This commit is contained in:
parent
36fc1d9d72
commit
57cc8237f7
3 changed files with 26 additions and 10 deletions
|
|
@ -354,6 +354,11 @@ template handleJmpBack() {.dirty.} =
|
||||||
globalError(c.debug[pc], errTooManyIterations)
|
globalError(c.debug[pc], errTooManyIterations)
|
||||||
dec(c.loopIterations)
|
dec(c.loopIterations)
|
||||||
|
|
||||||
|
proc skipColon(n: PNode): PNode =
|
||||||
|
result = n
|
||||||
|
if n.kind == nkExprColonExpr:
|
||||||
|
result = n.sons[1]
|
||||||
|
|
||||||
proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
var pc = start
|
var pc = start
|
||||||
var tos = tos
|
var tos = tos
|
||||||
|
|
@ -454,7 +459,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||||
decodeBC(rkNode)
|
decodeBC(rkNode)
|
||||||
let src = regs[rb].node
|
let src = regs[rb].node
|
||||||
if src.kind notin {nkEmpty..nkNilLit}:
|
if src.kind notin {nkEmpty..nkNilLit}:
|
||||||
let n = src.sons[rc]
|
let n = src.sons[rc].skipColon
|
||||||
regs[ra].node = n
|
regs[ra].node = n
|
||||||
else:
|
else:
|
||||||
stackTrace(c, tos, pc, errNilAccess)
|
stackTrace(c, tos, pc, errNilAccess)
|
||||||
|
|
|
||||||
|
|
@ -316,15 +316,7 @@ proc genAndOr(c: PCtx; n: PNode; opc: TOpcode; dest: var TDest) =
|
||||||
c.patch(L1)
|
c.patch(L1)
|
||||||
|
|
||||||
proc canonValue*(n: PNode): PNode =
|
proc canonValue*(n: PNode): PNode =
|
||||||
if n.kind == nkExprColonExpr:
|
result = n
|
||||||
result = n.sons[1]
|
|
||||||
elif n.hasSubnodeWith(nkExprColonExpr):
|
|
||||||
result = n.copyNode
|
|
||||||
newSeq(result.sons, n.len)
|
|
||||||
for i in 0.. <n.len:
|
|
||||||
result.sons[i] = canonValue(n.sons[i])
|
|
||||||
else:
|
|
||||||
result = n
|
|
||||||
|
|
||||||
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
proc rawGenLiteral(c: PCtx; n: PNode): int =
|
||||||
result = c.constants.len
|
result = c.constants.len
|
||||||
|
|
|
||||||
19
tests/macros/texprcolonexpr.nim
Normal file
19
tests/macros/texprcolonexpr.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
discard """
|
||||||
|
msg: '''
|
||||||
|
Infix
|
||||||
|
Ident !"=>"
|
||||||
|
Call
|
||||||
|
Ident !"name"
|
||||||
|
Ident !"a"
|
||||||
|
ExprColonExpr
|
||||||
|
Ident !"b"
|
||||||
|
Ident !"cint"
|
||||||
|
NilLit nil
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
import macros
|
||||||
|
|
||||||
|
macro def(x: stmt): stmt {.immediate.} =
|
||||||
|
echo treeRepr(x)
|
||||||
|
|
||||||
|
def name(a, b:cint) => nil
|
||||||
Loading…
Add table
Add a link
Reference in a new issue