Exemple #1
0
 public override bool VisitUnaryOperator([NotNull] IUnaryOperation operation1, [CanBeNull] IOperation argument)
 {
     return(argument is IUnaryOperation operation2 && AreBaseOperationsEqual(operation1, operation2) &&
            operation1.OperatorKind == operation2.OperatorKind &&
            AreSymbolsEqual(operation1.OperatorMethod, operation2.OperatorMethod) &&
            operation1.IsLifted == operation2.IsLifted && operation1.IsChecked == operation2.IsChecked);
 }
Exemple #2
0
 public string Subtraction_entered()
 {
     is_num_entered           = false;
     unary_pending_operation  = null;
     binary_pending_operation = new Subtraction();
     return(result);
 }
 public override void VisitUnaryOperator(IUnaryOperation operation)
 {
     if (operation.OperatorKind == UnaryOperatorKind.Not)
     {
         Visit(operation.Operand);
     }
 }
Exemple #4
0
 public void AddUnaryOperation(IUnaryOperation operation)
 {
     if (!UnaryOperations.Contains(operation))
     {
         UnaryOperations.Add(operation);
     }
 }
Exemple #5
0
        private void OnCompilationStart(CompilationStartAnalysisContext compilationContext)
        {
            var restrictedInternalsVisibleToMap = GetRestrictedInternalsVisibleToMap(compilationContext.Compilation);
            if (restrictedInternalsVisibleToMap.IsEmpty)
            {
                return;
            }

            var namespaceToIsBannedMap = new ConcurrentDictionary<INamespaceSymbol, /*isBanned*/bool>();

            // Verify all explicit type name specifications in declarations and executable code.
            compilationContext.RegisterSyntaxNodeAction(
                context =>
                {
                    var name = (TNameSyntax)context.Node;
                    if (!IsInTypeOnlyContext(name) ||
                        name.Parent is TNameSyntax)
                    {
                        // Bail out if we are not in type only context or the parent is also a name
                        // which will be analyzed separately.
                        return;
                    }

                    var typeInfo = context.SemanticModel.GetTypeInfo(name, context.CancellationToken);
                    VerifySymbol(typeInfo.Type as INamedTypeSymbol, name,
                        context.ReportDiagnostic, restrictedInternalsVisibleToMap, namespaceToIsBannedMap);
                },
                NameSyntaxKinds);

            // Verify all member usages in executable code.
            compilationContext.RegisterOperationAction(
                context =>
                {
                    var symbol = context.Operation switch
                    {
                        IObjectCreationOperation objectCreation => objectCreation.Constructor,
                        IInvocationOperation invocation => invocation.TargetMethod,
                        IMemberReferenceOperation memberReference => memberReference.Member,
                        IConversionOperation conversion => conversion.OperatorMethod,
                        IUnaryOperation unary => unary.OperatorMethod,
                        IBinaryOperation binary => binary.OperatorMethod,
                        IIncrementOrDecrementOperation incrementOrDecrement => incrementOrDecrement.OperatorMethod,
                        _ => throw new NotImplementedException($"Unhandled OperationKind: {context.Operation.Kind}"),
                    };

                    VerifySymbol(symbol, context.Operation.Syntax,
                        context.ReportDiagnostic, restrictedInternalsVisibleToMap, namespaceToIsBannedMap);
                },
                OperationKind.ObjectCreation,
                OperationKind.Invocation,
                OperationKind.EventReference,
                OperationKind.FieldReference,
                OperationKind.MethodReference,
                OperationKind.PropertyReference,
                OperationKind.Conversion,
                OperationKind.UnaryOperator,
                OperationKind.BinaryOperator,
                OperationKind.Increment,
                OperationKind.Decrement);
        }
Exemple #6
0
        public string Reciprocal_entered()
        {
            unary_operation = new Reciprocal();
            string firstEnteredValue = UnaryEquals();

            return(firstEnteredValue);
        }
Exemple #7
0
        public string RunUnaryOperation(string operation)
        {
            Unary_operation_factory factory = new Unary_operation_factory();

            unary_operation = factory.GetOperation(operation);
            if (equals_flag)
            {
                ClearAllButLhs();
            }

            if (Lhs.IsNotSet())
            {
                Lhs.Value = 0;
                Lhs.Value = unary_operation.PerformUnaryCalculation(Lhs.Value);
                return(Lhs.Value.ToString());
            }
            else if (pending_operation == null)
            {
                Lhs.Value = unary_operation.PerformUnaryCalculation(Lhs.Value);
                return(Lhs.Value.ToString());
            }
            else if (Rhs.IsNotSet())
            {
                Rhs.Value = unary_operation.PerformUnaryCalculation(Lhs.Value);
                return(Rhs.Value.ToString());
            }
            else // if (Rhs.IsSet())
            {
                Rhs.Value = unary_operation.PerformUnaryCalculation(Rhs.Value);
                return(Rhs.Value.ToString());
            }
        }
Exemple #8
0
 public string Clear_entered()
 {
     pending_operation = null;
     unary_operation   = null;
     firstEnteredValue = 0.0;
     lastEnteredValue  = 0.0;
     return("0");
 }
 public override void Visit(IUnaryOperation unaryOperation)
 {
     if (Process(unaryOperation))
     {
         visitor.Visit(unaryOperation);
     }
     base.Visit(unaryOperation);
 }
Exemple #10
0
        public override void VisitUnaryOperator(IUnaryOperation operation)
        {
            var operatorMethod     = operation.OperatorMethod;
            var unaryOperationKind = operation.OperatorKind;
            var isLifted           = operation.IsLifted;
            var isChecked          = operation.IsChecked;

            base.VisitUnaryOperator(operation);
        }
        public override void VisitUnaryOperator(IUnaryOperation operation)
        {
            Assert.Equal(OperationKind.UnaryOperator, operation.Kind);
            var operatorMethod     = operation.OperatorMethod;
            var unaryOperationKind = operation.OperatorKind;
            var isLifted           = operation.IsLifted;
            var isChecked          = operation.IsChecked;

            Assert.Same(operation.Operand, operation.Children.Single());
        }
Exemple #12
0
 public string Clear_entered()
 {
     lhs                      = 0;
     rhs                      = 0;
     result                   = "0";
     is_num_entered           = false;
     is_decimal_entered       = false;
     binary_pending_operation = null;
     unary_pending_operation  = null;
     return(result);
 }
            public override FlightEnabledAbstractValue VisitUnaryOperatorCore(IUnaryOperation operation, object?argument)
            {
                var value = base.VisitUnaryOperatorCore(operation, argument);

                if (operation.OperatorKind == UnaryOperatorKind.Not &&
                    value.Kind == FlightEnabledAbstractValueKind.Known)
                {
                    return(value.GetNegatedValue());
                }

                return(value);
            }
Exemple #14
0
 public string Reciprocal_entered()
 {
     is_num_entered           = false;
     binary_pending_operation = null;
     unary_pending_operation  = new Reciprocal();
     if (Convert.ToDouble(result) == 0.0)
     {
         Clear_entered(); return("Divide by Zero Error");
     }
     lhs    = unary_pending_operation.Perform_unary_calculation(Convert.ToDouble(result));
     result = lhs.ToString();
     return(lhs.ToString());
 }
Exemple #15
0
 public string Square_root_entered()
 {
     is_num_entered           = false;
     binary_pending_operation = null;
     unary_pending_operation  = new Square_root();
     if (Convert.ToDouble(result) < 0.0)
     {
         Clear_entered(); return("Invalid Input");
     }
     lhs    = unary_pending_operation.Perform_unary_calculation(Convert.ToDouble(result));
     result = lhs.ToString();
     return(lhs.ToString());
 }
Exemple #16
0
        private void ExecuteOperation(IUnaryOperation operation, double value)
        {
            ExecuteOperation(GetExecutableInfo, GetResult);

            ExecutableInfo GetExecutableInfo()
            {
                return(operation.GetExecutableInfo(value));
            }

            double GetResult()
            {
                return(operation.Execute(value));
            }
        }
Exemple #17
0
 public GeneratorUnaryOperation(IUnaryOperation operation)
 {
     Type    = operation.Type;
     Operand = GeneratorDynamicProperty.ConvertOperation(operation.Operand);
 }
Exemple #18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="unaryOperation"></param>
 internal UnaryOperation(IUnaryOperation unaryOperation)
     : base(unaryOperation)
 {
     this.operand = unaryOperation.Operand;
 }
Exemple #19
0
 public override IOperation VisitUnaryOperator(IUnaryOperation operation, object argument)
 {
     return(new UnaryOperatorExpression(operation.OperatorKind, Visit(operation.Operand), operation.IsLifted, operation.IsChecked, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit));
 }
