diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-12-25 22:29:44 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-12-25 22:29:44 +0200 |
commit | edab4aaad02bf414f7f0c6e3148ade8a7b485c40 (patch) | |
tree | 5239c5f1259440420f0adb71e855bbd578b8dcc8 /compiler/sem.nim | |
parent | 1d02f2ea531ad14f686a75c30af9228ba84fa194 (diff) | |
download | Nim-edab4aaad02bf414f7f0c6e3148ade8a7b485c40.tar.gz |
better integration of tyStatic into typeRel
Diffstat (limited to 'compiler/sem.nim')
-rw-r--r-- | compiler/sem.nim | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim index 3ace623bc..67d400ac5 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -189,6 +189,15 @@ proc evalConstExpr(c: PContext, module: PSym, e: PNode): PNode = proc evalStaticExpr(c: PContext, module: PSym, e: PNode, prc: PSym): PNode = result = evalConstExprAux(c.createEvalContext(emStatic), module, prc, e) +proc tryConstExpr(c: PContext, n: PNode): PNode = + var e = semExprWithType(c, n) + if e == nil: return + result = getConstExpr(c.module, e) + if result == nil: + result = evalConstExpr(c, c.module, e) + if result == nil or result.kind == nkEmpty: + return nil + proc semConstExpr(c: PContext, n: PNode): PNode = var e = semExprWithType(c, n) if e == nil: @@ -282,6 +291,7 @@ proc myOpen(module: PSym): PPassContext = c.semConstExpr = semConstExpr c.semExpr = semExpr c.semTryExpr = tryExpr + c.semTryConstExpr = tryConstExpr c.semOperand = semOperand c.semConstBoolExpr = semConstBoolExpr c.semOverloadedCall = semOverloadedCall |