예제 #1
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
                result = OutSet.CreateBool(true);
                break;

            case Operations.BitAnd:
                result = OutSet.CreateInt(0);
                break;

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

            case Operations.Mod:
                result = ModuloOperation.ModuloByNull(flow);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #2
0
 /// <inheritdoc />
 public override void VisitIntegerValue(IntegerValue value)
 {
     if (isIncrement)
     {
         if (value.Value < int.MaxValue)
         {
             result = OutSet.CreateInt(value.Value + 1);
         }
         else
         {
             result = OutSet.CreateDouble(TypeConversion.ToFloat(value.Value) + 1.0);
         }
     }
     else
     {
         if (value.Value > int.MinValue)
         {
             result = OutSet.CreateInt(value.Value - 1);
         }
         else
         {
             result = OutSet.CreateDouble(TypeConversion.ToFloat(value.Value) - 1.0);
         }
     }
 }
예제 #3
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.Equal:
            case Operations.LessThanOrEqual:
                result = OutSet.CreateBool(!TypeConversion.ToBoolean(leftOperand.Value));
                break;

            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(OutSet, leftOperand);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = leftOperand;
                break;

            case Operations.Mul:
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #4
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.Identical:
            case Operations.LessThan:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Equal:
            case Operations.LessThanOrEqual:
                bool convertedValue;
                if (TypeConversion.TryConvertToBoolean(leftOperand, out convertedValue))
                {
                    result = OutSet.CreateBool(!convertedValue);
                }
                else
                {
                    result = OutSet.AnyBooleanValue;
                }
                break;

            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(OutSet, leftOperand);
                break;

            case Operations.Add:
            case Operations.Sub:
                result = leftOperand;
                break;

            case Operations.BitAnd:
                result = OutSet.CreateInt(0);
                break;

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

            case Operations.Mod:
                result = ModuloOperation.ModuloByNull(flow);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #5
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            int    integerValue;
            double floatValue;
            bool   isInteger;

            switch (operation)
            {
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(OutSet, leftOperand);
                break;

            case Operations.Add:
            case Operations.Sub:
                TypeConversion.TryConvertToNumber(leftOperand.Value, true, out integerValue,
                                                  out floatValue, out isInteger);
                if (isInteger)
                {
                    result = OutSet.CreateInt(integerValue);
                }
                else
                {
                    result = OutSet.CreateDouble(floatValue);
                }
                break;

            case Operations.Mul:
                TypeConversion.TryConvertToNumber(leftOperand.Value, true, out integerValue,
                                                  out floatValue, out isInteger);
                if (isInteger)
                {
                    result = OutSet.CreateInt(0);
                }
                else
                {
                    result = OutSet.CreateDouble(0.0);
                }
                break;

            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = TypeConversion.ToInteger(OutSet, leftOperand);
                break;

            default:
                result = Comparison.Compare(OutSet, operation, leftOperand.Value, string.Empty);
                if (result != null)
                {
                    break;
                }

                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #6
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(!TypeConversion.ToNativeBoolean(Snapshot, value));
                break;

            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(Snapshot, value);
                break;

            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
                result = TypeConversion.ToInteger(Snapshot, value);
                break;

            case Operations.Mod:
                if (TypeConversion.ToNativeBoolean(Snapshot, value))
                {
                    // 0 (null) divided or modulo by anything is always 0
                    result = OutSet.CreateInt(0);
                }
                else
                {
                    SetWarning("Division by zero (converted from array)",
                               AnalysisWarningCause.DIVISION_BY_ZERO);

                    // Division or modulo by zero returns false boolean value
                    result = OutSet.CreateBool(false);
                }
                break;

            default:
                if (ArithmeticOperation.IsArithmetic(operation))
                {
                    // TODO: This must be fatal error
                    SetWarning("Unsupported operand type: Arithmetic of array and null type");
                    result = OutSet.AnyValue;
                    break;
                }

                base.VisitAssociativeArray(value);
                break;
            }
        }
예제 #7
0
        /// <inheritdoc />
        public override void VisitGenericIntervalValue <T>(IntervalValue <T> value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.Identical:
            case Operations.GreaterThan:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
            case Operations.LessThanOrEqual:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Equal:
            case Operations.GreaterThanOrEqual:
                bool booleanValue;
                if (TypeConversion.TryConvertToBoolean(value, out booleanValue))
                {
                    result = OutSet.CreateBool(!booleanValue);
                }
                else
                {
                    result = OutSet.AnyBooleanValue;
                }
                break;

            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                BooleanValue convertedValue;
                if (TypeConversion.TryConvertToBoolean(OutSet, value, out convertedValue))
                {
                    result = convertedValue;
                }
                else
                {
                    result = OutSet.AnyBooleanValue;
                }
                break;

            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitGenericIntervalValue(value);
                break;
            }
        }
