implemented 'static'; macros do not work anymore

This commit is contained in:
Araq 2012-03-15 00:28:28 +01:00
commit 4da067691e
10 changed files with 73 additions and 22 deletions

View file

@ -483,7 +483,7 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
if {sfNoSideEffect, sfCompileTime} * callee.flags != {} and
{sfForward, sfImportc} * callee.flags == {}:
if sfCompileTime notin callee.flags and
optImplicitCompileTime notin gOptions: return
optImplicitStatic notin gOptions: return
if callee.magic notin ctfeWhitelist: return
if callee.kind notin {skProc, skConverter} or callee.isGenericRoutine:
@ -508,6 +508,12 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
#if result != n:
# echo "SUCCESS evaluated at compile time: ", call.renderTree
proc semStaticExpr(c: PContext, n: PNode): PNode =
let a = semExpr(c, n.sons[0])
result = evalStaticExpr(c.module, a)
if result.isNil:
LocalError(n.info, errCannotInterpretNodeX, renderTree(n))
proc semDirectCallAnalyseEffects(c: PContext, n: PNode,
flags: TExprFlags): PNode =
if efWantIterator in flags:
@ -1342,6 +1348,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
result = semTableConstr(c, n)
of nkSymChoice:
GlobalError(n.info, errExprXAmbiguous, renderTree(n, {renderNoComments}))
of nkStaticExpr:
result = semStaticExpr(c, n)
else:
GlobalError(n.info, errInvalidExpressionX,
renderTree(n, {renderNoComments}))