From 0922f4a512035c3f6b9eb298d05ab9bd6c84d505 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 4 May 2015 00:09:45 +0200 Subject: [PATCH] some attempts at fixing staticT; breaks lots of tests --- compiler/options.nim | 2 +- compiler/semexprs.nim | 14 -------------- compiler/sigmatch.nim | 11 ++++------- compiler/trees.nim | 22 +++++++++++++++++----- web/news.txt | 15 ++++++++++++--- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/compiler/options.nim b/compiler/options.nim index 998ab7781..f697f317e 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -97,7 +97,7 @@ var gOptions*: TOptions = {optObjCheck, optFieldCheck, optRangeCheck, optBoundsCheck, optOverflowCheck, optAssert, optWarns, optHints, optStackTrace, optLineTrace, - optPatterns, optNilCheck} + optPatterns, optNilCheck, optImplicitStatic} gGlobalOptions*: TGlobalOptions = {optThreadAnalysis} gExitcode*: int8 gCmd*: TCommands = cmdNone # the command diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index cd6ba3753..d68d29d4d 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -692,20 +692,6 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode = else: return result result.typ = semfold.getIntervalType(callee.magic, call) - block maybeLabelAsStatic: - # XXX: temporary work-around needed for tlateboundstatic. - # This is certainly not correct, but it will get the job - # done until we have a more robust infrastructure for - # implicit statics. - if n.len > 1: - for i in 1 .. 0: argType.skipTypes({tyTypeDesc, tyFieldAccessor}) @@ -1468,6 +1461,10 @@ proc matchesAux(c: PContext, n, nOrig: PNode, if not n.isLValue: m.state = csNoMatch return + elif formal.typ.kind == tyStatic: + if not n.isStaticT_Expr: + m.state = csNoMatch + return var # iterates over formal parameters diff --git a/compiler/trees.nim b/compiler/trees.nim index 2c631af99..824d777d6 100644 --- a/compiler/trees.nim +++ b/compiler/trees.nim @@ -99,17 +99,14 @@ proc getMagic*(op: PNode): TMagic = else: result = mNone else: result = mNone -proc treeToSym*(t: PNode): PSym = - result = t.sym - proc isConstExpr*(n: PNode): bool = result = (n.kind in - {nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit, + {nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit, nkFloatLit..nkFloat64Lit, nkNilLit}) or (nfAllConst in n.flags) proc isDeepConstExpr*(n: PNode): bool = case n.kind - of nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit, + of nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit, nkFloatLit..nkFloat64Lit, nkNilLit: result = true of nkExprEqExpr, nkExprColonExpr, nkHiddenStdConv, nkHiddenSubConv: @@ -122,6 +119,21 @@ proc isDeepConstExpr*(n: PNode): bool = result = n.typ.isNil or n.typ.skipTypes({tyGenericInst, tyDistinct}).kind != tyObject else: discard +proc isStaticT_Expr*(n: PNode): bool = + case n.kind + of nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit, + nkFloatLit..nkFloat64Lit, nkNilLit: + result = true + of nkExprEqExpr, nkExprColonExpr, nkHiddenStdConv, nkHiddenSubConv: + result = isStaticT_Expr(n.sons[1]) + of nkCurly, nkBracket, nkPar, nkObjConstr, nkClosure: + for i in 0 ..