Exemple #1
0
        /// <inheritdoc />
        public override void VisitFloatValue(FloatValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // When dividend is true and divisor != +-1, result is 1, otherwise 0
                result = ModuloOperation.LeftAbstractBooleanModulo(flow, value.Value);
                break;

            default:
                var rightBoolean = TypeConversion.ToBoolean(value.Value);
                result = Comparison.LeftAbstractBooleanCompare(OutSet, operation, rightBoolean);
                if (result != null)
                {
                    break;
                }

                result = ArithmeticOperation.LeftAbstractBooleanArithmetic(flow, operation, value.Value);
                if (result != null)
                {
                    break;
                }

                result = LogicalOperation.AbstractLogical(OutSet, operation, rightBoolean);
                if (result != null)
                {
                    break;
                }

                base.VisitFloatValue(value);
                break;
            }
        }
Exemple #2
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

            case Operations.Mod:
                // When dividend is true and divisor != +-1, result is 1, otherwise 0
                result = ModuloOperation.LeftAbstractBooleanModulo(flow, value.Value);
                break;

            default:
                var rightBoolean = TypeConversion.ToBoolean(value.Value);
                result = Comparison.LeftAbstractBooleanCompare(OutSet, operation, rightBoolean);
                if (result != null)
                {
                    break;
                }

                result = LogicalOperation.AbstractLogical(OutSet, operation, rightBoolean);
                if (result != null)
                {
                    break;
                }

                int    integerValue;
                double floatValue;
                bool   isInteger;
                TypeConversion.TryConvertToNumber(value.Value, true,
                                                  out integerValue, out floatValue, out isInteger);

                result = isInteger
                        ? ArithmeticOperation.LeftAbstractBooleanArithmetic(flow, operation, integerValue)
                        : ArithmeticOperation.LeftAbstractBooleanArithmetic(flow, operation, floatValue);

                if (result != null)
                {
                    break;
                }

                base.VisitStringValue(value);
                break;
            }
        }