Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of OperatorExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public OperatorExpression(Operator @operator)
 {
     if (@operator == null)
         throw new ArgumentNullException("operator");
     this.Operator = @operator;
     this.operands = new Expression[@operator.Arity];
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a derived instance of OperatorExpression from the given operator.
        /// </summary>
        /// <param name="operator"> The operator to base this expression on. </param>
        /// <returns> A derived OperatorExpression instance. </returns>
        public static OperatorExpression FromOperator(Operator @operator)
        {
            if (@operator == null)
                throw new ArgumentNullException("operator");
            switch (@operator.Type)
            {
                case OperatorType.Grouping:
                    return new GroupingExpression(@operator);

                case OperatorType.FunctionCall:
                    return new FunctionCallExpression(@operator);

                case OperatorType.MemberAccess:
                case OperatorType.Index:
                    return new MemberAccessExpression(@operator);

                case OperatorType.New:
                    return new NewExpression(@operator);

                case OperatorType.PostIncrement:
                case OperatorType.PostDecrement:
                case OperatorType.PreIncrement:
                case OperatorType.PreDecrement:
                case OperatorType.Assignment:
                case OperatorType.CompoundAdd:
                case OperatorType.CompoundBitwiseAnd:
                case OperatorType.CompoundBitwiseOr:
                case OperatorType.CompoundBitwiseXor:
                case OperatorType.CompoundDivide:
                case OperatorType.CompoundLeftShift:
                case OperatorType.CompoundModulo:
                case OperatorType.CompoundMultiply:
                case OperatorType.CompoundSignedRightShift:
                case OperatorType.CompoundSubtract:
                case OperatorType.CompoundUnsignedRightShift:
                    return new AssignmentExpression(@operator);

                case OperatorType.Conditional:
                    return new TernaryExpression(@operator);

                case OperatorType.Comma:
                    return new ListExpression(@operator);
            }
            if (@operator.Arity == 1)
                return new UnaryExpression(@operator);
            if (@operator.Arity == 2)
                return new BinaryExpression(@operator);
            throw new NotImplementedException();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new instance of ListExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public ListExpression(Operator @operator)
     : base(@operator)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of NewExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public NewExpression(Operator @operator)
     : base(@operator)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of UnaryExpression.
 /// </summary>
 /// <param name="operator"> The unary operator to base this expression on. </param>
 public UnaryExpression(Operator @operator)
     : base(@operator)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of AssignmentExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public AssignmentExpression(Operator @operator)
     : base(@operator)
 {
 }
 /// <summary>
 /// Creates a new instance of MemberAccessExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public MemberAccessExpression(Operator @operator)
     : base(@operator)
 {
 }
 /// <summary>
 /// Creates a new instance of BinaryJSExpression.
 /// </summary>
 /// <param name="operator"> The binary operator to base this expression on. </param>
 /// <param name="left"> The operand on the left side of the operator. </param>
 /// <param name="right"> The operand on the right side of the operator. </param>
 public BinaryExpression(Operator @operator, Expression left, Expression right)
     : base(@operator)
 {
     this.Push(left);
     this.Push(right);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a new instance of GroupingJSExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public GroupingExpression(Operator @operator)
     : base(@operator)
 {
 }
 /// <summary>
 /// Creates a new instance of FunctionCallJSExpression.
 /// </summary>
 /// <param name="operator"> The binary operator to base this expression on. </param>
 public FunctionCallExpression(Operator @operator)
     : base(@operator)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new instance of MemberAccessExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public MemberAccessExpression(Operator @operator)
     : base(@operator)
 {
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a new instance of AssignmentExpression.
 /// </summary>
 /// <param name="operator"> The operator to base this expression on. </param>
 public AssignmentExpression(Operator @operator)
     : base(@operator)
 {
 }