teach opcLdObj about nkExprColonExpr
This commit is contained in:
parent
1793a0b5ce
commit
eebe0035b5
3 changed files with 73 additions and 19 deletions
52
tests/static/tstaticparammacro.nim
Normal file
52
tests/static/tstaticparammacro.nim
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
discard """
|
||||
msg: '''letters
|
||||
aa
|
||||
bb
|
||||
numbers
|
||||
11
|
||||
22
|
||||
AST a
|
||||
[(11, 22), (33, 44)]
|
||||
AST b
|
||||
(e: [55, 66], f: [77, 88])
|
||||
55
|
||||
'''
|
||||
"""
|
||||
|
||||
import macros
|
||||
|
||||
type
|
||||
TConfig = tuple
|
||||
letters: seq[string]
|
||||
numbers:seq[int]
|
||||
|
||||
const data: Tconfig = (@["aa", "bb"], @[11, 22])
|
||||
|
||||
macro mymacro(data: static[TConfig]): stmt =
|
||||
echo "letters"
|
||||
for s in items(data.letters):
|
||||
echo s
|
||||
echo "numbers"
|
||||
for n in items(data.numbers):
|
||||
echo n
|
||||
|
||||
mymacro(data)
|
||||
|
||||
type
|
||||
Ta = seq[tuple[c:int, d:int]]
|
||||
Tb = tuple[e:seq[int], f:seq[int]]
|
||||
|
||||
const
|
||||
a : Ta = @[(11, 22), (33, 44)]
|
||||
b : Tb = (@[55,66], @[77, 88])
|
||||
|
||||
macro mA(data: static[Ta]): stmt =
|
||||
echo "AST a \n", repr(data)
|
||||
|
||||
macro mB(data: static[Tb]): stmt =
|
||||
echo "AST b \n", repr(data)
|
||||
echo data.e[0]
|
||||
|
||||
mA(a)
|
||||
mB(b)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue