/** * Helper function for printMe with Declarations * * @param out * @param indent * @param decl */ public void printMe(FileWriter out, int indent, Declaration decl) { if (decl instanceof VarDeclaration) { ((VarDeclaration) decl).printMe(out, indent); } else if (decl instanceof FunDeclaration) { ((FunDeclaration) decl).printMe(out, indent); } }
@Override public Expression interpret(InterState istate, SemanticContext context) { Expression e = EXP_CANT_INTERPRET; VarDeclaration v = declaration.isVarDeclaration(); if (v != null) { Dsymbol s = v.toAlias(context); if (s == v && !v.isStatic() && v.init() != null) { ExpInitializer ie = v.init().isExpInitializer(); if (ie != null) { e = ie.exp.interpret(istate, context); } else if (v.init().isVoidInitializer() != null) { e = null; } } else { boolean condition; if (context.isD2()) { condition = s == v && (v.isConst() || v.isInvariant(context)) && v.init != null; } else { condition = s == v && v.isConst() && v.init() != null; } if (condition) { e = v.init().toExpression(context); if (null == e) { e = EXP_CANT_INTERPRET; } else if (null == e.type) { e.type = v.type; } } else if (declaration.isAttribDeclaration() != null || declaration.isTemplateMixin() != null || declaration.isTupleDeclaration() != null) { // These can be made to work, too lazy now e = EXP_CANT_INTERPRET; } else { // Others should not contain executable code, so are trivial to evaluate e = null; } } } return e; }