예제 #8
0
 /// <inheritdoc />
 public override void VisitUndefinedValue(UndefinedValue value)
 {
     if (isIncrement)
     {
         result = OutSet.CreateInt(1);
     }
     else
     {
         result = value;
     }
 }
예제 #9
0
        private MemoryEntry sub(MemoryEntry left, MemoryEntry right)
        {
            if (left.Count != 1 || right.Count != 1)
            {
                throw new NotImplementedException();
            }

            var leftValue  = left.PossibleValues.First() as IntegerValue;
            var rightValue = right.PossibleValues.First() as IntegerValue;

            return(new MemoryEntry(OutSet.CreateInt(leftValue.Value - rightValue.Value)));
        }
예제 #10
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.LessThan:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Equal:
            case Operations.LessThanOrEqual:
                result = OutSet.CreateBool(!TypeConversion.ToNativeBoolean(Snapshot, leftOperand));
                break;

            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(Snapshot, leftOperand);
                break;

            case Operations.BitAnd:
                result = OutSet.CreateInt(0);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = TypeConversion.ToInteger(Snapshot, leftOperand);
                break;

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

            case Operations.Mod:
                result = ModuloOperation.ModuloByNull(flow);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #11
0
        /// <inheritdoc />
        public override void VisitAnyObjectValue(AnyObjectValue value)
        {
            // An object is always greater then null value
            switch (operation)
            {
            case Operations.Equal:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Mul:
            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                SetWarning("Object cannot be converted to integer",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                result = OutSet.CreateInt(0);
                break;

            case Operations.Add:
            case Operations.Sub:
            case Operations.BitOr:
            case Operations.BitXor:
                SetWarning("Object cannot be converted to integer",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                result = OutSet.AnyIntegerValue;
                break;

            case Operations.Div:
            case Operations.Mod:
                SetWarning("Object cannot be converted to integer",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                // We can assume that object is not zero, because null is zero
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitAnyObjectValue(value);
                break;
            }
        }
예제 #12
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.Equal:
            case Operations.LessThan:
            case Operations.LessThanOrEqual:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.GreaterThanOrEqual:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Add:
            case Operations.Sub:
            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.AnyIntegerValue;
                break;

            case Operations.Mul:
            case Operations.BitAnd:
                result = OutSet.CreateInt(0);
                break;

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

            case Operations.Mod:
                result = ModuloOperation.ModuloByNull(flow);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #13
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            // Resource is always greater than null
            switch (operation)
            {
            case Operations.Equal:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Mul:
            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            case Operations.Add:
            case Operations.Sub:
            case Operations.BitOr:
            case Operations.BitXor:
                result = OutSet.AnyIntegerValue;
                break;

            case Operations.Div:
            case Operations.Mod:
                // We can assume that resource is not zero, because it is always true
                result = OutSet.CreateInt(0);
                break;

            default:
                if (PerformCommonAnyOperandOperations())
                {
                    break;
                }

                base.VisitAnyResourceValue(value);
                break;
            }
        }
예제 #14
0
        /// <inheritdoc />
        public override void VisitFloatValue(FloatValue value)
        {
            switch (operation)
            {
            case Operations.Plus:
                result = value;
                break;

            case Operations.Minus:
                result = OutSet.CreateDouble(-value.Value);
                break;

            case Operations.BitNegation:
                int nativeIntegerValue;
                if (TypeConversion.TryConvertToInteger(value.Value, out nativeIntegerValue))
                {
                    result = OutSet.CreateInt(~nativeIntegerValue);
                }
                else
                {
                    result = OutSet.AnyIntegerValue;
                }
                break;

            case Operations.Int32Cast:
                IntegerValue integerValue;
                if (TypeConversion.TryConvertToInteger(OutSet, value, out integerValue))
                {
                    result = integerValue;
                }
                else
                {
                    result = OutSet.AnyIntegerValue;
                }
                break;

            case Operations.FloatCast:
            case Operations.DoubleCast:
                result = value;
                break;

            default:
                base.VisitFloatValue(value);
                break;
            }
        }
예제 #15
0
        /// <inheritdoc />
        public override void VisitAnyBooleanValue(AnyBooleanValue value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.GreaterThanOrEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = value;
                break;

            case Operations.Add:
            case Operations.BitOr:
            case Operations.BitXor:
                result = TypeConversion.AnyBooleanToIntegerInterval(OutSet);
                break;

            case Operations.Sub:
                var booleanInterval = TypeConversion.AnyBooleanToIntegerInterval(OutSet);
                result = OutSet.CreateIntegerInterval(-booleanInterval.End, -booleanInterval.Start);
                break;

            case Operations.Mul:
                result = OutSet.CreateInt(0);
                break;

            case Operations.Div:
                SetWarning("Possible division by zero (converted from boolean false)",
                           AnalysisWarningCause.DIVISION_BY_ZERO);

                // Division or modulo by false returns false boolean value
                result = OutSet.AnyValue;
                break;

            case Operations.Mod:
                result = ModuloOperation.ModuloByAnyBooleanValue(flow);
                break;

            default:
                base.VisitAnyBooleanValue(value);
                break;
            }
        }
예제 #16
0
        /// <inheritdoc />
        public override void VisitIntervalIntegerValue(IntegerIntervalValue value)
        {
            if (value.Start == value.End)
            {
                VisitIntegerValue(OutSet.CreateInt(value.Start));
                return;
            }

            switch (operation)
            {
            case Operations.Minus:
                // Result of arithmetic negation can overflow
                if ((value.Start == 0) || ((-value.Start) != 0))
                {
                    result = OutSet.CreateIntegerInterval(-value.End, -value.Start);
                }
                else
                {
                    // <seealso cref="UnaryOperationEvaluator.VisitIntegerValue" />
                    result = OutSet.CreateFloatInterval(-TypeConversion.ToFloat(value.End),
                                                        -TypeConversion.ToFloat(value.Start));
                }
                break;

            case Operations.BitNegation:
                result = OutSet.CreateIntegerInterval(~value.End, ~value.Start);
                break;

            case Operations.Int32Cast:
                result = value;
                break;

            case Operations.FloatCast:
            case Operations.DoubleCast:
                result = OutSet.CreateFloatInterval(TypeConversion.ToFloat(value.Start),
                                                    TypeConversion.ToFloat(value.End));
                break;

            default:
                base.VisitIntervalIntegerValue(value);
                break;
            }
        }
예제 #17
0
        /// <inheritdoc />
        public override void VisitIntegerValue(IntegerValue value)
        {
            switch (operation)
            {
            case Operations.Plus:
                result = value;
                break;

            case Operations.Minus:
                // Result of arithmetic negation can overflow
                if ((value.Value == 0) || ((-value.Value) != 0))
                {
                    result = OutSet.CreateInt(-value.Value);
                }
                else
                {
                    // If the number has the lowest value (the most important bit is 1, others are 0
                    // in binary), arithmetic negation of it is zero. PHP behaves differently.
                    // It converts the number to the same positive value, but that cause overflow.
                    // Then integer value is converted to appropriate float value
                    result = OutSet.CreateDouble(-TypeConversion.ToFloat(value.Value));
                }
                break;

            case Operations.BitNegation:
                result = OutSet.CreateInt(~value.Value);
                break;

            case Operations.Int32Cast:
                result = value;
                break;

            case Operations.FloatCast:
            case Operations.DoubleCast:
                result = OutSet.CreateDouble(value.Value);
                break;

            default:
                base.VisitIntegerValue(value);
                break;
            }
        }
예제 #18
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.LessThan:
                result = OutSet.CreateBool(false);
                break;

            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Equal:
            case Operations.LessThanOrEqual:
                result = OutSet.CreateBool(!leftOperand.Value);
                break;

            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.Or:
            case Operations.Xor:
                result = leftOperand;
                break;

            case Operations.Add:
            case Operations.Sub:
            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = TypeConversion.ToInteger(OutSet, leftOperand);
                break;

            case Operations.Mul:
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #19
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.Identical:
            case Operations.LessThan:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.LessThanOrEqual:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.AnyBooleanValue;
                break;

            case Operations.BitAnd:
                result = OutSet.CreateInt(0);
                break;

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

            case Operations.Mod:
                result = ModuloOperation.ModuloByNull(flow);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #20
0
        /// <inheritdoc />
        public override void VisitAnyScalarValue(AnyScalarValue value)
        {
            switch (operation)
            {
            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            default:
                if (PerformCommonAnyOperandOperations())
                {
                    break;
                }

                base.VisitAnyScalarValue(value);
                break;
            }
        }
예제 #21
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = leftOperand;
                break;

            case Operations.Mul:
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #22
0
        public override MemoryEntry IncDecEx(IncDecEx operation, MemoryEntry incrementedValue)
        {
            var inc = operation.Inc ? 1 : -1;

            var values = new List <Value>();

            foreach (var incremented in incrementedValue.PossibleValues)
            {
                var integer = incremented as IntegerValue;
                if (integer == null)
                {
                    return(new MemoryEntry(OutSet.AnyValue));
                }

                var result = OutSet.CreateInt(integer.Value + inc);
                values.Add(result);
            }

            return(new MemoryEntry(values));
        }
예제 #23
0
        /// <inheritdoc />
        public override void VisitAnyArrayValue(AnyArrayValue value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.GreaterThanOrEqual:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.AnyBooleanValue;
                break;

            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
                result = TypeConversion.AnyArrayToIntegerInterval(OutSet);
                break;

            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow);
                break;

            default:
                if (ArithmeticOperation.IsArithmetic(operation))
                {
                    // TODO: This must be fatal error
                    SetWarning("Unsupported operand type: Arithmetic of array and null type");
                    result = OutSet.AnyValue;
                    break;
                }

                base.VisitAnyArrayValue(value);
                break;
            }
        }
예제 #24
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.Equal:
            case Operations.LessThanOrEqual:
                result = OutSet.CreateBool(!TypeConversion.ToBoolean(leftOperand.Value));
                break;

            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(OutSet, leftOperand);
                break;

            case Operations.Mul:
                result = OutSet.CreateDouble(0.0);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                int leftInteger;
                if (TypeConversion.TryConvertToInteger(leftOperand.Value, out leftInteger))
                {
                    result = OutSet.CreateInt(leftInteger);
                }
                else
                {
                    result = OutSet.AnyIntegerValue;
                }
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #25
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = leftOperand;
                break;

            case Operations.Mul:
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #26
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Add:
            case Operations.Sub:
            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = TypeConversion.AnyBooleanToIntegerInterval(OutSet);
                break;

            case Operations.Mul:
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
예제 #27
0
        /// <inheritdoc />
        protected override void flowThrough()
        {
            switch (_partial.Type)
            {
            case PseudoConstUse.Types.Line:
                Value = OutSet.CreateSnapshotEntry(new MemoryEntry(OutSet.CreateInt(_partial.Position.FirstLine)));
                return;

            case PseudoConstUse.Types.File:
                Value = OutSet.CreateSnapshotEntry(new MemoryEntry(OutSet.CreateString(OwningScriptFullName)));
                return;

            case PseudoConstUse.Types.Dir:
                Value = OutSet.CreateSnapshotEntry(new MemoryEntry(OutSet.CreateString(OwningScript.Directory.FullName)));
                return;

            case PseudoConstUse.Types.Function:
                if (OwningPPGraph.FunctionName == null)
                {
                    Value = OutSet.CreateSnapshotEntry(new MemoryEntry(OutSet.UndefinedValue));
                }
                else
                {
                    Value = OutSet.CreateSnapshotEntry(new MemoryEntry(OutSet.CreateString(OwningPPGraph.FunctionName)));
                }
                return;

            case PseudoConstUse.Types.Method:
            case PseudoConstUse.Types.Class:
            case PseudoConstUse.Types.Namespace:
                Value = OutSet.CreateSnapshotEntry(new MemoryEntry(OutSet.AnyStringValue));
                return;

            default:
                Value = OutSet.CreateSnapshotEntry(new MemoryEntry(OutSet.AnyValue));
                return;
            }
        }
