示例#1
0
        public FlatDomain <T> Meet(FlatDomain <T> that)
        {
            if (this.IsTop)
            {
                return(that);
            }
            if (that.IsTop)
            {
                return(this);
            }
            if (this.IsBottom)
            {
                return(this);
            }
            if (that.IsBottom)
            {
                return(that);
            }

            if (this.Value.Equals(that.Value))
            {
                return(that);
            }
            return(BottomValue);
        }
示例#2
0
        public FlatDomain <T> Join(FlatDomain <T> newState, out bool weaker, bool widen)
        {
            if (this.IsTop)
            {
                weaker = false; return(this);
            }
            if (newState.IsTop)
            {
                weaker = !this.IsTop; return(newState);
            }
            if (this.IsBottom)
            {
                weaker = !newState.IsBottom; return(newState);
            }
            if (newState.IsBottom)
            {
                weaker = false; return(this);
            }

            if (this.Value.Equals(newState.Value))
            {
                weaker = false; return(newState);
            }
            weaker = true;
            return(TopValue);
        }
示例#3
0
 public bool LessEqual(FlatDomain <T> that)
 {
     if (that.IsTop)
     {
         return(true);
     }
     if (this.IsBottom)
     {
         return(true);
     }
     if (this.IsTop)
     {
         return(false);
     }
     if (that.IsBottom)
     {
         return(false);
     }
     return(this.Value.Equals(that.Value));
 }
        public static bool TryGetRange <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable>(this Variable var, FlatDomain <Type> t,
                                                                                                                                           IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> MetaDataDecoder, out IntervalStruct result)
            where Type : IEquatable <Type>
        {
            Contract.Requires(MetaDataDecoder != null);

            if (t.IsNormal)
            {
                var type = t.Value;
                if (MetaDataDecoder.System_Boolean.Equals(type) || MetaDataDecoder.System_Int32.Equals(type))
                {
                    result = new IntervalStruct(Int32.MinValue, Int32.MaxValue, (Decimal d) => BoxedExpression.Const((int)d, MetaDataDecoder.System_Int32, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_Char.Equals(type))
                {
                    result = new IntervalStruct(Char.MinValue, Char.MaxValue, (Decimal d) => BoxedExpression.Const((char)d, MetaDataDecoder.System_Char, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_Int8.Equals(type))
                {
                    result = new IntervalStruct(SByte.MinValue, SByte.MaxValue, (Decimal d) => BoxedExpression.Const((sbyte)d, MetaDataDecoder.System_Int8, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_Int16.Equals(type))
                {
                    result = new IntervalStruct(short.MinValue, short.MaxValue, (Decimal d) => BoxedExpression.Const((short)d, MetaDataDecoder.System_Int16, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_Int64.Equals(type))
                {
                    result = new IntervalStruct(long.MinValue, long.MaxValue, (Decimal d) => BoxedExpression.Const((long)d, MetaDataDecoder.System_Int64, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_UInt8.Equals(type))
                {
                    result = new IntervalStruct(byte.MinValue, byte.MaxValue, (Decimal d) => BoxedExpression.Const((byte)d, MetaDataDecoder.System_UInt8, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_UInt16.Equals(type))
                {
                    result = new IntervalStruct(UInt16.MinValue, UInt16.MaxValue, (Decimal d) => BoxedExpression.Const((UInt16)d, MetaDataDecoder.System_UInt16, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_UInt32.Equals(type))
                {
                    result = new IntervalStruct(UInt32.MinValue, UInt32.MaxValue, (Decimal d) => BoxedExpression.Const((UInt32)d, MetaDataDecoder.System_UInt32, MetaDataDecoder));
                    return(true);
                }
                if (MetaDataDecoder.System_UInt64.Equals(type))
                {
                    result = new IntervalStruct(UInt64.MinValue, UInt64.MaxValue, (Decimal d) => BoxedExpression.Const((UInt64)d, MetaDataDecoder.System_UInt64, MetaDataDecoder));
                    return(true);
                }

                // return false for Single, Double,
            }

            result = default(IntervalStruct);
            return(false);
        }
示例#5
0
                private bool IsFloat(FlatDomain <Type> t)
                {
                    var mdDecoder = this.MetaDataDecoder;

                    return(t.IsNormal && (t.Value.Equals(mdDecoder.System_Single) || t.Value.Equals(mdDecoder.System_Double)));
                }
示例#6
0
 //^ [StateIndependent]
 public bool Equals(FlatDomain <T> other)
 {
     return(state == other.state && (!this.IsNormal || this.Value.Equals(other.Value)));
 }
示例#7
0
                private INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> HandleLoadAddrInstruction(APC pc, Variable dest, FlatDomain <Type> t, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> data)
                {
                    if (!t.IsNormal)
                    {
                        return(data);
                    }

                    return(HandleLoadAddrInstruction(pc, dest, t.Value, data));
                }