Beispiel #1
0
        public bool ApplyAssignment(CodeContext codeContext, string leftOfEquals, string rightOfEquals, string newVariableDeclarationType,
                                    AssignmentOperatorType assignmentOperator)
        {
            bool succeeded = false;

            if (newVariableDeclarationType == null && variables.Contains(leftOfEquals))
            {
                // Circular depenency detected!
                AddErrorText("Circular dependency detected on " + leftOfEquals);
            }
            else
            {
                variables.Add(leftOfEquals);

                try
                {
                    AssignValue(newVariableDeclarationType, leftOfEquals, rightOfEquals, codeContext, assignmentOperator);
                    succeeded = true;
                }
                catch (Exception exception)
                {
                    string combined = newVariableDeclarationType + " " + leftOfEquals + " assignment " + rightOfEquals;
                    AddErrorText("Parse error in:  " + combined);
                    mParserLog.AppendLine("Parse error for line " + combined + "\nException:\n" + exception);
                }
                variables.Remove(leftOfEquals);
            }

            return(succeeded);
        }
Beispiel #2
0
 public AssignmentNode(VariableNode p_Assigned, Node p_Value, AssignmentOperatorType p_Op, PositionData p_PositionData)
     : base(NodeType.ASSIGMENT_OP, p_PositionData)
 {
     Assigned = p_Assigned;
     Value    = p_Value;
     Op       = p_Op;
 }
Beispiel #3
0
 public static ExpressionType GetLinqNodeType(AssignmentOperatorType op, bool checkForOverflow)
 {
     Console.WriteLine("GetLinqNodeType:" + op);
     switch (op)
     {
     //            case AssignmentOperatorType.Assign:
     //                return ExpressionType.Assign;
     //            case AssignmentOperatorType.Add:
     //	return checkForOverflow ? ExpressionType.AddAssignChecked : ExpressionType.AddAssign;
     //case AssignmentOperatorType.Subtract:
     //	return checkForOverflow ? ExpressionType.SubtractAssignChecked : ExpressionType.SubtractAssign;
     //case AssignmentOperatorType.Multiply:
     //	return checkForOverflow ? ExpressionType.MultiplyAssignChecked : ExpressionType.MultiplyAssign;
     //case AssignmentOperatorType.Divide:
     //	return ExpressionType.DivideAssign;
     //case AssignmentOperatorType.Modulus:
     //	return ExpressionType.ModuloAssign;
     //case AssignmentOperatorType.ShiftLeft:
     //	return ExpressionType.LeftShiftAssign;
     //case AssignmentOperatorType.ShiftRight:
     //	return ExpressionType.RightShiftAssign;
     //case AssignmentOperatorType.BitwiseAnd:
     //	return ExpressionType.AndAssign;
     //case AssignmentOperatorType.BitwiseOr:
     //	return ExpressionType.OrAssign;
     //case AssignmentOperatorType.ExclusiveOr:
     //	return ExpressionType.ExclusiveOrAssign;
     default:
         throw new NotSupportedException("Invalid value for AssignmentOperatorType");
     }
 }
		void TestAssignmentExpression(string program, AssignmentOperatorType op)
		{
			AssignmentExpression ae = ParseUtilCSharp.ParseExpression<AssignmentExpression>(program);
			
			Assert.AreEqual(op, ae.Operator);
			
			Assert.IsTrue(ae.Left is IdentifierExpression);
			Assert.IsTrue(ae.Right is IdentifierExpression);
		}
        void TestAssignmentExpression(string program, AssignmentOperatorType op)
        {
            AssignmentExpression ae = ParseUtilCSharp.ParseExpression <AssignmentExpression>(program);

            Assert.AreEqual(op, ae.Operator);

            Assert.IsTrue(ae.Left is IdentifierExpression);
            Assert.IsTrue(ae.Right is IdentifierExpression);
        }
        void TestAssignmentExpression(string program, AssignmentOperatorType op)
        {
            ExpressionStatement se = ParseUtil.ParseStatement<ExpressionStatement>(program);
            AssignmentExpression ae = se.Expression as AssignmentExpression;
            Assert.AreEqual(op, ae.Op);

            Assert.IsTrue(ae.Left is IdentifierExpression);
            Assert.IsTrue(ae.Right is IdentifierExpression);
        }
        void VBNetTestAssignmentExpression(string program, AssignmentOperatorType op)
        {
            ExpressionStatement  se = ParseUtilVBNet.ParseStatement <ExpressionStatement>(program);
            AssignmentExpression ae = se.Expression as AssignmentExpression;

            Assert.AreEqual(op, ae.Op);

            Assert.IsTrue(ae.Left is IdentifierExpression);
            Assert.IsTrue(ae.Right is IdentifierExpression);
        }
Beispiel #8
0
        private static ExpressionNode AsOverloadedMethod(ContextNode context, AssignmentOperatorType op, ExpressionNode left, ExpressionNode right, SequencePoint point)
        {
            if (!OperatorMethods.ContainsKey(op))
            {
                return(null);
            }

            string name = OperatorMethods[op];

            return(BinaryOperatorNode.AsOverload(context, name, left, right, point));
        }
Beispiel #9
0
        B.BinaryOperatorType ConvertOperator(AssignmentOperatorType op, out bool isInPlace)
        {
            isInPlace = true;
            switch (op)
            {
            case AssignmentOperatorType.Add:
                return(B.BinaryOperatorType.InPlaceAddition);

            case AssignmentOperatorType.Assign:
                return(B.BinaryOperatorType.Assign);

            case AssignmentOperatorType.BitwiseAnd:
                return(B.BinaryOperatorType.InPlaceBitwiseAnd);

            case AssignmentOperatorType.BitwiseOr:
                return(B.BinaryOperatorType.InPlaceBitwiseOr);

            case AssignmentOperatorType.ConcatString:
                return(B.BinaryOperatorType.InPlaceAddition);

            case AssignmentOperatorType.Divide:
                return(B.BinaryOperatorType.InPlaceDivision);

            case AssignmentOperatorType.DivideInteger:
                return(B.BinaryOperatorType.InPlaceDivision);

            case AssignmentOperatorType.ExclusiveOr:
                return(B.BinaryOperatorType.InPlaceExclusiveOr);

            case AssignmentOperatorType.Modulus:
                isInPlace = false;
                return(B.BinaryOperatorType.Modulus);

            case AssignmentOperatorType.Multiply:
                return(B.BinaryOperatorType.InPlaceMultiply);

            case AssignmentOperatorType.Power:
                isInPlace = false;
                return(B.BinaryOperatorType.Exponentiation);

            case AssignmentOperatorType.ShiftLeft:
                return(B.BinaryOperatorType.InPlaceShiftLeft);

            case AssignmentOperatorType.ShiftRight:
                return(B.BinaryOperatorType.InPlaceShiftRight);

            case AssignmentOperatorType.Subtract:
                return(B.BinaryOperatorType.InPlaceSubtraction);

            default:
                return(B.BinaryOperatorType.None);
            }
        }
Beispiel #10
0
        static IfElseStatement ConvertAssignment(Expression target, AssignmentOperatorType op,
                                                 ConditionalExpression conditionalExpr)
        {
            var trueAssignment = new AssignmentExpression(target.Clone(), op,
                                                          conditionalExpr.TrueExpression.Clone());
            var falseAssignment = new AssignmentExpression(target.Clone(), op,
                                                           conditionalExpr.FalseExpression.Clone());

            return(new IfElseStatement(conditionalExpr.Condition.Clone(),
                                       new ExpressionStatement(trueAssignment),
                                       new ExpressionStatement(falseAssignment)));
        }
Beispiel #11
0
        public static ExpressionNode Create(ContextNode context, AssignmentOperatorType op, ExpressionNode left, ExpressionNode right, SequencePoint point)
        {
            if (!left.IsSettable)
            {
                ErrorCode.NotAnLValue.ReportAndThrow(left.SequencePoint, "Left of assignment operator must be settable");
            }

            if (!right.IsGettable)
            {
                ErrorCode.NotAnRValue.ReportAndThrow(right.SequencePoint, "Right of assignment operator must be gettable");
            }

            var type = left.ExpressionReturnType;

            var overloaded = AsOverloadedMethod(context, op, left, right, point);

            if (overloaded != null)
            {
                return(overloaded);
            }

            if (op != AssignmentOperatorType.Assignment)
            {
                //only transform primitives
                if (!(context.Parser.IsPrimitive(left.ExpressionReturnType) && context.Parser.IsPrimitive(right.ExpressionReturnType)))
                {
                    AssignmentMissmatch(left, right, point);
                }

                if (!left.IsGettable)
                {
                    ErrorCode.NotAnRValue.ReportAndThrow(right.SequencePoint, "Left of this type of assignment operator must be gettable");
                }

                right = BinaryOperatorNode.Create(context, AssignmentToBinary[op], left, right, point);
            }

            if (!right.ExpressionReturnType.IsAssignableTo(left.ExpressionReturnType))
            {
                ErrorCode.TypeMismatch.ReportAndThrow(point,
                                                      "Cannot assign {0} to {1}", right.ExpressionReturnType, left.ExpressionReturnType);
            }

            var instance = new AssignmentOperatorNode(point);

            instance.left  = left;
            instance.right = right;
            instance.type  = left.ExpressionReturnType;

            return(instance);
        }
        private UnifiedBinaryOperator LookupAssignOperator(AssignmentOperatorType type)
        {
            switch (type)
            {
            case AssignmentOperatorType.Assign:
                return(UnifiedBinaryOperator.Create(
                           "=", UnifiedBinaryOperatorKind.Assign));

            case AssignmentOperatorType.Add:
                return(UnifiedBinaryOperator.Create(
                           "+=", UnifiedBinaryOperatorKind.AddAssign));

            case AssignmentOperatorType.Subtract:
                return(UnifiedBinaryOperator.Create(
                           "-=", UnifiedBinaryOperatorKind.SubtractAssign));

            case AssignmentOperatorType.Multiply:
                return(UnifiedBinaryOperator.Create(
                           "*=", UnifiedBinaryOperatorKind.MultiplyAssign));

            case AssignmentOperatorType.Divide:
                return(UnifiedBinaryOperator.Create(
                           "/=", UnifiedBinaryOperatorKind.DivideAssign));

            case AssignmentOperatorType.Modulus:
                return(UnifiedBinaryOperator.Create(
                           "%=", UnifiedBinaryOperatorKind.ModuloAssign));

            case AssignmentOperatorType.ShiftLeft:
                return(UnifiedBinaryOperator.Create(
                           "<<=", UnifiedBinaryOperatorKind.ArithmeticLeftShiftAssign));

            case AssignmentOperatorType.ShiftRight:
                return(UnifiedBinaryOperator.Create(
                           ">>=", UnifiedBinaryOperatorKind.ArithmeticRightShiftAssign));

            case AssignmentOperatorType.BitwiseAnd:
                return(UnifiedBinaryOperator.Create(
                           "&=", UnifiedBinaryOperatorKind.AndAssign));

            case AssignmentOperatorType.BitwiseOr:
                return(UnifiedBinaryOperator.Create(
                           "|=", UnifiedBinaryOperatorKind.OrAssign));

            case AssignmentOperatorType.ExclusiveOr:
                return(UnifiedBinaryOperator.Create(
                           "^=", UnifiedBinaryOperatorKind.ExclusiveOrAssign));
            }
            throw new ArgumentException("Unknown operator: " + type);
        }
Beispiel #13
0
        public static BinaryExpressionOperator BinaryOperator(AssignmentOperatorType op)
        {
            switch (op)
            {
            case AssignmentOperatorType.Add: return(BinaryExpressionOperator.Add);

            case AssignmentOperatorType.Subtract: return(BinaryExpressionOperator.Subtract);

            case AssignmentOperatorType.Multiply: return(BinaryExpressionOperator.Multiply);

            case AssignmentOperatorType.Divide: return(BinaryExpressionOperator.Divide);

            case AssignmentOperatorType.Modulus: return(BinaryExpressionOperator.Modulus);

            default: throw new RedILException($"No equivalent operator for assigment operator '{op}'");
            }
        }
Beispiel #14
0
        private void AssignValue(string newVariableDeclarationType, string leftOfEquals, string rightOfEquals, CodeContext codeContext,
                                 AssignmentOperatorType assignOperator)
        {
            ElementRuntime elementRuntime = codeContext.ContainerInstance as ElementRuntime;
            IElement       element        = null;

            if (elementRuntime != null)
            {
                element = elementRuntime.AssociatedIElement;
            }

            CustomVariable customVariable = CreateCustomVariableFor(newVariableDeclarationType, leftOfEquals, rightOfEquals, elementRuntime, codeContext);

            if (customVariable.Name.CountOf('.') > 1)
            {
                throw new Exception("Script parsing doesn't support setting properties/fields on properties/fields.  In other words, assigning something.X is okay, but not something.Position.x");
            }

            mParserLog.AppendLine("Left side:  " + leftOfEquals + "  RightSide:  " + rightOfEquals + "    Resulting variable:   " + customVariable);

            if (newVariableDeclarationType != null)
            {
                TopOfVariableStack[leftOfEquals] = customVariable.DefaultValue;
                codeContext.VariableStack.Last().Add(leftOfEquals, customVariable.DefaultValue);
            }
            else if (customVariable != null)
            {
                if (codeContext.ContainerInstance != null)
                {
                    ElementRuntime runtime = codeContext.ContainerInstance as ElementRuntime;
                    runtime.SetCustomVariable(customVariable, runtime.AssociatedIElement, customVariable.DefaultValue, true, VariableSettingOptions.LiteralSet);
                }
                else
                {
                    var  reference   = mExpressionParser.EvaluateExpression(leftOfEquals, codeContext, ExpressionParseType.GetReference);
                    bool wasAssigned = false;

                    wasAssigned = TryAssignIAssignableReference(assignOperator, customVariable, reference);

                    if (!wasAssigned)
                    {
                        throw new Exception("Could not assign the value");
                    }
                }
            }
        }
Beispiel #15
0
        public static BinaryOperatorType TypeOfAssignment(AssignmentOperatorType operatorType)
        {
            switch (operatorType)
            {
                case AssignmentOperatorType.Assign:
                    return BinaryOperatorType.Any;

                case AssignmentOperatorType.Add:
                    return BinaryOperatorType.Add;

                case AssignmentOperatorType.Subtract:
                    return BinaryOperatorType.Subtract;

                case AssignmentOperatorType.Multiply:
                    return BinaryOperatorType.Multiply;

                case AssignmentOperatorType.Divide:
                    return BinaryOperatorType.Divide;

                case AssignmentOperatorType.Modulus:
                    return BinaryOperatorType.Modulus;

                case AssignmentOperatorType.ShiftLeft:
                    return BinaryOperatorType.ShiftLeft;

                case AssignmentOperatorType.ShiftRight:
                    return BinaryOperatorType.ShiftRight;

                case AssignmentOperatorType.BitwiseAnd:
                    return BinaryOperatorType.BitwiseAnd;

                case AssignmentOperatorType.BitwiseOr:
                    return BinaryOperatorType.BitwiseOr;

                case AssignmentOperatorType.ExclusiveOr:
                    return BinaryOperatorType.ExclusiveOr;

                case AssignmentOperatorType.Any:
                    return BinaryOperatorType.Any;

                default:
                    throw new ArgumentOutOfRangeException("operatorType", operatorType, null);
            }
        }
Beispiel #16
0
        private static bool TryAssignIAssignableReference(AssignmentOperatorType assignOperator, CustomVariable customVariable, object reference)
        {
            bool wasAssigned = false;

            if (reference is IAssignableReference)
            {
                if (assignOperator == AssignmentOperatorType.Assign)
                {
                    ((IAssignableReference)reference).CurrentValue = customVariable.DefaultValue;
                    wasAssigned = true;
                }
                else if (assignOperator == AssignmentOperatorType.Add)
                {
                    object currentValue = ((IAssignableReference)reference).CurrentValue;
                    object addedResult  = PrimitiveOperationManager.Self.AddObjects(currentValue, customVariable.DefaultValue);
                    ((IAssignableReference)reference).CurrentValue = addedResult;
                    wasAssigned = true;
                }
                else if (assignOperator == AssignmentOperatorType.Subtract)
                {
                    object currentValue = ((IAssignableReference)reference).CurrentValue;
                    object addedResult  = PrimitiveOperationManager.Self.SubtractObjects(currentValue, customVariable.DefaultValue);
                    ((IAssignableReference)reference).CurrentValue = addedResult;
                    wasAssigned = true;
                }
                else if (assignOperator == AssignmentOperatorType.Multiply)
                {
                    object currentValue = ((IAssignableReference)reference).CurrentValue;
                    object addedResult  = PrimitiveOperationManager.Self.MultiplyObjects(currentValue, customVariable.DefaultValue);
                    ((IAssignableReference)reference).CurrentValue = addedResult;
                    wasAssigned = true;
                }
                else if (assignOperator == AssignmentOperatorType.Divide)
                {
                    object currentValue = ((IAssignableReference)reference).CurrentValue;
                    object addedResult  = PrimitiveOperationManager.Self.DivideObjects(currentValue, customVariable.DefaultValue);
                    ((IAssignableReference)reference).CurrentValue = addedResult;
                    wasAssigned = true;
                }
            }
            return(wasAssigned);
        }
Beispiel #17
0
        public static ExpressionType GetLinqNodeType(AssignmentOperatorType op, bool checkForOverflow)
        {
            switch (op)
            {
            case AssignmentOperatorType.Assign:
                return(ExpressionType.Assign);

            case AssignmentOperatorType.Add:
                return(checkForOverflow ? ExpressionType.AddAssignChecked : ExpressionType.AddAssign);

            case AssignmentOperatorType.Subtract:
                return(checkForOverflow ? ExpressionType.SubtractAssignChecked : ExpressionType.SubtractAssign);

            case AssignmentOperatorType.Multiply:
                return(checkForOverflow ? ExpressionType.MultiplyAssignChecked : ExpressionType.MultiplyAssign);

            case AssignmentOperatorType.Divide:
                return(ExpressionType.DivideAssign);

            case AssignmentOperatorType.Modulus:
                return(ExpressionType.ModuloAssign);

            case AssignmentOperatorType.ShiftLeft:
                return(ExpressionType.LeftShiftAssign);

            case AssignmentOperatorType.ShiftRight:
                return(ExpressionType.RightShiftAssign);

            case AssignmentOperatorType.BitwiseAnd:
                return(ExpressionType.AndAssign);

            case AssignmentOperatorType.BitwiseOr:
                return(ExpressionType.OrAssign);

            case AssignmentOperatorType.ExclusiveOr:
                return(ExpressionType.ExclusiveOrAssign);

            default:
                throw new NotSupportedException("Invalid value for AssignmentOperatorType");
            }
        }
Beispiel #18
0
        public static string GetOperatorSymbol(AssignmentOperatorType op)
        {
            switch (op)
            {
            case AssignmentOperatorType.Assign:
                return("=");

            case AssignmentOperatorType.Add:
                return("+=");

            case AssignmentOperatorType.Subtract:
                return("-=");

            case AssignmentOperatorType.Multiply:
                return("*=");

            case AssignmentOperatorType.Divide:
                return("/=");

            case AssignmentOperatorType.Modulus:
                return("%=");

            case AssignmentOperatorType.ShiftLeft:
                return("<<=");

            case AssignmentOperatorType.ShiftRight:
                return(">>=");

            case AssignmentOperatorType.BitwiseAnd:
                return("&=");

            case AssignmentOperatorType.BitwiseOr:
                return("|=");

            case AssignmentOperatorType.ExclusiveOr:
                return("^=");

            default:
                throw new NotSupportedException("Invalid value for AssignmentOperatorType");
            }
        }
Beispiel #19
0
        public static string ToCpp(this AssignmentOperatorType op)
        {
            switch (op)
            {
            case AssignmentOperatorType.Assign:
                return("=");

            case AssignmentOperatorType.Add:
                return("+=");

            case AssignmentOperatorType.BitwiseAnd:
                return("&=");

            case AssignmentOperatorType.BitwiseOr:
                return("|=");

            case AssignmentOperatorType.Divide:
                return("/=");

            case AssignmentOperatorType.ExclusiveOr:
                return("^=");

            case AssignmentOperatorType.Modulus:
                return("%=");

            case AssignmentOperatorType.Multiply:
                return("*=");

            case AssignmentOperatorType.ShiftLeft:
                return("<<=");

            case AssignmentOperatorType.ShiftRight:
                return(">>=");

            case AssignmentOperatorType.Subtract:
                return("+=");

            default:
                throw new Exception($"Unsupported assignment operator: {op}");
            }
        }
Beispiel #20
0
        /// <summary>
        /// Gets the binary operator for the specified compound assignment operator.
        /// Returns null if 'op' is not a compound assignment.
        /// </summary>
        public static BinaryOperatorType?GetCorrespondingBinaryOperator(AssignmentOperatorType op)
        {
            switch (op)
            {
            case AssignmentOperatorType.Assign:
                return(null);

            case AssignmentOperatorType.Add:
                return(BinaryOperatorType.Add);

            case AssignmentOperatorType.Subtract:
                return(BinaryOperatorType.Subtract);

            case AssignmentOperatorType.Multiply:
                return(BinaryOperatorType.Multiply);

            case AssignmentOperatorType.Divide:
                return(BinaryOperatorType.Divide);

            case AssignmentOperatorType.Modulus:
                return(BinaryOperatorType.Modulus);

            case AssignmentOperatorType.ShiftLeft:
                return(BinaryOperatorType.ShiftLeft);

            case AssignmentOperatorType.ShiftRight:
                return(BinaryOperatorType.ShiftRight);

            case AssignmentOperatorType.BitwiseAnd:
                return(BinaryOperatorType.BitwiseAnd);

            case AssignmentOperatorType.BitwiseOr:
                return(BinaryOperatorType.BitwiseOr);

            case AssignmentOperatorType.ExclusiveOr:
                return(BinaryOperatorType.ExclusiveOr);

            default:
                throw new NotSupportedException("Invalid value for AssignmentOperatorType");
            }
        }
Beispiel #21
0
        public static TokenRole GetOperatorRole(AssignmentOperatorType op)
        {
            switch (op)
            {
            case AssignmentOperatorType.Assign:
                return(AssignRole);

            case AssignmentOperatorType.Add:
                return(AddRole);

            case AssignmentOperatorType.Subtract:
                return(SubtractRole);

            case AssignmentOperatorType.Multiply:
                return(MultiplyRole);

            case AssignmentOperatorType.Divide:
                return(DivideRole);

            case AssignmentOperatorType.Modulus:
                return(ModulusRole);

            case AssignmentOperatorType.ShiftLeft:
                return(ShiftLeftRole);

            case AssignmentOperatorType.ShiftRight:
                return(ShiftRightRole);

            case AssignmentOperatorType.BitwiseAnd:
                return(BitwiseAndRole);

            case AssignmentOperatorType.BitwiseOr:
                return(BitwiseOrRole);

            case AssignmentOperatorType.ExclusiveOr:
                return(ExclusiveOrRole);

            default:
                throw new NotSupportedException("Invalid value for AssignmentOperatorType");
            }
        }
Beispiel #22
0
        public static BinaryOperatorType ToBinaryOperator(this AssignmentOperatorType op)
        {
            switch (op)
            {
            case AssignmentOperatorType.Add:
                return(BinaryOperatorType.Add);

            case AssignmentOperatorType.Subtract:
                return(BinaryOperatorType.Subtract);

            case AssignmentOperatorType.Multiply:
                return(BinaryOperatorType.Modulus);

            case AssignmentOperatorType.Divide:
                return(BinaryOperatorType.Divide);

            case AssignmentOperatorType.Modulus:
                return(BinaryOperatorType.Modulus);

            case AssignmentOperatorType.ShiftLeft:
                return(BinaryOperatorType.ShiftLeft);

            case AssignmentOperatorType.ShiftRight:
                return(BinaryOperatorType.ShiftRight);

            case AssignmentOperatorType.BitwiseAnd:
                return(BinaryOperatorType.BitwiseAnd);

            case AssignmentOperatorType.BitwiseOr:
                return(BinaryOperatorType.BitwiseOr);

            case AssignmentOperatorType.ExclusiveOr:
                return(BinaryOperatorType.ExclusiveOr);

            case AssignmentOperatorType.Assign:
            case AssignmentOperatorType.Any:
            default:
                throw new Exception(string.Format("Cannot convert assignment operator {0} to BinaryOperator", op));
            }
        }
Beispiel #23
0
        private static E.BinaryOperator GetOperator(AssignmentOperatorType @operator)
        {
            switch (@operator)
            {
            case AssignmentOperatorType.Add:
                return(E.BinaryOperator.Add);

            case AssignmentOperatorType.Subtract:
                return(E.BinaryOperator.Subtract);

            case AssignmentOperatorType.Multiply:
                // TODO: integer divide
                return(E.BinaryOperator.Multiply);

            case AssignmentOperatorType.Divide:
                return(E.BinaryOperator.Divide);

            case AssignmentOperatorType.Modulus:
                return(E.BinaryOperator.Modulo);

            case AssignmentOperatorType.ShiftLeft:
                return(E.BinaryOperator.LeftShift);

            case AssignmentOperatorType.ShiftRight:
                // TODO: Unsigned
                return(E.BinaryOperator.SignedRightShift);

            case AssignmentOperatorType.BitwiseAnd:
                return(E.BinaryOperator.BitwiseAnd);

            case AssignmentOperatorType.BitwiseOr:
                return(E.BinaryOperator.BitwiseOr);

            case AssignmentOperatorType.ExclusiveOr:
                return(E.BinaryOperator.BitwiseXor);

            default:
                throw GetNotImplementedException();
            }
        }
        private BinaryOperatorType GetComplexAssignOperator(AssignmentOperatorType type)
        {
            switch (type)
            {
            case AssignmentOperatorType.BitwiseOr:
                return(BinaryOperatorType.BitwiseOr);

            case AssignmentOperatorType.BitwiseAnd:
                return(BinaryOperatorType.BitwiseAnd);

            case AssignmentOperatorType.ExclusiveOr:
                return(BinaryOperatorType.ExclusiveOr);

            case AssignmentOperatorType.Add:
                return(BinaryOperatorType.Add);

            case AssignmentOperatorType.Subtract:
                return(BinaryOperatorType.Subtract);

            case AssignmentOperatorType.Divide:
                return(BinaryOperatorType.Divide);

            case AssignmentOperatorType.Modulus:
                return(BinaryOperatorType.Modulus);

            case AssignmentOperatorType.Multiply:
                return(BinaryOperatorType.Multiply);

            case AssignmentOperatorType.ShiftLeft:
                return(BinaryOperatorType.ShiftLeft);

            case AssignmentOperatorType.ShiftRight:
                return(BinaryOperatorType.ShiftRight);

            default:
                throw new ArgumentException();
            }
        }
        static BinaryOperatorType GetAssignmentOperator(AssignmentOperatorType op)
        {
            switch (op)
            {
            case AssignmentOperatorType.BitwiseAnd:
                return(BinaryOperatorType.BitwiseAnd);

            case AssignmentOperatorType.BitwiseOr:
                return(BinaryOperatorType.BitwiseOr);

            case AssignmentOperatorType.ExclusiveOr:
                return(BinaryOperatorType.ExclusiveOr);

            case AssignmentOperatorType.Add:
                return(BinaryOperatorType.Add);

            case AssignmentOperatorType.Subtract:
                return(BinaryOperatorType.Subtract);

            case AssignmentOperatorType.Multiply:
                return(BinaryOperatorType.Multiply);

            case AssignmentOperatorType.Divide:
                return(BinaryOperatorType.Divide);

            case AssignmentOperatorType.Modulus:
                return(BinaryOperatorType.Modulus);

            case AssignmentOperatorType.ShiftLeft:
                return(BinaryOperatorType.ShiftLeft);

            case AssignmentOperatorType.ShiftRight:
                return(BinaryOperatorType.ShiftRight);

            default:
                return(BinaryOperatorType.Any);
            }
        }
 public static AssignmentExpression  assign_To(this Expression left, AssignmentOperatorType assignmentOperator, Expression right)
 {
     return(new AssignmentExpression(left, assignmentOperator, right));
 }
Beispiel #27
0
 private void AssignmentOperator(out AssignmentOperatorType op)
 {
     op = AssignmentOperatorType.None;
     if (this.la.kind == 3)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.Assign;
     }
     else if (this.la.kind == 0x26)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.Add;
     }
     else if (this.la.kind == 0x27)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.Subtract;
     }
     else if (this.la.kind == 40)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.Multiply;
     }
     else if (this.la.kind == 0x29)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.Divide;
     }
     else if (this.la.kind == 0x2a)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.Modulus;
     }
     else if (this.la.kind == 0x2b)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.BitwiseAnd;
     }
     else if (this.la.kind == 0x2c)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.BitwiseOr;
     }
     else if (this.la.kind == 0x2d)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.ExclusiveOr;
     }
     else if (this.la.kind == 0x2e)
     {
         base.lexer.NextToken();
         op = AssignmentOperatorType.ShiftLeft;
     }
     else if ((this.la.kind == 0x16) && (this.Peek(1).kind == 0x23))
     {
         base.Expect(0x16);
         base.Expect(0x23);
         op = AssignmentOperatorType.ShiftRight;
     }
     else
     {
         base.SynErr(0xa9);
     }
 }
Beispiel #28
0
	void AssignmentOperator(
#line  1615 "VBNET.ATG" 
out AssignmentOperatorType op) {

#line  1616 "VBNET.ATG" 
		op = AssignmentOperatorType.None; 
		switch (la.kind) {
		case 10: {
			lexer.NextToken();

#line  1617 "VBNET.ATG" 
			op = AssignmentOperatorType.Assign; 
			break;
		}
		case 42: {
			lexer.NextToken();

#line  1618 "VBNET.ATG" 
			op = AssignmentOperatorType.ConcatString; 
			break;
		}
		case 34: {
			lexer.NextToken();

#line  1619 "VBNET.ATG" 
			op = AssignmentOperatorType.Add; 
			break;
		}
		case 36: {
			lexer.NextToken();

#line  1620 "VBNET.ATG" 
			op = AssignmentOperatorType.Subtract; 
			break;
		}
		case 37: {
			lexer.NextToken();

#line  1621 "VBNET.ATG" 
			op = AssignmentOperatorType.Multiply; 
			break;
		}
		case 38: {
			lexer.NextToken();

#line  1622 "VBNET.ATG" 
			op = AssignmentOperatorType.Divide; 
			break;
		}
		case 39: {
			lexer.NextToken();

#line  1623 "VBNET.ATG" 
			op = AssignmentOperatorType.DivideInteger; 
			break;
		}
		case 35: {
			lexer.NextToken();

#line  1624 "VBNET.ATG" 
			op = AssignmentOperatorType.Power; 
			break;
		}
		case 40: {
			lexer.NextToken();

#line  1625 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
			break;
		}
		case 41: {
			lexer.NextToken();

#line  1626 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
			break;
		}
		default: SynErr(256); break;
		}
	}
Beispiel #29
0
 public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right)
 {
 }
 public AssignmentExpression(Expression left, AssignmentOperatorType type, Expression right)
 {
     AddChild(left, LeftExpressionRole);
     AddChild(right, RightExpressionRole);
     Operator = type;
 }
Beispiel #31
0
	void AssignmentOperator(
#line  1655 "VBNET.ATG" 
out AssignmentOperatorType op) {

#line  1656 "VBNET.ATG" 
		op = AssignmentOperatorType.None; 
		switch (la.kind) {
		case 20: {
			lexer.NextToken();

#line  1657 "VBNET.ATG" 
			op = AssignmentOperatorType.Assign; 
			break;
		}
		case 54: {
			lexer.NextToken();

#line  1658 "VBNET.ATG" 
			op = AssignmentOperatorType.ConcatString; 
			break;
		}
		case 46: {
			lexer.NextToken();

#line  1659 "VBNET.ATG" 
			op = AssignmentOperatorType.Add; 
			break;
		}
		case 48: {
			lexer.NextToken();

#line  1660 "VBNET.ATG" 
			op = AssignmentOperatorType.Subtract; 
			break;
		}
		case 49: {
			lexer.NextToken();

#line  1661 "VBNET.ATG" 
			op = AssignmentOperatorType.Multiply; 
			break;
		}
		case 50: {
			lexer.NextToken();

#line  1662 "VBNET.ATG" 
			op = AssignmentOperatorType.Divide; 
			break;
		}
		case 51: {
			lexer.NextToken();

#line  1663 "VBNET.ATG" 
			op = AssignmentOperatorType.DivideInteger; 
			break;
		}
		case 47: {
			lexer.NextToken();

#line  1664 "VBNET.ATG" 
			op = AssignmentOperatorType.Power; 
			break;
		}
		case 52: {
			lexer.NextToken();

#line  1665 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
			break;
		}
		case 53: {
			lexer.NextToken();

#line  1666 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
			break;
		}
		default: SynErr(277); break;
		}
	}
		B.BinaryOperatorType ConvertOperator(AssignmentOperatorType op, out bool isInPlace)
		{
			isInPlace = true;
			switch (op) {
				case AssignmentOperatorType.Add:
					return B.BinaryOperatorType.InPlaceAddition;
				case AssignmentOperatorType.Assign:
					return B.BinaryOperatorType.Assign;
				case AssignmentOperatorType.BitwiseAnd:
					return B.BinaryOperatorType.InPlaceBitwiseAnd;
				case AssignmentOperatorType.BitwiseOr:
					return B.BinaryOperatorType.InPlaceBitwiseOr;
				case AssignmentOperatorType.ConcatString:
					return B.BinaryOperatorType.InPlaceAddition;
				case AssignmentOperatorType.Divide:
					return B.BinaryOperatorType.InPlaceDivision;
				case AssignmentOperatorType.DivideInteger:
					return B.BinaryOperatorType.InPlaceDivision;
				case AssignmentOperatorType.ExclusiveOr:
					return B.BinaryOperatorType.InPlaceExclusiveOr;
				case AssignmentOperatorType.Modulus:
					isInPlace = false;
					return B.BinaryOperatorType.Modulus;
				case AssignmentOperatorType.Multiply:
					return B.BinaryOperatorType.InPlaceMultiply;
				case AssignmentOperatorType.Power:
					isInPlace = false;
					return B.BinaryOperatorType.Exponentiation;
				case AssignmentOperatorType.ShiftLeft:
					return B.BinaryOperatorType.InPlaceShiftLeft;
				case AssignmentOperatorType.ShiftRight:
					return B.BinaryOperatorType.InPlaceShiftRight;
				case AssignmentOperatorType.Subtract:
					return B.BinaryOperatorType.InPlaceSubtraction;
				default:
					return B.BinaryOperatorType.None;
			}
		}
        public bool ApplyAssignment(CodeContext codeContext, string leftOfEquals, string rightOfEquals, string newVariableDeclarationType,
            AssignmentOperatorType assignmentOperator)
        {
            bool succeeded = false;
            if (newVariableDeclarationType == null && variables.Contains(leftOfEquals))
            {
                // Circular depenency detected!
                AddErrorText("Circular dependency detected on " + leftOfEquals);
            }
            else
            {

                variables.Add(leftOfEquals);

                try
                {
                    AssignValue(newVariableDeclarationType, leftOfEquals, rightOfEquals, codeContext, assignmentOperator);
                    succeeded = true;
                }
                catch (Exception exception)
                {
                    string combined = newVariableDeclarationType + " " + leftOfEquals + " assignment " + rightOfEquals;
                    AddErrorText("Parse error in:  " + combined);
                    mParserLog.AppendLine("Parse error for line " + combined + "\nException:\n" + exception);
                }
                variables.Remove(leftOfEquals);
            }

            return succeeded;
        }
Beispiel #34
0
		public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right) {
			Left = left;
			Op = op;
			Right = right;
		}
        private void AssignValue(string newVariableDeclarationType,  string leftOfEquals, string rightOfEquals, CodeContext codeContext,
            AssignmentOperatorType assignOperator)
        {
            ElementRuntime elementRuntime = codeContext.ContainerInstance as ElementRuntime;
            IElement element = null;

            if (elementRuntime != null)
            {
                element = elementRuntime.AssociatedIElement;
            }

            CustomVariable customVariable = CreateCustomVariableFor(newVariableDeclarationType, leftOfEquals, rightOfEquals, elementRuntime, codeContext);

            if (customVariable.Name.CountOf('.') > 1)
            {
                throw new Exception("Script parsing doesn't support setting properties/fields on properties/fields.  In other words, assigning something.X is okay, but not something.Position.x");
            }

            mParserLog.AppendLine("Left side:  " + leftOfEquals + "  RightSide:  " + rightOfEquals + "    Resulting variable:   " + customVariable);

            if (newVariableDeclarationType != null)
            {
                TopOfVariableStack[leftOfEquals] = customVariable.DefaultValue;
                codeContext.VariableStack.Last().Add(leftOfEquals, customVariable.DefaultValue);
            }
            else if (customVariable != null)
            {
                if (codeContext.ContainerInstance != null)
                {
                    ElementRuntime runtime = codeContext.ContainerInstance as ElementRuntime;
                    runtime.SetCustomVariable(customVariable, runtime.AssociatedIElement, customVariable.DefaultValue, true, VariableSettingOptions.LiteralSet );
                }
                else
                {
                    var reference = mExpressionParser.EvaluateExpression(leftOfEquals, codeContext, ExpressionParseType.GetReference);
                    bool wasAssigned = false;

                    wasAssigned = TryAssignIAssignableReference(assignOperator, customVariable, reference);

                    if (!wasAssigned)
                    {
                        throw new Exception("Could not assign the value");
                    }
                }
            }
        }
Beispiel #36
0
        private BinaryOperatorType GetComplexAssignOperator(AssignmentOperatorType type)
        {
            switch (type)
            {
                case AssignmentOperatorType.BitwiseOr:
                    return BinaryOperatorType.BitwiseOr;
                case AssignmentOperatorType.BitwiseAnd:
                    return BinaryOperatorType.BitwiseAnd;
                case AssignmentOperatorType.ExclusiveOr:
                    return BinaryOperatorType.ExclusiveOr;
                case AssignmentOperatorType.Add:
                    return BinaryOperatorType.Add;
                case AssignmentOperatorType.Subtract:
                    return BinaryOperatorType.Subtract;
                case AssignmentOperatorType.Divide:
                    return BinaryOperatorType.Divide;
                case AssignmentOperatorType.Modulus:
                    return BinaryOperatorType.Modulus;
                case AssignmentOperatorType.Multiply:
                    return BinaryOperatorType.Multiply;
                case AssignmentOperatorType.ShiftLeft:
                    return BinaryOperatorType.ShiftLeft;
                case AssignmentOperatorType.ShiftRight:
                    return BinaryOperatorType.ShiftRight;

                default:
                    throw new ArgumentException();
            }
        }
 private static bool TryAssignIAssignableReference(AssignmentOperatorType assignOperator, CustomVariable customVariable, object reference)
 {
     bool wasAssigned = false;
     if (reference is IAssignableReference)
     {
         if (assignOperator == AssignmentOperatorType.Assign)
         {
             ((IAssignableReference)reference).CurrentValue = customVariable.DefaultValue;
             wasAssigned = true;
         }
         else if (assignOperator == AssignmentOperatorType.Add)
         {
             object currentValue = ((IAssignableReference)reference).CurrentValue;
             object addedResult = PrimitiveOperationManager.Self.AddObjects(currentValue, customVariable.DefaultValue);
             ((IAssignableReference)reference).CurrentValue = addedResult;
             wasAssigned = true;
         }
         else if (assignOperator == AssignmentOperatorType.Subtract)
         {
             object currentValue = ((IAssignableReference)reference).CurrentValue;
             object addedResult = PrimitiveOperationManager.Self.SubtractObjects(currentValue, customVariable.DefaultValue);
             ((IAssignableReference)reference).CurrentValue = addedResult;
             wasAssigned = true;
         }
         else if (assignOperator == AssignmentOperatorType.Multiply)
         {
             object currentValue = ((IAssignableReference)reference).CurrentValue;
             object addedResult = PrimitiveOperationManager.Self.MultiplyObjects(currentValue, customVariable.DefaultValue);
             ((IAssignableReference)reference).CurrentValue = addedResult;
             wasAssigned = true;
         }
         else if (assignOperator == AssignmentOperatorType.Divide)
         {
             object currentValue = ((IAssignableReference)reference).CurrentValue;
             object addedResult = PrimitiveOperationManager.Self.DivideObjects(currentValue, customVariable.DefaultValue);
             ((IAssignableReference)reference).CurrentValue = addedResult;
             wasAssigned = true;
         }
     }
     return wasAssigned;
 }
Beispiel #38
0
	void AssignmentOperator(
//#line  1410 "cs.ATG" 
out AssignmentOperatorType op) {

//#line  1411 "cs.ATG" 
		op = AssignmentOperatorType.None; 
		if (la.kind == 3) {
			lexer.NextToken();

//#line  1413 "cs.ATG" 
			op = AssignmentOperatorType.Assign; 
		} else if (la.kind == 38) {
			lexer.NextToken();

//#line  1414 "cs.ATG" 
			op = AssignmentOperatorType.Add; 
		} else if (la.kind == 39) {
			lexer.NextToken();

//#line  1415 "cs.ATG" 
			op = AssignmentOperatorType.Subtract; 
		} else if (la.kind == 40) {
			lexer.NextToken();

//#line  1416 "cs.ATG" 
			op = AssignmentOperatorType.Multiply; 
		} else if (la.kind == 41) {
			lexer.NextToken();

//#line  1417 "cs.ATG" 
			op = AssignmentOperatorType.Divide; 
		} else if (la.kind == 42) {
			lexer.NextToken();

//#line  1418 "cs.ATG" 
			op = AssignmentOperatorType.Modulus; 
		} else if (la.kind == 43) {
			lexer.NextToken();

//#line  1419 "cs.ATG" 
			op = AssignmentOperatorType.BitwiseAnd; 
		} else if (la.kind == 44) {
			lexer.NextToken();

//#line  1420 "cs.ATG" 
			op = AssignmentOperatorType.BitwiseOr; 
		} else if (la.kind == 45) {
			lexer.NextToken();

//#line  1421 "cs.ATG" 
			op = AssignmentOperatorType.ExclusiveOr; 
		} else if (la.kind == 46) {
			lexer.NextToken();

//#line  1422 "cs.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
		} else if (
//#line  1423 "cs.ATG" 
la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) {
			Expect(22);
			Expect(35);

//#line  1424 "cs.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
		} else SynErr(193);
	}
        static IfElseStatement ConvertAssignment(Expression target, AssignmentOperatorType op,
												  ConditionalExpression conditionalExpr)
        {
            var trueAssignment = new AssignmentExpression (target.Clone (), op,
                                                           conditionalExpr.TrueExpression.Clone ());
            var falseAssignment = new AssignmentExpression (target.Clone (), op,
                                                            conditionalExpr.FalseExpression.Clone ());
            return new IfElseStatement (conditionalExpr.Condition.Clone (),
                                        new ExpressionStatement (trueAssignment),
                                        new ExpressionStatement (falseAssignment));
        }
Beispiel #40
0
		public ResolveResult ResolveAssignment(AssignmentOperatorType op, ResolveResult lhs, ResolveResult rhs)
		{
			var linqOp = AssignmentExpression.GetLinqNodeType(op, this.CheckForOverflow);
			var bop = AssignmentExpression.GetCorrespondingBinaryOperator(op);
			if (bop == null) {
				return new OperatorResolveResult(lhs.Type, linqOp, lhs, this.Convert(rhs, lhs.Type));
			}
			ResolveResult bopResult = ResolveBinaryOperator(bop.Value, lhs, rhs);
			OperatorResolveResult opResult = bopResult as OperatorResolveResult;
			if (opResult == null || opResult.Operands.Count != 2)
				return bopResult;
			return new OperatorResolveResult(lhs.Type, linqOp, opResult.UserDefinedOperatorMethod, opResult.IsLiftedOperator,
			                                 new [] { lhs, opResult.Operands[1] });
		}
Beispiel #41
0
 public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right)
 {
     this.Left     = left;
     this.Operator = op;
     this.Right    = right;
 }
Beispiel #42
0
	void AssignmentOperator(
#line  1569 "VBNET.ATG" 
out AssignmentOperatorType op) {

#line  1570 "VBNET.ATG" 
		op = AssignmentOperatorType.None; 
		switch (la.kind) {
		case 11: {
			lexer.NextToken();

#line  1571 "VBNET.ATG" 
			op = AssignmentOperatorType.Assign; 
			break;
		}
		case 41: {
			lexer.NextToken();

#line  1572 "VBNET.ATG" 
			op = AssignmentOperatorType.ConcatString; 
			break;
		}
		case 33: {
			lexer.NextToken();

#line  1573 "VBNET.ATG" 
			op = AssignmentOperatorType.Add; 
			break;
		}
		case 35: {
			lexer.NextToken();

#line  1574 "VBNET.ATG" 
			op = AssignmentOperatorType.Subtract; 
			break;
		}
		case 36: {
			lexer.NextToken();

#line  1575 "VBNET.ATG" 
			op = AssignmentOperatorType.Multiply; 
			break;
		}
		case 37: {
			lexer.NextToken();

#line  1576 "VBNET.ATG" 
			op = AssignmentOperatorType.Divide; 
			break;
		}
		case 38: {
			lexer.NextToken();

#line  1577 "VBNET.ATG" 
			op = AssignmentOperatorType.DivideInteger; 
			break;
		}
		case 34: {
			lexer.NextToken();

#line  1578 "VBNET.ATG" 
			op = AssignmentOperatorType.Power; 
			break;
		}
		case 39: {
			lexer.NextToken();

#line  1579 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
			break;
		}
		case 40: {
			lexer.NextToken();

#line  1580 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
			break;
		}
		default: SynErr(239); break;
		}
	}
 Expression ConvertAssignmentOperator(InvocationExpression invocation, AssignmentOperatorType op, bool? isChecked = null)
 {
     return NotSupported(invocation);
 }
Beispiel #44
0
	void AssignmentOperator(
#line  1430 "cs.ATG" 
out AssignmentOperatorType op) {

#line  1431 "cs.ATG" 
		op = AssignmentOperatorType.None; 
		if (la.kind == 3) {
			lexer.NextToken();

#line  1433 "cs.ATG" 
			op = AssignmentOperatorType.Assign; 
		} else if (la.kind == 38) {
			lexer.NextToken();

#line  1434 "cs.ATG" 
			op = AssignmentOperatorType.Add; 
		} else if (la.kind == 39) {
			lexer.NextToken();

#line  1435 "cs.ATG" 
			op = AssignmentOperatorType.Subtract; 
		} else if (la.kind == 40) {
			lexer.NextToken();

#line  1436 "cs.ATG" 
			op = AssignmentOperatorType.Multiply; 
		} else if (la.kind == 41) {
			lexer.NextToken();

#line  1437 "cs.ATG" 
			op = AssignmentOperatorType.Divide; 
		} else if (la.kind == 42) {
			lexer.NextToken();

#line  1438 "cs.ATG" 
			op = AssignmentOperatorType.Modulus; 
		} else if (la.kind == 43) {
			lexer.NextToken();

#line  1439 "cs.ATG" 
			op = AssignmentOperatorType.BitwiseAnd; 
		} else if (la.kind == 44) {
			lexer.NextToken();

#line  1440 "cs.ATG" 
			op = AssignmentOperatorType.BitwiseOr; 
		} else if (la.kind == 45) {
			lexer.NextToken();

#line  1441 "cs.ATG" 
			op = AssignmentOperatorType.ExclusiveOr; 
		} else if (la.kind == 46) {
			lexer.NextToken();

#line  1442 "cs.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
		} else if (
#line  1443 "cs.ATG" 
la.kind == Tokens.GreaterThan && Peek(1).kind == Tokens.GreaterEqual) {
			Expect(22);
			Expect(35);

#line  1444 "cs.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
		} else SynErr(195);
	}
Beispiel #45
0
        public static BinaryOperatorType TypeOfAssignment(AssignmentOperatorType operatorType)
        {
            switch (operatorType)
            {
                case AssignmentOperatorType.Assign:
                    return BinaryOperatorType.Any;

                case AssignmentOperatorType.Add:
                    return BinaryOperatorType.Add;

                case AssignmentOperatorType.Subtract:
                    return BinaryOperatorType.Subtract;

                case AssignmentOperatorType.Multiply:
                    return BinaryOperatorType.Multiply;

                case AssignmentOperatorType.Divide:
                    return BinaryOperatorType.Divide;

                case AssignmentOperatorType.Modulus:
                    return BinaryOperatorType.Modulus;

                case AssignmentOperatorType.ShiftLeft:
                    return BinaryOperatorType.ShiftLeft;

                case AssignmentOperatorType.ShiftRight:
                    return BinaryOperatorType.ShiftRight;

                case AssignmentOperatorType.BitwiseAnd:
                    return BinaryOperatorType.BitwiseAnd;

                case AssignmentOperatorType.BitwiseOr:
                    return BinaryOperatorType.BitwiseOr;

                case AssignmentOperatorType.ExclusiveOr:
                    return BinaryOperatorType.ExclusiveOr;

                case AssignmentOperatorType.Any:
                    return BinaryOperatorType.Any;

                default:
                    throw new ArgumentOutOfRangeException("operatorType", operatorType, null);
            }
        }
Beispiel #46
0
 Expression ConvertAssignmentOperator(InvocationExpression invocation, AssignmentOperatorType op, bool?isChecked = null)
 {
     return(NotSupported(invocation));
 }
			static bool IsBitwiseOperator (AssignmentOperatorType op)
			{
				return op == AssignmentOperatorType.BitwiseAnd || op == AssignmentOperatorType.BitwiseOr ||
					op == AssignmentOperatorType.ExclusiveOr;
			}
 public static AssignmentExpression assign_To(this Expression left, AssignmentOperatorType assignmentOperator, Expression right)
 {
     return new AssignmentExpression(left, assignmentOperator, right);
 }
	void AssignmentOperator(
#line  1478 "VBNET.ATG" 
out AssignmentOperatorType op) {

#line  1479 "VBNET.ATG" 
		op = AssignmentOperatorType.None; 
		switch (la.kind) {
		case 11: {
			lexer.NextToken();

#line  1480 "VBNET.ATG" 
			op = AssignmentOperatorType.Assign; 
			break;
		}
		case 42: {
			lexer.NextToken();

#line  1481 "VBNET.ATG" 
			op = AssignmentOperatorType.ConcatString; 
			break;
		}
		case 34: {
			lexer.NextToken();

#line  1482 "VBNET.ATG" 
			op = AssignmentOperatorType.Add; 
			break;
		}
		case 36: {
			lexer.NextToken();

#line  1483 "VBNET.ATG" 
			op = AssignmentOperatorType.Subtract; 
			break;
		}
		case 37: {
			lexer.NextToken();

#line  1484 "VBNET.ATG" 
			op = AssignmentOperatorType.Multiply; 
			break;
		}
		case 38: {
			lexer.NextToken();

#line  1485 "VBNET.ATG" 
			op = AssignmentOperatorType.Divide; 
			break;
		}
		case 39: {
			lexer.NextToken();

#line  1486 "VBNET.ATG" 
			op = AssignmentOperatorType.DivideInteger; 
			break;
		}
		case 35: {
			lexer.NextToken();

#line  1487 "VBNET.ATG" 
			op = AssignmentOperatorType.Power; 
			break;
		}
		case 40: {
			lexer.NextToken();

#line  1488 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
			break;
		}
		case 41: {
			lexer.NextToken();

#line  1489 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
			break;
		}
		default: SynErr(216); break;
		}
	}
	void AssignmentOperator(
#line  1487 "cs.ATG" 
out AssignmentOperatorType op) {

#line  1488 "cs.ATG" 
		op = AssignmentOperatorType.None; 
		switch (la.kind) {
		case 3: {
			lexer.NextToken();

#line  1490 "cs.ATG" 
			op = AssignmentOperatorType.Assign; 
			break;
		}
		case 37: {
			lexer.NextToken();

#line  1491 "cs.ATG" 
			op = AssignmentOperatorType.Add; 
			break;
		}
		case 38: {
			lexer.NextToken();

#line  1492 "cs.ATG" 
			op = AssignmentOperatorType.Subtract; 
			break;
		}
		case 39: {
			lexer.NextToken();

#line  1493 "cs.ATG" 
			op = AssignmentOperatorType.Multiply; 
			break;
		}
		case 40: {
			lexer.NextToken();

#line  1494 "cs.ATG" 
			op = AssignmentOperatorType.Divide; 
			break;
		}
		case 41: {
			lexer.NextToken();

#line  1495 "cs.ATG" 
			op = AssignmentOperatorType.Modulus; 
			break;
		}
		case 42: {
			lexer.NextToken();

#line  1496 "cs.ATG" 
			op = AssignmentOperatorType.BitwiseAnd; 
			break;
		}
		case 43: {
			lexer.NextToken();

#line  1497 "cs.ATG" 
			op = AssignmentOperatorType.BitwiseOr; 
			break;
		}
		case 44: {
			lexer.NextToken();

#line  1498 "cs.ATG" 
			op = AssignmentOperatorType.ExclusiveOr; 
			break;
		}
		case 45: {
			lexer.NextToken();

#line  1499 "cs.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
			break;
		}
		case 46: {
			lexer.NextToken();

#line  1500 "cs.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
			break;
		}
		default: SynErr(167); break;
		}
	}
Beispiel #51
0
 public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right)
 {
 }
Beispiel #52
0
 static bool IsBitwiseOperator(AssignmentOperatorType op)
 {
     return(op == AssignmentOperatorType.BitwiseAnd || op == AssignmentOperatorType.BitwiseOr ||
            op == AssignmentOperatorType.ExclusiveOr);
 }
 public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right)
 {
     this.left  = left;
     this.op    = op;
     this.right = right;
 }
Beispiel #54
0
	void AssignmentOperator(
//#line  1678 "VBNET.ATG" 
out AssignmentOperatorType op) {

//#line  1679 "VBNET.ATG" 
		op = AssignmentOperatorType.None; 
		switch (la.kind) {
		case 20: {
			lexer.NextToken();

//#line  1680 "VBNET.ATG" 
			op = AssignmentOperatorType.Assign; 
			break;
		}
		case 54: {
			lexer.NextToken();

//#line  1681 "VBNET.ATG" 
			op = AssignmentOperatorType.ConcatString; 
			break;
		}
		case 46: {
			lexer.NextToken();

//#line  1682 "VBNET.ATG" 
			op = AssignmentOperatorType.Add; 
			break;
		}
		case 48: {
			lexer.NextToken();

//#line  1683 "VBNET.ATG" 
			op = AssignmentOperatorType.Subtract; 
			break;
		}
		case 49: {
			lexer.NextToken();

//#line  1684 "VBNET.ATG" 
			op = AssignmentOperatorType.Multiply; 
			break;
		}
		case 50: {
			lexer.NextToken();

//#line  1685 "VBNET.ATG" 
			op = AssignmentOperatorType.Divide; 
			break;
		}
		case 51: {
			lexer.NextToken();

//#line  1686 "VBNET.ATG" 
			op = AssignmentOperatorType.DivideInteger; 
			break;
		}
		case 47: {
			lexer.NextToken();

//#line  1687 "VBNET.ATG" 
			op = AssignmentOperatorType.Power; 
			break;
		}
		case 52: {
			lexer.NextToken();

//#line  1688 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftLeft; 
			break;
		}
		case 53: {
			lexer.NextToken();

//#line  1689 "VBNET.ATG" 
			op = AssignmentOperatorType.ShiftRight; 
			break;
		}
		default: SynErr(277); break;
		}
	}
Beispiel #55
0
	void AssignmentOperator(out AssignmentOperatorType op) {
		op = AssignmentOperatorType.None;
		switch (la.kind) {
		case 20: {
			Get();
			op = AssignmentOperatorType.Assign;
			break;
		}
		case 54: {
			Get();
			op = AssignmentOperatorType.ConcatString;
			break;
		}
		case 46: {
			Get();
			op = AssignmentOperatorType.Add;
			break;
		}
		case 48: {
			Get();
			op = AssignmentOperatorType.Subtract;
			break;
		}
		case 49: {
			Get();
			op = AssignmentOperatorType.Multiply;
			break;
		}
		case 50: {
			Get();
			op = AssignmentOperatorType.Divide;
			break;
		}
		case 51: {
			Get();
			op = AssignmentOperatorType.DivideInteger;
			break;
		}
		case 47: {
			Get();
			op = AssignmentOperatorType.Power;
			break;
		}
		case 52: {
			Get();
			op = AssignmentOperatorType.ShiftLeft;
			break;
		}
		case 53: {
			Get();
			op = AssignmentOperatorType.ShiftRight;
			break;
		}
		default: SynErr(279); break;
		}
	}