/// <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) { var node = 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); } return GetValue(_falseExp, context, evalContext); }
/// <summary> /// Create a new instance /// </summary> public OpXor(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> /// 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) { }
private void InitializeLambda() { lock (this) { if (_bodyExpression == null) { if (getNumberOfChildren() == 1) { _argumentNames = new string[0]; _bodyExpression = (BaseNode) getFirstChild(); } else { var argsNode = getFirstChild(); _argumentNames = new string[argsNode.getNumberOfChildren()]; var argNode = argsNode.getFirstChild(); var i = 0; while (argNode != null) { _argumentNames[i++] = argNode.getText(); argNode = argNode.getNextSibling(); } _bodyExpression = (BaseNode) argsNode.getNextSibling(); } } } }
/// <summary> /// Create a new instance /// </summary> public UnaryOperator(BaseNode operand) { addChild(operand); }
/// <summary> /// Create a new instance /// </summary> public OpNot(BaseNode operand) : base(operand) { }
protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue) { node.Set(context, evalContext, newValue); }
/// <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); }
protected object GetValue(BaseNode node, object context, EvaluationContext evalContext) { return node.Get(context, evalContext); }