Exemplo n.º 1
0
 public SubPolyhedraAnalysisForUnsafeCode(
     string methodName,
     IMethodDriver <APC, Local, Parameter, Method, Field, Property, Type, Attribute, Assembly, ExternalExpression, Variable, ILogOptions> mdriver,
     List <Analyzers.Unsafe.UnsafeOptions> options,
     IOverallUnsafeStatistics overallStats
     )
     : base(methodName, mdriver, options, overallStats)
 {
     this.encoder = BoxedExpressionEncoder.Encoder(this.DecoderForMetaData, this.Context);
 }
                private ExpressionManager <BoxedVariable <Variable>, BoxedExpression> GetExpressionManager()
                {
                    var valuedDecoder = new AnalysisWrapper.TypeBindings <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable> .ValueExpDecoder(this.Mdriver.Context, this.Mdriver.MetaDataDecoder);

                    var expDecoder = BoxedExpressionDecoder <Variable> .Decoder(valuedDecoder, (object o) => ExpressionType.Unknown);

                    var expEncoder = BoxedExpressionEncoder <Variable> .Encoder(this.Mdriver.MetaDataDecoder, this.Mdriver.Context);

                    var expManager = new ExpressionManagerWithEncoder <BoxedVariable <Variable>, BoxedExpression>(this.timeout, expDecoder, expEncoder);

                    return(expManager);
                }
Exemplo n.º 3
0
                /// <summary>
                /// Given the length of a pointer that is null in one of the two branches of a join, add it to the domain all the contraints
                /// of the length that are on the other branch of the join
                /// </summary>
                /// <param name="pc">The pc at the join point</param>
                /// <param name="length">The length of the null pointer</param>
                /// <param name="result">The state on which we have to add the constraints</param>
                private void RefineWithNullPointerInformation(APC pc, BoxedExpression length, LinearEqualitiesForUnsafeCode thiscloned, LinearEqualitiesForUnsafeCode prevcloned, ref LinearEqualitiesForUnsafeCode result)
                {
                    Set <Polynomial <BoxedExpression> > eq = thiscloned.EqualsTo(length);

                    foreach (Polynomial <BoxedExpression> pol in eq)
                    {
                        IExpressionEncoder <BoxedExpression> encoder = BoxedExpressionEncoder.Encoder(this.mdDecoder, this.context);
                        BoxedExpression right = pol.ToPureExpression(encoder);
                        result = new LinearEqualitiesForUnsafeCode(result.TestTrueEqual(length, right), this.bdecoder, this.context, this.mdDecoder);
                    }
                    eq = prevcloned.EqualsTo(length);
                    foreach (Polynomial <BoxedExpression> pol in eq)
                    {
                        IExpressionEncoder <BoxedExpression> encoder = BoxedExpressionEncoder.Encoder(this.mdDecoder, this.context);
                        BoxedExpression right = pol.ToPureExpression(encoder);
                        result = new LinearEqualitiesForUnsafeCode(result.TestTrueEqual(length, right), this.bdecoder, this.context, this.mdDecoder);
                    }
                }
Exemplo n.º 4
0
        internal static IExpressionEncoder <BoxedVariable <Variable>, BoxedExpression> BoxedEncoder <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, LogOptions>
        (
            this IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, LogOptions> mdriver
        )
            where Type : IEquatable <Type>
            where Expression : IEquatable <Expression>
            where Variable : IEquatable <Variable>
            where LogOptions : IFrameworkLogOptions
        {
            Contract.Ensures(Contract.Result <IExpressionEncoder <BoxedVariable <Variable>, BoxedExpression> >() != null);

            var result = encoderCache as IExpressionEncoder <BoxedVariable <Variable>, BoxedExpression>;

            if (result == null)
            {
                encoderCache = result = BoxedExpressionEncoder <Variable> .Encoder(mdriver.MetaDataDecoder, mdriver.Context);
            }

            return(result);
        }