Exemple #20
0
 /// <summary>
 /// Performs some computation with the given unary operation expression.
 /// </summary>
 /// <param name="unaryOperation"></param>
 public virtual void Visit(IUnaryOperation unaryOperation)
 {
     this.Visit((IExpression)unaryOperation);
 }
Exemple #21
0
 /// <summary>
 /// Called whenever a unary operation expression is about to be traversed by a type specific routine.
 /// This gives the traverser the opportunity to take some uniform action for all unary operation expressions,
 /// regardless of how the traversal gets to them.
 /// </summary>
 public virtual void TraverseChildren(IUnaryOperation unaryOperation)
 {
     Contract.Requires(unaryOperation != null);
       this.TraverseChildren((IExpression)unaryOperation);
       this.Traverse(unaryOperation.Operand);
 }
Exemple #22
0
 /// <summary>
 /// Traverses the unary operation expression.
 /// </summary>
 /// <param name="unaryOperation"></param>
 public void Traverse(IUnaryOperation unaryOperation)
 {
     Contract.Requires(unaryOperation != null);
       unaryOperation.Dispatch(this.dispatchingVisitor);
 }
 /// <summary>
 /// Performs some computation with the given unary operation expression.
 /// </summary>
 /// <param name="unaryOperation"></param>
 public virtual void Visit(IUnaryOperation unaryOperation)
 {
     
 }
Exemple #24
0
 public string Square_root_entered()
 {
     unary_operation = new SquareRoot();
     UnaryEquals();
     return(firstEnteredValue.ToString());
 }
Exemple #25
0
 public override void Visit(IUnaryOperation unaryOperation)
 {
     allElements.Add(new InvokInfo(Traverser, "IUnaryOperation", unaryOperation));
 }
Exemple #26
0
 public override Scope VisitUnaryOperator(IUnaryOperation operation, Scope currentScope) =>
 operation.Operand.Accept(this, currentScope);
 private static bool IsOperatorNot([NotNull] IUnaryOperation unaryOperator)
 {
     return(unaryOperator.OperatorKind == UnaryOperatorKind.Not);
 }
Exemple #28
0
 public override IState Next(IUnaryOperation operation)
 {
     stateParams.LeftOperand = operation.Perform(stateParams.LeftOperand);
     return(this);
 }
 /// <summary>
 /// Performs some computation with the given unary operation expression.
 /// </summary>
 /// <param name="unaryOperation"></param>
 public virtual void Visit(IUnaryOperation unaryOperation)
 {
 }
Exemple #30
0
 public override void VisitUnaryOperator([NotNull] IUnaryOperation operation)
 {
     base.VisitUnaryOperator(operation);
 }
 public override IState Next(IUnaryOperation operation)
 {
     PerformPendingOperation();
     stateParams.LeftOperand = operation.Perform(stateParams.LeftOperand);
     return(stateFactory.GetShowResultState(stateParams));
 }
        public override void TraverseChildren(IUnaryOperation unaryOperation)
{ MethodEnter(unaryOperation);
            base.TraverseChildren(unaryOperation);
     MethodExit();   }
Exemple #33
0
 public abstract IState Next(IUnaryOperation operation);
Exemple #34
0
 public virtual void VisitUnaryOperator(IUnaryOperation operation)
 {
     DefaultVisit(operation);
 }
Exemple #35
0
 public override void TraverseChildren(IUnaryOperation unaryOperation)
 {
     MethodEnter(unaryOperation);
     base.TraverseChildren(unaryOperation);
     MethodExit();
 }
Exemple #36
0
 public double DoMathOperation(IUnaryOperation calculatorMathOp, double n1)
 {
     return(calculatorMathOp.Compute(n1));
 }
        static void ComplexNumberUnaryArithmetics(IUnaryOperation channel, Complex z)
        {
            try
            {
                Console.WriteLine("\n*** Complex Number Unary Arithmetics ***\n");

                Console.WriteLine("Conjugate[{0}] = {1}", f(z), f(channel.Conjugate(z)));
                Console.WriteLine("Reciprocal[{0}] = {1}", f(z), f(channel.Reciprocal(z)));
                Console.WriteLine("Modulus[{0}] = {1}", f(z), channel.Modulus(z));
                Console.WriteLine("Argument[{0}] = {1} Radians", f(z), channel.Argument(z));
            }
            catch (Exception fx)
            {
                Console.WriteLine(fx.Message);
            }
        }
 public override void Visit(IUnaryOperation unaryOperation)
 {
     if(Process(unaryOperation)){visitor.Visit(unaryOperation);}
     base.Visit(unaryOperation);
 }