store full definition AST for consts, fix noRewrite (#20115)
* continue #9582 for consts, close #9331, fix #20114 also move extractPragma to ast to pave the way for things like {.strdefine: "abc".} etc * changelog correctly * fix jsgen * update tgetimpl * fix sighashes * fix #19766, add comment about postfix * fix noRewrite LOL refs #16620 * fix changelog * fix destructors
This commit is contained in:
parent
fdc6b0fb6e
commit
de4b0346bd
26 changed files with 176 additions and 65 deletions
20
tests/trmacros/tnorewrite.nim
Normal file
20
tests/trmacros/tnorewrite.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
block:
|
||||
proc get(x: int): int = x
|
||||
|
||||
template t{get(a)}(a: int): int =
|
||||
{.noRewrite.}:
|
||||
get(a) + 1
|
||||
|
||||
doAssert get(0) == 1
|
||||
|
||||
block:
|
||||
var x: int
|
||||
|
||||
template asgn{a = b}(a: int{lvalue}, b: int) =
|
||||
let newVal = b + 1
|
||||
# ^ this is needed but should it be?
|
||||
{.noRewrite.}:
|
||||
a = newVal
|
||||
|
||||
x = 10
|
||||
doAssert x == 11, $x
|
||||
|
|
@ -33,7 +33,8 @@ block tcse:
|
|||
|
||||
block hoist:
|
||||
template optPeg{peg(pattern)}(pattern: string{lit}): Peg =
|
||||
var gl {.global, gensym.} = peg(pattern)
|
||||
{.noRewrite.}:
|
||||
var gl {.global, gensym.} = peg(pattern)
|
||||
gl
|
||||
doAssert match("(a b c)", peg"'(' @ ')'")
|
||||
doAssert match("W_HI_Le", peg"\y 'while'")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue