fixes lots of regressions
This commit is contained in:
parent
43de61f37b
commit
1bdc0d1dd3
5 changed files with 20 additions and 15 deletions
|
|
@ -947,7 +947,7 @@ proc evalTypeTrait*(n: PNode, context: PSym): PNode =
|
||||||
let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc})
|
let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc})
|
||||||
case n.sons[0].sym.name.s.normalize
|
case n.sons[0].sym.name.s.normalize
|
||||||
of "name":
|
of "name":
|
||||||
result = newStrNode(nkStrLit, typ.typeToString(preferName))
|
result = newStrNode(nkStrLit, typ.typeToString(preferExported))
|
||||||
result.typ = newType(tyString, context)
|
result.typ = newType(tyString, context)
|
||||||
result.info = n.info
|
result.info = n.info
|
||||||
else:
|
else:
|
||||||
|
|
@ -1493,20 +1493,21 @@ proc eval*(c: PEvalContext, n: PNode): PNode =
|
||||||
else:
|
else:
|
||||||
stackTrace(c, result, errCannotInterpretNodeX, renderTree(n))
|
stackTrace(c, result, errCannotInterpretNodeX, renderTree(n))
|
||||||
|
|
||||||
proc evalConstExprAux(module: PSym, e: PNode, mode: TEvalMode): PNode =
|
proc evalConstExprAux(module, prc: PSym, e: PNode, mode: TEvalMode): PNode =
|
||||||
var p = newEvalContext(module, mode)
|
var p = newEvalContext(module, mode)
|
||||||
var s = newStackFrame()
|
var s = newStackFrame()
|
||||||
s.call = e
|
s.call = e
|
||||||
|
s.prc = prc
|
||||||
pushStackFrame(p, s)
|
pushStackFrame(p, s)
|
||||||
result = tryEval(p, e)
|
result = tryEval(p, e)
|
||||||
if result != nil and result.kind == nkExceptBranch: result = nil
|
if result != nil and result.kind == nkExceptBranch: result = nil
|
||||||
popStackFrame(p)
|
popStackFrame(p)
|
||||||
|
|
||||||
proc evalConstExpr*(module: PSym, e: PNode): PNode =
|
proc evalConstExpr*(module: PSym, e: PNode): PNode =
|
||||||
result = evalConstExprAux(module, e, emConst)
|
result = evalConstExprAux(module, nil, e, emConst)
|
||||||
|
|
||||||
proc evalStaticExpr*(module: PSym, e: PNode): PNode =
|
proc evalStaticExpr*(module: PSym, e: PNode, prc: PSym): PNode =
|
||||||
result = evalConstExprAux(module, e, emStatic)
|
result = evalConstExprAux(module, prc, e, emStatic)
|
||||||
|
|
||||||
proc setupMacroParam(x: PNode): PNode =
|
proc setupMacroParam(x: PNode): PNode =
|
||||||
result = x
|
result = x
|
||||||
|
|
|
||||||
|
|
@ -590,7 +590,7 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
|
||||||
call.add(a)
|
call.add(a)
|
||||||
#echo "NOW evaluating at compile time: ", call.renderTree
|
#echo "NOW evaluating at compile time: ", call.renderTree
|
||||||
if sfCompileTime in callee.flags:
|
if sfCompileTime in callee.flags:
|
||||||
result = evalStaticExpr(c.module, call)
|
result = evalStaticExpr(c.module, call, c.p.owner)
|
||||||
if result.isNil:
|
if result.isNil:
|
||||||
LocalError(n.info, errCannotInterpretNodeX, renderTree(call))
|
LocalError(n.info, errCannotInterpretNodeX, renderTree(call))
|
||||||
else:
|
else:
|
||||||
|
|
@ -601,9 +601,10 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
|
||||||
|
|
||||||
proc semStaticExpr(c: PContext, n: PNode): PNode =
|
proc semStaticExpr(c: PContext, n: PNode): PNode =
|
||||||
let a = semExpr(c, n.sons[0])
|
let a = semExpr(c, n.sons[0])
|
||||||
result = evalStaticExpr(c.module, a)
|
result = evalStaticExpr(c.module, a, c.p.owner)
|
||||||
if result.isNil:
|
if result.isNil:
|
||||||
LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
|
LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
|
||||||
|
result = emptyNode
|
||||||
|
|
||||||
proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
|
proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
|
||||||
flags: TExprFlags): PNode =
|
flags: TExprFlags): PNode =
|
||||||
|
|
|
||||||
|
|
@ -1139,9 +1139,10 @@ proc semPragmaBlock(c: PContext, n: PNode): PNode =
|
||||||
|
|
||||||
proc semStaticStmt(c: PContext, n: PNode): PNode =
|
proc semStaticStmt(c: PContext, n: PNode): PNode =
|
||||||
let a = semStmt(c, n.sons[0])
|
let a = semStmt(c, n.sons[0])
|
||||||
result = evalStaticExpr(c.module, a)
|
result = evalStaticExpr(c.module, a, c.p.owner)
|
||||||
if result.isNil:
|
if result.isNil:
|
||||||
LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
|
LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
|
||||||
|
result = emptyNode
|
||||||
elif result.kind == nkEmpty:
|
elif result.kind == nkEmpty:
|
||||||
result = newNodeI(nkDiscardStmt, n.info, 1)
|
result = newNodeI(nkDiscardStmt, n.info, 1)
|
||||||
result.sons[0] = emptyNode
|
result.sons[0] = emptyNode
|
||||||
|
|
|
||||||
|
|
@ -702,7 +702,7 @@ proc openTransf(module: PSym, filename: string): PTransf =
|
||||||
result.module = module
|
result.module = module
|
||||||
|
|
||||||
proc transformBody*(module: PSym, n: PNode, prc: PSym): PNode =
|
proc transformBody*(module: PSym, n: PNode, prc: PSym): PNode =
|
||||||
if nfTransf in n.flags or prc.kind in {skTemplate, skMacro}:
|
if nfTransf in n.flags or prc.kind in {skTemplate}:
|
||||||
result = n
|
result = n
|
||||||
else:
|
else:
|
||||||
#when useEffectSystem: trackProc(prc, n)
|
#when useEffectSystem: trackProc(prc, n)
|
||||||
|
|
|
||||||
|
|
@ -1734,6 +1734,8 @@ when isMainModule:
|
||||||
else:
|
else:
|
||||||
doAssert false
|
doAssert false
|
||||||
|
|
||||||
|
block:
|
||||||
|
var matches: array[0..2, string]
|
||||||
if match("abcdefg", peg"c {d} ef {g}", matches, 2):
|
if match("abcdefg", peg"c {d} ef {g}", matches, 2):
|
||||||
doAssert matches[0] == "d"
|
doAssert matches[0] == "d"
|
||||||
doAssert matches[1] == "g"
|
doAssert matches[1] == "g"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue