예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public OpXor(BaseNode left, BaseNode right)
     : base(left, right)
 {
 }
예제 #3
0
 /// <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);
 }
예제 #4
0
 /// <summary>
 ///     Append an argument node to the list of child nodes
 /// </summary>
 /// <param name="argumentNode"></param>
 public void AddArgument(BaseNode argumentNode)
 {
     base.addChild(argumentNode);
 }
예제 #5
0
 /// <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();
                    }
                }
            }
        }
예제 #7
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public UnaryOperator(BaseNode operand)
 {
     addChild(operand);
 }
예제 #8
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public OpNot(BaseNode operand)
     : base(operand)
 {
 }
예제 #9
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public UnaryOperator(BaseNode operand)
 {
     addChild(operand);
 }
예제 #10
0
 protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue)
 {
     node.Set(context, evalContext, newValue);
 }
예제 #11
0
 /// <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);
 }
예제 #12
0
 protected object GetValue(BaseNode node, object context, EvaluationContext evalContext)
 {
     return node.Get(context, evalContext);
 }
예제 #13
0
 /// <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);
 }