예제 #28
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Plus:
                result = TypeConversion.ToInteger(OutSet, value);
                break;

            case Operations.Minus:
                result = OutSet.CreateInt(value.Value ? -1 : 0);
                break;

            case Operations.LogicNegation:
                result = OutSet.CreateBool(!value.Value);
                break;

            case Operations.BitNegation:
                // TODO: This must be fatal error
                SetWarning("Unsupported operand types: Bit negation of boolean value");
                result = OutSet.AnyValue;
                break;

            case Operations.Int32Cast:
                result = TypeConversion.ToInteger(OutSet, value);
                break;

            case Operations.FloatCast:
            case Operations.DoubleCast:
                result = TypeConversion.ToFloat(Snapshot, value);
                break;

            default:
                base.VisitBooleanValue(value);
                break;
            }
        }
예제 #29
0
        /// <inheritdoc />
        public override void VisitScalarValue(ScalarValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
                result = OutSet.CreateBool(true);
                break;

            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            default:
                base.VisitScalarValue(value);
                break;
            }
        }
예제 #30
0
 /// <summary>
 /// Create integer representation of given literal
 /// </summary>
 /// <param name="x">Literal value</param>
 /// <returns>Created literal value representation</returns>
 public virtual MemoryEntry IntLiteral(IntLiteral x)
 {
     return(new MemoryEntry(OutSet.CreateInt((int)x.Value)));
 }