/// <summary> /// Returns a value for the string literal node. /// </summary> /// <param name="context">Context to evaluate expressions against.</param> /// <param name="evalContext">Current expression evaluation context.</param> /// <returns>Node's value.</returns> protected override object Get(object context, EvaluationContext evalContext) { if (!initialized) { lock (this) { if (!initialized) { AST node = this.getFirstChild(); condition = (BaseNode) node; node = node.getNextSibling(); trueExp = (BaseNode) node; node = node.getNextSibling(); falseExp = (BaseNode) node; initialized = true; } } } if (Convert.ToBoolean(GetValue(condition, context, evalContext))) { return GetValue(trueExp, context, evalContext); } else { return GetValue(falseExp, context, evalContext); } }
protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue) { node.Set(context, evalContext, newValue); }
protected object GetValue(BaseNode node, object context, EvaluationContext evalContext) { return node.Get(context, evalContext); }
/// <summary> /// Evaluates this node, switching local variables map to the ones specified in <paramref name="arguments"/>. /// </summary> protected object GetValueWithArguments(BaseNode node, object context, EvaluationContext evalContext, object[] arguments) { return node.Get(context, evalContext, arguments); }
/// <summary> /// Create a new instance /// </summary> public UnaryOperator(BaseNode operand) { this.addChild(operand); }
private void InitializeLambda() { lock (this) { if (bodyExpression == null) { if (this.getNumberOfChildren() == 1) { argumentNames = new string[0]; bodyExpression = (BaseNode)this.getFirstChild(); } else { AST argsNode = this.getFirstChild(); argumentNames = new string[argsNode.getNumberOfChildren()]; AST argNode = argsNode.getFirstChild(); int i = 0; while (argNode != null) { argumentNames[i++] = argNode.getText(); argNode = argNode.getNextSibling(); } bodyExpression = (BaseNode)argsNode.getNextSibling(); } } } }
/// <summary> /// Create a new instance /// </summary> public OpNOT(BaseNode operand) :base(operand) { }
/// <summary> /// Append an argument node to the list of child nodes /// </summary> /// <param name="argumentNode"></param> public void AddArgument(BaseNode argumentNode) { base.addChild(argumentNode); }
/// <summary> /// Create a new instance /// </summary> public OpAND(BaseNode left, BaseNode right) :base(left, right) { }
/// <summary> /// Create a new instance with the supplied operands /// </summary> /// <param name="left"></param> /// <param name="right"></param> protected BinaryOperator(BaseNode left, BaseNode right) { base.addChild(left); base.addChild(right); }
/// <summary> /// Create a new instance /// </summary> public OpXOR(BaseNode left, BaseNode right) : base(left, right) { }
protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue) { node.Set(context, evalContext, newValue); }
protected object GetValue(BaseNode node, object context, EvaluationContext evalContext) { return node.Get(context, evalContext); }
/// <summary> /// Evaluates this node, switching local variables map to the ones specified in <paramref name="arguments"/>. /// </summary> protected object GetValueWithArguments(BaseNode node, object context, EvaluationContext evalContext, object[] arguments) { return node.Get(context, evalContext, arguments); }
/// <summary> /// Create a new instance with the supplied operands /// </summary> /// <param name="left"></param> /// <param name="right"></param> protected BinaryOperator(BaseNode left, BaseNode right) { base.addChild(left); base.addChild(right); }
/// <summary> /// Create a new instance /// </summary> public UnaryOperator(BaseNode operand) { this.addChild(operand); }
/// <summary> /// Create a new instance /// </summary> public OpNOT(BaseNode operand) : base(operand) { }
/// <summary> /// Create a new instance /// </summary> public OpOR(BaseNode left, BaseNode right) :base(left, right) { }
/// <summary> /// Append an argument node to the list of child nodes /// </summary> /// <param name="argumentNode"></param> public void AddArgument(BaseNode argumentNode) { base.addChild(argumentNode); }