Пример #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)
                    {
                        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);
            }
        }
Пример #2
0
 protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue)
 {
     node.Set(context, evalContext, newValue);
 }
Пример #3
0
 protected object GetValue(BaseNode node, object context, EvaluationContext evalContext)
 {
     return node.Get(context, evalContext);
 }
Пример #4
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);
 }
Пример #5
0
 /// <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();
                    }
                }
            }
        }
Пример #7
0
 /// <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);
 }
Пример #9
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public OpAND(BaseNode left, BaseNode right)
     :base(left, right)
 {
 }
Пример #10
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);
 }
Пример #11
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public OpXOR(BaseNode left, BaseNode right)
     : base(left, right)
 {
 }
Пример #12
0
 protected void SetValue(BaseNode node, object context, EvaluationContext evalContext, object newValue)
 {
     node.Set(context, evalContext, newValue);
 }
Пример #13
0
 protected object GetValue(BaseNode node, object context, EvaluationContext evalContext)
 {
     return node.Get(context, evalContext);
 }
Пример #14
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);
 }
 /// <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);
 }
Пример #16
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public UnaryOperator(BaseNode operand)
 {
     this.addChild(operand);
 }
Пример #17
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public OpNOT(BaseNode operand)
     : base(operand)
 {
 }
Пример #18
0
 /// <summary>
 /// Create a new instance
 /// </summary>
 public OpOR(BaseNode left, BaseNode right)
     :base(left, right)
 {
 }
Пример #19
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);
 }