diff options
author | Arne Döring <arne.doering@gmx.net> | 2017-07-25 09:28:23 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-07-25 09:28:23 +0200 |
commit | 000b8afd26fa16684a116d9afe798ea94df9c270 (patch) | |
tree | e5295df748b90c5027e44adfa3a442031534572c /tests/macros | |
parent | 52ff244d5d2775fa4d13f4e2b9a996f411281312 (diff) | |
download | Nim-000b8afd26fa16684a116d9afe798ea94df9c270.tar.gz |
Remove expr/stmt (#5857)
Diffstat (limited to 'tests/macros')
32 files changed, 56 insertions, 68 deletions
diff --git a/tests/macros/tbindsym.nim b/tests/macros/tbindsym.nim index e1e3b5112..6289d3eb2 100644 --- a/tests/macros/tbindsym.nim +++ b/tests/macros/tbindsym.nim @@ -11,7 +11,7 @@ type TTextKind = enum TFoo, TBar -macro test: stmt = +macro test: untyped = var x = @[TFoo, TBar] result = newStmtList() for i in x: diff --git a/tests/macros/tbugs.nim b/tests/macros/tbugs.nim index 1bfce6bc4..990edf1e2 100644 --- a/tests/macros/tbugs.nim +++ b/tests/macros/tbugs.nim @@ -26,7 +26,7 @@ iterator test2(f: string): Foo = for i in f: yield Foo(s: i) -macro test(): stmt = +macro test(): untyped = for i in test2("asdf"): echo i.s @@ -39,7 +39,7 @@ import macros type TType = tuple[s: string] -macro echotest(): stmt = +macro echotest(): untyped = var t: TType t.s = "" t.s.add("test") @@ -61,7 +61,7 @@ proc get_data(d: Td) : string {.compileTime.} = #result.add("aa") # B #result = result & "aa" # C -macro m(s:static[Td]) : stmt = +macro m(s:static[Td]) : untyped = echo get_data(s) echo get_data(s) result = newEmptyNode() @@ -77,7 +77,7 @@ proc nilcheck(): NimNode {.compileTime.} = echo(result.isNil) # true echo(repr(result)) # nil -macro testnilcheck(): stmt = +macro testnilcheck(): untyped = result = newNimNode(nnkStmtList) discard nilcheck() @@ -95,10 +95,10 @@ echo c[0] # bug #3046 -macro sampleMacroInt(i: int): stmt = +macro sampleMacroInt(i: int): untyped = echo i.intVal -macro sampleMacroBool(b: bool): stmt = +macro sampleMacroBool(b: bool): untyped = echo b.boolVal sampleMacroInt(42) diff --git a/tests/macros/tcomplexecho.nim b/tests/macros/tcomplexecho.nim index f7f933c1c..0b70a3ef7 100644 --- a/tests/macros/tcomplexecho.nim +++ b/tests/macros/tcomplexecho.nim @@ -10,7 +10,7 @@ OK import macros # Bug from the forum -macro addEcho1(s: untyped): stmt = +macro addEcho1(s: untyped): untyped = s.body.add(newCall("echo", newStrLitNode("OK"))) result = s @@ -32,7 +32,7 @@ proc foo(): seq[NimNode] {.compiletime.} = result.add test() result.add parseExpr("echo(5+56)") -macro bar(): stmt = +macro bar(): typed = result = newNimNode(nnkStmtList) let x = foo() for xx in x: diff --git a/tests/macros/tdebugstmt.nim b/tests/macros/tdebugstmt.nim index 421f8fd14..740ae7b05 100644 --- a/tests/macros/tdebugstmt.nim +++ b/tests/macros/tdebugstmt.nim @@ -6,7 +6,7 @@ x: some string''' import macros -macro debug(n: varargs[expr]): stmt = +macro debug(n: varargs[untyped]): untyped = # `n` is a Nim AST that contains the whole macro invocation # this macro returns a list of statements: result = newNimNode(nnkStmtList, n) diff --git a/tests/macros/tdumpast2.nim b/tests/macros/tdumpast2.nim index 6b694fa77..c4c591b2a 100644 --- a/tests/macros/tdumpast2.nim +++ b/tests/macros/tdumpast2.nim @@ -21,7 +21,7 @@ proc dumpit(n: NimNode): string {.compileTime.} = add(result, dumpit(n[j])) add(result, ")") -macro dumpAST(n: stmt): stmt {.immediate.} = +macro dumpAST(n): untyped = # dump AST as a side-effect and return the inner node let n = callsite() echo dumpit(n) diff --git a/tests/macros/texprcolonexpr.nim b/tests/macros/texprcolonexpr.nim index 3b2c86b77..59c799771 100644 --- a/tests/macros/texprcolonexpr.nim +++ b/tests/macros/texprcolonexpr.nim @@ -13,7 +13,7 @@ Infix """ import macros -macro def(x: stmt): stmt {.immediate.} = +macro def(x): untyped = echo treeRepr(x) def name(a, b:cint) => nil diff --git a/tests/macros/tgensym.nim b/tests/macros/tgensym.nim index a4d1a3606..955168939 100644 --- a/tests/macros/tgensym.nim +++ b/tests/macros/tgensym.nim @@ -11,7 +11,7 @@ proc convertReturns(node, retFutureSym: NimNode): NimNode {.compileTime.} = for i in 0 .. <node.len: result[i] = convertReturns(node[i], retFutureSym) -macro async2(prc: stmt): stmt {.immediate.} = +macro async2(prc: untyped): untyped = expectKind(prc, nnkProcDef) var outerProcBody = newNimNode(nnkStmtList) diff --git a/tests/macros/tgentemplates.nim b/tests/macros/tgentemplates.nim index 764b94bc7..301d58c6a 100644 --- a/tests/macros/tgentemplates.nim +++ b/tests/macros/tgentemplates.nim @@ -20,7 +20,7 @@ proc parse_template(node: NimNode, value: string) {.compiletime.} = while index < value.len and parse_until_symbol(node, value, index): discard -macro tmpli*(body: expr): stmt = +macro tmpli*(body: untyped): typed = result = newStmtList() result.add parseExpr("result = \"\"") result.parse_template body[1].strVal diff --git a/tests/macros/tgettype.nim b/tests/macros/tgettype.nim index 0eab6c0a0..8b787b022 100644 --- a/tests/macros/tgettype.nim +++ b/tests/macros/tgettype.nim @@ -10,11 +10,11 @@ type name : string password : string -macro testUser: expr = - return newLit(User.getType.lispRepr) +macro testUser: string = + result = newLit(User.getType.lispRepr) -macro testGeneric(T: typedesc[Model]): expr = - return newLit(T.getType.lispRepr) +macro testGeneric(T: typedesc[Model]): string= + result = newLit(T.getType.lispRepr) echo testUser echo User.testGeneric diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim index f89aa5e0b..8e1d9bc13 100644 --- a/tests/macros/tgettypeinst.nim +++ b/tests/macros/tgettypeinst.nim @@ -22,7 +22,7 @@ proc symToIdent(x: NimNode): NimNode = result.add symToIdent(c) # check getTypeInst and getTypeImpl for given symbol x -macro testX(x,inst0: typed; recurse: static[bool]; implX: stmt): typed = +macro testX(x,inst0: typed; recurse: static[bool]; implX: typed): typed = # check that getTypeInst(x) equals inst0 let inst = x.getTypeInst let instr = inst.symToIdent.treeRepr diff --git a/tests/macros/tidgen.nim b/tests/macros/tidgen.nim index 2fe9e0f82..88322b227 100644 --- a/tests/macros/tidgen.nim +++ b/tests/macros/tidgen.nim @@ -8,7 +8,7 @@ import macros var gid {.compileTime.} = 3 -macro genId(): expr = +macro genId(): int = result = newIntLitNode(gid) inc gid diff --git a/tests/macros/tmacro1.nim b/tests/macros/tmacro1.nim index 2dd5c31df..ac6bd02a5 100644 --- a/tests/macros/tmacro1.nim +++ b/tests/macros/tmacro1.nim @@ -2,7 +2,7 @@ import macros from uri import `/` -macro test*(a: stmt): stmt {.immediate.} = +macro test*(a: untyped): untyped = var nodes: tuple[a, b: int] nodes.a = 4 nodes[1] = 45 @@ -20,4 +20,3 @@ macro test*(a: stmt): stmt {.immediate.} = test: "hi" - diff --git a/tests/macros/tmacro2.nim b/tests/macros/tmacro2.nim index 17f312925..72972c0c1 100644 --- a/tests/macros/tmacro2.nim +++ b/tests/macros/tmacro2.nim @@ -12,7 +12,7 @@ proc testBlock(): string {.compileTime.} = echo "outer block" result = "ta-da" -macro mac(n: expr): expr = +macro mac(n: typed): string = let n = callsite() expectKind(n, nnkCall) expectLen(n, 2) diff --git a/tests/macros/tmacro3.nim b/tests/macros/tmacro3.nim index d7421ff7f..a1dc4f371 100644 --- a/tests/macros/tmacro3.nim +++ b/tests/macros/tmacro3.nim @@ -8,7 +8,7 @@ type TA = tuple[a: int] PA = ref TA -macro test*(a: stmt): stmt {.immediate.} = +macro test*(a: untyped): untyped = var val: PA new(val) val.a = 4 @@ -16,7 +16,7 @@ macro test*(a: stmt): stmt {.immediate.} = test: "hi" -macro test2*(a: stmt): stmt {.immediate.} = +macro test2*(a: untyped): untyped = proc testproc(recurse: int) = echo "Thats weird" var o : NimNode = nil @@ -28,4 +28,3 @@ macro test2*(a: stmt): stmt {.immediate.} = test2: "hi" - diff --git a/tests/macros/tmacro4.nim b/tests/macros/tmacro4.nim index fb07941a9..164afaeb7 100644 --- a/tests/macros/tmacro4.nim +++ b/tests/macros/tmacro4.nim @@ -5,7 +5,7 @@ discard """ import macros, strutils -macro test_macro*(s: string, n: stmt): stmt {.immediate.} = +macro test_macro*(s: string, n: untyped): untyped = result = newNimNode(nnkStmtList) var ass : NimNode = newNimNode(nnkAsgn) add(ass, newIdentNode("str")) @@ -16,4 +16,3 @@ when isMainModule: test_macro(str): var i : integer = 123 echo str - diff --git a/tests/macros/tmacro5.nim b/tests/macros/tmacro5.nim index d7a4fe8c8..1c60e1ffd 100644 --- a/tests/macros/tmacro5.nim +++ b/tests/macros/tmacro5.nim @@ -3,7 +3,7 @@ import macros,json var decls{.compileTime.}: seq[NimNode] = @[] var impls{.compileTime.}: seq[NimNode] = @[] -macro importImpl_forward(name, returns): stmt {.immediate.} = +macro importImpl_forward(name, returns: untyped): untyped = result = newNimNode(nnkEmpty) var func_name = newNimNode(nnkAccQuoted) func_name.add newIdentNode("import") @@ -19,7 +19,7 @@ macro importImpl_forward(name, returns): stmt {.immediate.} = res[3].add returns var p1 = newNimNode(nnkIdentDefs) p1.add newIdentNode("dat") - p1.add newIdentNOde("PJsonNode") + p1.add newIdentNOde("JsonNode") p1.add newNimNode(nnkEmpty) res[3].add p1 var p2 = newNimNode(nnkIdentDefs) @@ -38,7 +38,7 @@ macro importImpl_forward(name, returns): stmt {.immediate.} = decls.add res echo(repr(res)) -macro importImpl(name, returns: expr, body: stmt): stmt {.immediate.} = +macro importImpl(name, returns, body: untyped): typed = #var res = getAST(importImpl_forward(name, returns)) discard getAST(importImpl_forward(name, returns)) var res = copyNimTree(decls[decls.high]) @@ -46,7 +46,7 @@ macro importImpl(name, returns: expr, body: stmt): stmt {.immediate.} = echo repr(res) impls.add res -macro okayy:stmt = +macro okayy: typed = result = newNimNode(nnkStmtList) for node in decls: result.add node for node in impls: result.add node diff --git a/tests/macros/tmacro_in_template.nim b/tests/macros/tmacro_in_template.nim index 8f7753cea..9668495df 100644 --- a/tests/macros/tmacro_in_template.nim +++ b/tests/macros/tmacro_in_template.nim @@ -2,8 +2,8 @@ # bug #1944 import macros -template t(e: expr): stmt = - macro m(eNode: expr): stmt = +template t(e: untyped): untyped = + macro m(eNode: untyped): untyped = echo eNode.treeRepr m e diff --git a/tests/macros/tmacroaspragma.nim b/tests/macros/tmacroaspragma.nim index 0e5c352b3..5f06f2425 100644 --- a/tests/macros/tmacroaspragma.nim +++ b/tests/macros/tmacroaspragma.nim @@ -1,8 +1,7 @@ import macros -macro foo(x: stmt): stmt = +macro foo(x: untyped): untyped = echo treerepr(callsite()) result = newNimNode(nnkStmtList) proc zoo() {.foo.} = echo "hi" - diff --git a/tests/macros/tmacros1.nim b/tests/macros/tmacros1.nim index 1a1073a44..9e3ab028b 100644 --- a/tests/macros/tmacros1.nim +++ b/tests/macros/tmacros1.nim @@ -5,7 +5,7 @@ discard """ import macros, strutils -macro outterMacro*(n: stmt): stmt {.immediate.} = +macro outterMacro*(n, blck: untyped): untyped = let n = callsite() var j : string = "hi" proc innerProc(i: int): string = @@ -27,5 +27,3 @@ var str: string outterMacro(str): "hellow" echo str - - diff --git a/tests/macros/tmacrostmt.nim b/tests/macros/tmacrostmt.nim index 23e2f358c..6f648958f 100644 --- a/tests/macros/tmacrostmt.nim +++ b/tests/macros/tmacrostmt.nim @@ -1,5 +1,5 @@ import macros -macro case_token(n: stmt): stmt {.immediate.} = +macro case_token(n: untyped): untyped {.immediate.} = # creates a lexical analyzer from regular expressions # ... (implementation is an exercise for the reader :-) nil @@ -18,7 +18,7 @@ case_token: inc i #bug #488 -macro foo: stmt = +macro foo: typed = var exp = newCall("whatwhat", newIntLitNode(1)) if compiles(getAst(exp)): return exp else: echo "Does not compute!" diff --git a/tests/macros/tmacrotypes.nim b/tests/macros/tmacrotypes.nim index 991668930..e8a68c34d 100644 --- a/tests/macros/tmacrotypes.nim +++ b/tests/macros/tmacrotypes.nim @@ -5,7 +5,7 @@ int''' import macros -macro checkType(ex: stmt; expected: expr): stmt = +macro checkType(ex: typed; expected: string): untyped = var t = ex.getType() echo t diff --git a/tests/macros/tnodecompare.nim b/tests/macros/tnodecompare.nim index b9cf7df48..5ffb495b1 100644 --- a/tests/macros/tnodecompare.nim +++ b/tests/macros/tnodecompare.nim @@ -11,7 +11,7 @@ static: nodeB.strVal = "this is a different comment" doAssert nodeA != nodeB -macro test(a: typed, b: typed): expr = +macro test(a: typed, b: typed): untyped = newLit(a == b) doAssert test(1, 1) == true @@ -29,10 +29,10 @@ var a, b: int doAssert test(a, a) == true doAssert test(a, b) == false -macro test2: expr = +macro test2: untyped = newLit(bindSym"Obj" == bindSym"Obj") -macro test3: expr = +macro test3: untyped = newLit(bindSym"Obj" == bindSym"Other") doAssert test2() == true diff --git a/tests/macros/tquotewords.nim b/tests/macros/tquotewords.nim index 48fcafd62..fa00ba9de 100644 --- a/tests/macros/tquotewords.nim +++ b/tests/macros/tquotewords.nim @@ -6,7 +6,7 @@ discard """ import macros -macro quoteWords(n: varargs[expr]): expr {.immediate.} = +macro quoteWords(n: varargs[untyped]): untyped = let n = callsite() result = newNimNode(nnkBracket, n) for i in 1..n.len-1: @@ -21,6 +21,3 @@ for w in items(myWordList): s.add(w) echo s #OUT thisanexample - - - diff --git a/tests/macros/trecmacro.nim b/tests/macros/trecmacro.nim index 28b6db530..69ebe3da3 100644 --- a/tests/macros/trecmacro.nim +++ b/tests/macros/trecmacro.nim @@ -4,7 +4,7 @@ discard """ errormsg: "recursive dependency: 'dump'" """ -macro dump(n: stmt): stmt = +macro dump(n: untyped): untyped = dump(n) if kind(n) == nnkNone: nil diff --git a/tests/macros/treturnsempty.nim b/tests/macros/treturnsempty.nim index 7af26a747..a5a678af3 100644 --- a/tests/macros/treturnsempty.nim +++ b/tests/macros/treturnsempty.nim @@ -3,10 +3,9 @@ discard """ line: 11 """ # bug #2372 -macro foo(dummy: int): stmt = +macro foo(dummy: int): untyped = discard proc takeStr(s: string) = echo s takeStr foo(12) - diff --git a/tests/macros/tsametype.nim b/tests/macros/tsametype.nim index 34296015f..865fb4cb8 100644 --- a/tests/macros/tsametype.nim +++ b/tests/macros/tsametype.nim @@ -13,7 +13,7 @@ false''' import macros -macro same(a: typedesc, b: typedesc): expr = +macro same(a: typedesc, b: typedesc): untyped = newLit(a.getType[1].sameType b.getType[1]) echo same(int, int) diff --git a/tests/macros/tstaticparamsmacro.nim b/tests/macros/tstaticparamsmacro.nim index f6ecb3a9f..ea59936e0 100644 --- a/tests/macros/tstaticparamsmacro.nim +++ b/tests/macros/tstaticparamsmacro.nim @@ -25,7 +25,7 @@ type const data: Tconfig = (@["aa", "bb"], @[11, 22]) -macro mymacro(data: static[TConfig]): stmt = +macro mymacro(data: static[TConfig]): untyped = echo "letters" for s in items(data.letters): echo s @@ -43,10 +43,10 @@ const a : Ta = @[(11, 22), (33, 44)] b : Tb = (@[55,66], @[77, 88]) -macro mA(data: static[Ta]): stmt = +macro mA(data: static[Ta]): untyped = echo "AST a \n", repr(data) -macro mB(data: static[Tb]): stmt = +macro mB(data: static[Tb]): untyped = echo "AST b \n", repr(data) echo data.e[0] @@ -56,13 +56,13 @@ mB(b) type Foo[N: static[int], Z: static[string]] = object -macro staticIntMacro(f: static[int]): stmt = echo f +macro staticIntMacro(f: static[int]): untyped = echo f staticIntMacro 10 var x: Foo[20, "Test"] -macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12): stmt = +macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12): untyped = echo N, Z genericMacro x diff --git a/tests/macros/tstringinterp.nim b/tests/macros/tstringinterp.nim index bc79cdaba..305f40ac5 100644 --- a/tests/macros/tstringinterp.nim +++ b/tests/macros/tstringinterp.nim @@ -9,7 +9,7 @@ proc concat(strings: varargs[string]): string = result = newString(0) for s in items(strings): result.add(s) -template processInterpolations(e: expr) = +template processInterpolations(e) = var s = e[1].strVal for f in interpolatedFragments(s): case f.kind @@ -17,7 +17,7 @@ template processInterpolations(e: expr) = of ikDollar: addDollar() of ikVar, ikExpr: addExpr(newCall("$", parseExpr(f.value))) -macro formatStyleInterpolation(e: expr): expr = +macro formatStyleInterpolation(e: untyped): untyped = let e = callsite() var formatString = "" @@ -41,7 +41,7 @@ macro formatStyleInterpolation(e: expr): expr = result[1].strVal = formatString result[2] = arrayNode -macro concatStyleInterpolation(e: expr): expr = +macro concatStyleInterpolation(e: untyped): untyped = let e = callsite() var args: seq[NimNode] newSeq(args, 0) @@ -71,4 +71,3 @@ var s2 = formatStyleInterpolation"Hello ${bob}, ${sum(alice.len, bob.len, 2)}$$" write(stdout, s1 & " | " & s2) - diff --git a/tests/macros/ttryparseexpr.nim b/tests/macros/ttryparseexpr.nim index c7bbc8e5b..54442b662 100644 --- a/tests/macros/ttryparseexpr.nim +++ b/tests/macros/ttryparseexpr.nim @@ -5,7 +5,7 @@ discard """ # feature request #1473 import macros -macro test(text: string): expr = +macro test(text: string): untyped = try: result = parseExpr(text.strVal) except ValueError: diff --git a/tests/macros/tvarnimnode.nim b/tests/macros/tvarnimnode.nim index ab0f66caa..26c9b1f1a 100644 --- a/tests/macros/tvarnimnode.nim +++ b/tests/macros/tvarnimnode.nim @@ -10,7 +10,7 @@ proc test(f: var NimNode) {.compileTime.} = f = newNimNode(nnkStmtList) f.add newCall(newIdentNode("echo"), newLit(10)) -macro blah(prc: stmt): stmt = +macro blah(prc: untyped): untyped = result = prc test(result) diff --git a/tests/macros/typesapi.nim b/tests/macros/typesapi.nim index 670b39c9e..cdbfc0ad2 100644 --- a/tests/macros/typesapi.nim +++ b/tests/macros/typesapi.nim @@ -8,7 +8,7 @@ proc (x: int) => typeDesc[proc[void, int]]''' import macros -macro showType(t:stmt): stmt = +macro showType(t:typed): untyped = let ty = t.getType echo t.repr, " => ", ty.repr diff --git a/tests/macros/typesapi2.nim b/tests/macros/typesapi2.nim index 2e59d2154..0130049c0 100644 --- a/tests/macros/typesapi2.nim +++ b/tests/macros/typesapi2.nim @@ -2,7 +2,7 @@ # be used as a type import macros -macro testTypesym (t:stmt): expr = +macro testTypesym (t:typed): untyped = var ty = t.getType if ty.typekind == ntyTypedesc: # skip typedesc get to the real type @@ -31,7 +31,7 @@ static: assert(ref int is testTypesym(ref int)) static: assert(void is testTypesym(void)) -macro tts2 (t:stmt, idx:int): expr = +macro tts2 (t:typed, idx:int): untyped = var ty = t.getType if ty.typekind == ntyTypedesc: # skip typedesc get to the real type @@ -46,4 +46,3 @@ static: assert(tts2(TestFN2, 1) is string) assert(tts2(TestFN2, 2) is int) assert(tts2(TestFN2, 3) is float) - |