diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-01-27 23:41:45 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-01-27 23:41:45 +0200 |
commit | 81a3585872b1a327b62ba528addbee913d6bbe5a (patch) | |
tree | aff8358bc86704edbd89fd56ec4f7b0cd3583bca /compiler/patterns.nim | |
parent | 67f37264b3f461fe46f5cfea7c35c0a4f709dcb0 (diff) | |
parent | 07585088955c1fe8fb815c40409ed9f5d66fd446 (diff) | |
download | Nim-81a3585872b1a327b62ba528addbee913d6bbe5a.tar.gz |
merged upstream master
Diffstat (limited to 'compiler/patterns.nim')
-rw-r--r-- | compiler/patterns.nim | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/patterns.nim b/compiler/patterns.nim index af259c916..ff7f18ac0 100644 --- a/compiler/patterns.nim +++ b/compiler/patterns.nim @@ -71,8 +71,8 @@ proc inSymChoice(sc, x: PNode): bool = proc checkTypes(c: PPatternContext, p: PSym, n: PNode): bool = # check param constraints first here as this is quite optimized: - if p.typ.constraint != nil: - result = matchNodeKinds(p.typ.constraint, n) + if p.constraint != nil: + result = matchNodeKinds(p.constraint, n) if not result: return if isNil(n.typ): result = p.typ.kind in {tyEmpty, tyStmt} @@ -237,6 +237,15 @@ proc addToArgList(result, n: PNode) = else: for i in 0 .. <n.len: result.add(n.sons[i]) +when false: + proc procPatternMatches*(c: PContext, s: PSym, n: PNode): bool = + ## for AST-based overloading: + var ctx: TPatternContext + ctx.owner = s + ctx.c = c + ctx.formals = sonsLen(s.typ)-1 + result = matches(ctx, s.ast.sons[patternPos], n) + proc applyRule*(c: PContext, s: PSym, n: PNode): PNode = ## returns a tree to semcheck if the rule triggered; nil otherwise var ctx: TPatternContext |