Remove expr/stmt (#5857)
This commit is contained in:
parent
52ff244d5d
commit
000b8afd26
168 changed files with 497 additions and 529 deletions
|
|
@ -3,7 +3,7 @@ discard """
|
|||
"""
|
||||
|
||||
proc f(x: varargs[string, `$`]) = discard
|
||||
template optF{f(x)}(x: varargs[expr]) =
|
||||
template optF{f(x)}(x: varargs[untyped]) =
|
||||
writeLine(stdout, x)
|
||||
|
||||
f 1, 2, false, 3, "ha"
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ discard """
|
|||
output: "4"
|
||||
"""
|
||||
|
||||
template cse{f(a, a, x)}(a: expr{(nkDotExpr|call|nkBracketExpr)&noSideEffect},
|
||||
f: expr, x: varargs[expr]): expr =
|
||||
template cse{f(a, a, x)}(a: typed{(nkDotExpr|call|nkBracketExpr)&noSideEffect},
|
||||
f: typed, x: varargs[typed]): untyped =
|
||||
let aa = a
|
||||
f(aa, aa, x)+4
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ proc `$`(a: TMat): string = result = $a.dummy
|
|||
proc mat21(): TMat =
|
||||
result.dummy = 21
|
||||
|
||||
macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): expr =
|
||||
macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): untyped =
|
||||
echo treeRepr(a)
|
||||
result = newCall(bindSym"mat21")
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ discard """
|
|||
output: "23"
|
||||
"""
|
||||
|
||||
template optslice{a = b + c}(a: expr{noalias}, b, c: expr): stmt =
|
||||
template optslice{a = b + c}(a: untyped{noalias}, b, c: untyped): typed =
|
||||
a = b
|
||||
inc a, c
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ discard """
|
|||
"""
|
||||
|
||||
# bug #206
|
||||
template optimizeOut{testFunc(a, b)}(a: int, b: int{alias}) : expr = 0
|
||||
template optimizeOut{testFunc(a, b)}(a: int, b: int{alias}): untyped = 0
|
||||
|
||||
proc testFunc(a, b: int): int = result = a + b
|
||||
var testVar = 1
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ discard """
|
|||
|
||||
# test that an endless recursion is avoided:
|
||||
|
||||
template optLen{len(x)}(x: expr): expr = len(x)
|
||||
template optLen{len(x)}(x: typed): int = len(x)
|
||||
|
||||
var s = "lala"
|
||||
echo len(s)
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ true
|
|||
3'''
|
||||
"""
|
||||
|
||||
template arithOps: expr = (`+` | `-` | `*`)
|
||||
template testOr{ (arithOps{f})(a, b) }(a, b, f: expr): expr = f(a+1, b)
|
||||
template arithOps: untyped = (`+` | `-` | `*`)
|
||||
template testOr{ (arithOps{f})(a, b) }(a, b, f: untyped): untyped = f(a+1, b)
|
||||
|
||||
let xx = 10
|
||||
echo 10*xx
|
||||
|
||||
template t{x = (~x){y} and (~x){z}}(x, y, z: bool): stmt =
|
||||
template t{x = (~x){y} and (~x){z}}(x, y, z: bool): typed =
|
||||
x = y
|
||||
if x: x = z
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ a = b and a
|
|||
echo a
|
||||
|
||||
# bug #798
|
||||
template t012{(0|1|2){x}}(x: expr): expr = x+1
|
||||
template t012{(0|1|2){x}}(x: untyped): untyped = x+1
|
||||
let z = 1
|
||||
# outputs 3 thanks to fixpoint iteration:
|
||||
echo z
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ discard """
|
|||
proc p(x, y: int; cond: bool): int =
|
||||
result = if cond: x + y else: x - y
|
||||
|
||||
template optP{p(x, y, true)}(x, y: expr): expr = x - y
|
||||
template optP{p(x, y, false)}(x, y: expr): expr = x + y
|
||||
template optP{p(x, y, true)}(x, y): untyped = x - y
|
||||
template optP{p(x, y, false)}(x, y): untyped = x + y
|
||||
|
||||
echo p(2, 4, true)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ proc `&&`(s: varargs[string]): string =
|
|||
for i in 1..len(s)-1: result.add s[i]
|
||||
inc calls
|
||||
|
||||
template optConc{ `&&` * a }(a: string): expr = &&a
|
||||
template optConc{ `&&` * a }(a: string): string = &&a
|
||||
|
||||
let space = " "
|
||||
echo "my" && (space & "awe" && "some " ) && "concat"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ discard """
|
|||
template optWrite{
|
||||
write(f, x)
|
||||
((write|writeLine){w})(f, y)
|
||||
}(x, y: varargs[expr], f, w: expr) =
|
||||
}(x, y: varargs[untyped], f, w: untyped) =
|
||||
w(f, "|", x, y, "|")
|
||||
|
||||
if true:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue