コード例 #1
0
        public override void VisitCompoundAssignment(ICompoundAssignmentOperation operation)
        {
            Assert.Equal(OperationKind.CompoundAssignment, operation.Kind);
            var operatorMethod      = operation.OperatorMethod;
            var binaryOperationKind = operation.OperatorKind;
            var inConversion        = operation.InConversion;
            var outConversion       = operation.OutConversion;

            if (operation.Syntax.Language == LanguageNames.CSharp)
            {
                Assert.Throws <ArgumentException>("compoundAssignment", () => VisualBasic.VisualBasicExtensions.GetInConversion(operation));
                Assert.Throws <ArgumentException>("compoundAssignment", () => VisualBasic.VisualBasicExtensions.GetOutConversion(operation));
                var inConversionInteranl  = CSharp.CSharpExtensions.GetInConversion(operation);
                var outConversionInteranl = CSharp.CSharpExtensions.GetOutConversion(operation);
            }
            else
            {
                Assert.Throws <ArgumentException>("compoundAssignment", () => CSharp.CSharpExtensions.GetInConversion(operation));
                Assert.Throws <ArgumentException>("compoundAssignment", () => CSharp.CSharpExtensions.GetOutConversion(operation));
                var inConversionInternal  = VisualBasic.VisualBasicExtensions.GetInConversion(operation);
                var outConversionInternal = VisualBasic.VisualBasicExtensions.GetOutConversion(operation);
            }

            var isLifted  = operation.IsLifted;
            var isChecked = operation.IsChecked;

            VisitAssignment(operation);
        }
コード例 #2
0
        public override void VisitCompoundAssignment(ICompoundAssignmentOperation operation)
        {
            var operatorMethod      = operation.OperatorMethod;
            var binaryOperationKind = operation.OperatorKind;

            base.VisitCompoundAssignment(operation);
        }
コード例 #3
0
        public void ICompoundAssignment_NullArgumentToGetConversionThrows()
        {
            ICompoundAssignmentOperation nullAssignment = null;

            Assert.Throws <ArgumentNullException>("compoundAssignment", () => nullAssignment.GetInConversion());
            Assert.Throws <ArgumentNullException>("compoundAssignment", () => nullAssignment.GetOutConversion());
        }
 public override ValueContentAbstractValue ComputeValueForCompoundAssignment(
     ICompoundAssignmentOperation operation,
     ValueContentAbstractValue targetValue,
     ValueContentAbstractValue assignedValue,
     ITypeSymbol targetType,
     ITypeSymbol assignedValueType)
 {
     return(targetValue.MergeBinaryOperation(assignedValue, operation.OperatorKind, targetType, assignedValueType, operation.Type));
 }
コード例 #5
0
 public override bool VisitCompoundAssignment([NotNull] ICompoundAssignmentOperation operation1,
                                              [CanBeNull] IOperation argument)
 {
     return(argument is ICompoundAssignmentOperation operation2 && AreBaseOperationsEqual(operation1, operation2) &&
            operation1.OperatorKind == operation2.OperatorKind &&
            AreSymbolsEqual(operation1.OperatorMethod, operation2.OperatorMethod) &&
            operation1.IsLifted == operation2.IsLifted && operation1.IsChecked == operation2.IsChecked &&
            operation1.InConversion.Equals(operation2.InConversion) &&
            operation1.OutConversion.Equals(operation2.OutConversion));
 }
コード例 #6
0
        private static AbstractExpression ReadCompoundAssignment(ICompoundAssignmentOperation op)
        {
            if (!CompoundAssignmentByOperatorKind.TryGetValue(op.OperatorKind, out var compoundOp))
            {
                throw new NotSupportedException(
                          $"Compound assignment kind {op.OperatorKind} ({op.GetType().Name}) is not supported");
            }

            var result = (AssignmentExpression)ReadAssignment(op);

            result.CompoundOperator = compoundOp;
            return(result);
        }
コード例 #7
0
            public override StringContentAbstractValue VisitCompoundAssignment(ICompoundAssignmentOperation operation, object argument)
            {
                StringContentAbstractValue value;

                switch (operation.OperatorKind)
                {
                case BinaryOperatorKind.Add:
                case BinaryOperatorKind.Concatenate:
                    var leftValue  = Visit(operation.Target, argument);
                    var rightValue = Visit(operation.Value, argument);
                    value = leftValue.MergeBinaryAdd(rightValue);
                    break;

                default:
                    value = base.VisitCompoundAssignment(operation, argument);
                    break;
                }

                SetAbstractValueForAssignment(operation.Target, operation.Value, value);
                return(value);
            }
コード例 #8
0
        public override IOperation VisitCompoundAssignment(ICompoundAssignmentOperation operation, object argument)
        {
            var compoundAssignment = (BaseCompoundAssignmentExpression)operation;

            return(new CompoundAssignmentOperation(Visit(operation.Target), Visit(operation.Value), compoundAssignment.InConversionConvertible, compoundAssignment.OutConversionConvertible, operation.OperatorKind, operation.IsLifted, operation.IsChecked, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit));
        }
コード例 #9
0
ファイル: OperationVisitor.cs プロジェクト: zyonet/roslyn
 public virtual void VisitCompoundAssignment(ICompoundAssignmentOperation operation)
 {
     DefaultVisit(operation);
 }
 public override void VisitCompoundAssignment([NotNull] ICompoundAssignmentOperation operation)
 {
     RegisterAssignment(operation.Target);
     base.VisitCompoundAssignment(operation);
 }
コード例 #11
0
 public override void VisitCompoundAssignment([NotNull] ICompoundAssignmentOperation operation)
 {
     base.VisitCompoundAssignment(operation);
 }
コード例 #12
0
            public override StringContentAbstractValue ComputeValueForCompoundAssignment(ICompoundAssignmentOperation operation, StringContentAbstractValue targetValue, StringContentAbstractValue assignedValue)
            {
                switch (operation.OperatorKind)
                {
                case BinaryOperatorKind.Add:
                case BinaryOperatorKind.Concatenate:
                    return(targetValue.MergeBinaryAdd(assignedValue));

                default:
                    return(base.ComputeValueForCompoundAssignment(operation, targetValue, assignedValue));
                }
            }
コード例 #13
0
ファイル: ScopeUsage.cs プロジェクト: pepelev/Suspension
        public override Scope VisitCompoundAssignment(ICompoundAssignmentOperation operation, Scope currentScope)
        {
            var scope = operation.Value.Accept(this, currentScope);

            return(operation.Target.Accept(this, scope));
        }
コード例 #14
0
 public override Scope VisitCompoundAssignment(ICompoundAssignmentOperation operation, Scope currentScope)
 => currentScope;
コード例 #15
0
 public override void VisitCompoundAssignment(ICompoundAssignmentOperation operation)
 {
     base.VisitCompoundAssignment(operation);
     throw new NotImplementedException();
 }
コード例 #16
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="operation">IOperationインスタンス</param>
        /// <param name="container">イベントコンテナ</param>
        public CompoundAssignment(ICompoundAssignmentOperation operation, EventContainer container) : base(container)
        {
            // 対象インスタンス
            Expressions.AddRange(OperationFactory.GetExpressionList(operation.Target, container));

            var operatorName = string.Empty;

            switch (operation.OperatorKind)
            {
            case BinaryOperatorKind.Add:
                operatorName = "+";
                break;

            case BinaryOperatorKind.Subtract:
                operatorName = "-";
                break;

            case BinaryOperatorKind.Multiply:
                operatorName = "*";
                break;

            case BinaryOperatorKind.Divide:
                operatorName = "/";
                break;

            case BinaryOperatorKind.And:
                operatorName = "&&";
                break;

            case BinaryOperatorKind.ConditionalAnd:
                operatorName = "&";
                break;

            case BinaryOperatorKind.ConditionalOr:
                operatorName = "|";
                break;

            case BinaryOperatorKind.Equals:
                operatorName = "==";
                break;

            case BinaryOperatorKind.ExclusiveOr:
                operatorName = "^";
                break;

            case BinaryOperatorKind.GreaterThan:
                operatorName = ">";
                break;

            case BinaryOperatorKind.GreaterThanOrEqual:
                operatorName = ">=";
                break;

            case BinaryOperatorKind.LessThan:
                operatorName = "<";
                break;

            case BinaryOperatorKind.LessThanOrEqual:
                operatorName = "<=";
                break;

            case BinaryOperatorKind.NotEquals:
                operatorName = "!=";
                break;

            case BinaryOperatorKind.Or:
                operatorName = "||";
                break;
            }
            if (!string.IsNullOrEmpty(operatorName))
            {
                Expressions.Add(new Expression($"{operatorName}=", string.Empty));
            }

            // 値
            Expressions.AddRange(OperationFactory.GetExpressionList(operation.Value, container));
        }