summary refs log tree commit diff stats
path: root/compiler/sem.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/sem.nim')
-rwxr-xr-xcompiler/sem.nim15
1 files changed, 14 insertions, 1 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index d92c1657d..8d0e4e168 100755
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -15,7 +15,7 @@ import
   magicsys, parser, nversion, nimsets, semfold, importer,
   procfind, lookups, rodread, pragmas, passes, semdata, semtypinst, sigmatch,
   semthreads, intsets, transf, evals, idgen, aliases, cgmeth, lambdalifting,
-  evaltempl
+  evaltempl, patterns
 
 proc semPass*(): TPass
 # implementation
@@ -102,6 +102,19 @@ proc semConstExpr(c: PContext, n: PNode): PNode =
     return n
   result = evalTypedExpr(c, e)
 
+proc applyPatterns(c: PContext, n: PNode): PNode =
+  # fast exit:
+  if c.patterns.len == 0: return n
+  result = n
+  # we apply the last pattern first, so that pattern overriding is possible;
+  # however the resulting AST would better not trigger the old rule then
+  # anymore ;-)
+  for i in countdown(<c.patterns.len, 0):
+    let x = applyRule(c, c.patterns[i], result)
+    if not isNil(x):
+      assert x.kind == nkCall
+      result = semExpr(c, x)
+
 include seminst, semcall
 
 proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode = 
committer Ganesh Viswanathan <dev@genotrance.com> 2018-09-14 18:51:05 -0500 Move' href='/ahoang/Nim/commit/tests/destructor/t6434.nim?h=devel&id=b966945ab219e58023cdf85c77804519c96c231e'>b966945ab ^
962b2e4b3 ^
b966945ab ^
c5358b0d4 ^

b966945ab ^
c5358b0d4 ^
962b2e4b3 ^

c5358b0d4 ^
b966945ab ^
045e026d0 ^
ba4fbb632 ^
c0db1705d ^









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43