public virtual void Evaluate(SymParserDocumentContext aContext) { IsEvaluated = false; // Evaluate the expression, taking into account the current #define'd // values. Prepares a new document with these expressions evaluated. SymTokenDocument evalDoc = BalancedArguments.ExtractTokensAsDocument(false, true); string expression = evalDoc.ChildrenAsString(false, true); // Get evaluated result from evaluator iEvaluationResult = SymExpressionEvaluator.EvaluateAsBoolean(expression); IsEvaluated = true; }
public override void Evaluate(SymParserDocumentContext aContext) { IsEvaluated = false; if (Type == TType.ETypeIf || Type == TType.ETypeElseIf) { // Evaluate the expression, taking into account the current #define'd // values. Prepares a new document with these expressions evaluated. SymTokenDocument evalDoc = new SymTokenDocument(); EvaluateDefineNodes(BalancedArguments, evalDoc, aContext); string expression = evalDoc.ChildrenAsString(false, true); EvaluationResult = SymExpressionEvaluator.EvaluateAsBoolean(expression); } else if (Type == TType.ETypeIfdef || Type == TType.ETypeIfndef) { // Convert the tree to a flat expression string symbol = BalancedArguments.ChildrenAsString(true, true); // Check if the symbol is defined if (Type == TType.ETypeIfdef) { EvaluationResult = aContext.DefineDirectory.IsDefined(symbol); } else if (Type == TType.ETypeIfndef) { EvaluationResult = !aContext.DefineDirectory.IsDefined(symbol); } } else if (Type == TType.ETypeElse) { // Else statements always evaluate to true. We let the parent // conditional expression node decide whether or not this item should // 'fire' EvaluationResult = true; } IsEvaluated = true; }