Ejemplo n.º 1
0
        public SlicerWorker(
            GeneralOptions options,
            ISimpleLineWriter outputLineWriter,
            ISlicerEnvironment <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> environment
            )
        {
            this.options         = options;
            this.environment     = environment;
            this.mdDecoder       = environment.MetaDataDecoder;
            this.contractDecoder = environment.ContractDecoder;
            this.fieldsDB        = new FieldsDB <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(this.mdDecoder);

            this.output = new TextWriterOutputWithPrefix(outputLineWriter.AsTextWriter(), options, "[SlicerWorker] "); // TODO

            var basicDriver = new BasicAnalysisDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, ILogOptions>(this.mdDecoder, this.contractDecoder, this.output, options);

            this.driver = new OldAnalysisDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, ILogOptions, IMethodResult <SymbolicValue> >(basicDriver);

            this.OptionsData = OptionsHashing.GetOptionsData(environment.MethodAnalyzers, environment.ClassAnalyzers, options);

            EGraphStats.IncrementalJoin = options.incrementalEgraphJoin; // used in OptimisticHeapAnalysis

            // TODO: initialize analysis needed by the slicer, but not more

            // TODO: is that it?
        }
Ejemplo n.º 2
0
 public ProtectionBasedMethodOrder(
     IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> md,
     IDecodeContracts <Local, Parameter, Method, Field, Type> cd,
     FieldsDB <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> fieldsDB,
     CancellationToken cancellationToken)
     : base(md, cd, fieldsDB)
 {
     this.cancellationToken = cancellationToken;
 }
Ejemplo n.º 3
0
        protected BaseMethodOrder(
            IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> md,
            IDecodeContracts <Local, Parameter, Method, Field, Type> cd,
            FieldsDB <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> fieldsDB)
        {
            Contract.Requires(fieldsDB != null);

            this.md       = md;
            this.cd       = cd;
            this.fieldsDB = fieldsDB;
        }
Ejemplo n.º 4
0
 public ConstructorsFirstAndTheCallGraphMethodOrder(
     bool constructorsFirst,
     IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> md,
     IDecodeContracts <Local, Parameter, Method, Field, Type> cd,
     Set <string> underAnalysis,
     FieldsDB <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> fieldsDB,
     CancellationToken cancellationToken)
     : base(constructorsFirst, md, cd, underAnalysis, fieldsDB, cancellationToken)
 {
     this.constructors = new List <Method>();
 }
        public SharedPostConditionManagerInfo(IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> metadataDecoder, FieldsDB <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> fieldDB)
        {
            Contract.Requires(metadataDecoder != null);
            Contract.Requires(fieldDB != null);

            this.metadataDecoder                  = metadataDecoder;
            this.FieldDB                          = fieldDB;
            this.nnFieldsAtMethodExitPoint        = new Dictionary <Method, IEnumerable <Tuple <Field, BoxedExpression> > >();
            this.analyzedConstructors             = new Dictionary <Type, Set <Method> >();
            this.completeTypes                    = new Set <Type>();
            this.typesWeSuggestedNonNullFields    = new Set <Type>();
            this.typesWeSuggestedObjectInvariants = new Set <Type>();
        }
Ejemplo n.º 6
0
 public CallGraphOrder(
     bool constructorsFirst,
     IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> md,
     IDecodeContracts <Local, Parameter, Method, Field, Type> cd,
     Set <string> underAnalysis,
     FieldsDB <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> fieldsDB,
     CancellationToken cancellationToken)
     : base(md, cd, fieldsDB)
 {
     this.constructorsFirst       = constructorsFirst;
     this.callGraph               = new SingleEdgeGraph <Node, Unit>(null, new Node.EqualityComparer(md));
     this.assembliesUnderAnalysis = underAnalysis;
     this.contractConsumer        = new ContractConsumer(this);
     this.cancellationToken       = cancellationToken;
 }
        GetCandidatePostconditionsForAutoProperties <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>
            (IEnumerable <BoxedExpression> boxedExpressions, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdd,
            FieldsDB <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> fieldsDB)
        {
            var result = new List <Tuple <Method, BoxedExpression.AssertExpression, Provenance> >();

            if (boxedExpressions != null)
            {
                foreach (var post in boxedExpressions.Where(exp => { return(exp.IsBinary); }))
                {
                    Contract.Assume(post != null);

                    BoxedExpression exp;
                    if (post.IsCheckExpNotNotNull(out exp))
                    {
                        var path = exp.AccessPath;
                        if (path != null)
                        {
                            Method m;
                            if (path[0].ToString() == "this" && path[path.Length - 1].IsMethodCall && path[path.Length - 1].TryMethod(out m) && mdd.IsAutoPropertyMember(m))
                            {
                                Method setter;
                                if (mdd.TryGetSetterFromGetter(m, out setter) && fieldsDB.IsCalledInANonConstructor(setter))
                                {
#if DEBUG
                                    Console.WriteLine("[INFERENCE] Skipping the inference of the postcondition '{0}' to an autoproperty because found it is set in a non-constructor", post);
#endif
                                    continue;
                                }

                                var t       = mdd.ReturnType(m);
                                var neqNull = BoxedExpression.Binary(BinaryOperator.Cne_Un, BoxedExpression.Result(t), BoxedExpression.Const(null, t, mdd));
#if DEBUG
                                Console.WriteLine("[INFERENCE] Propagating the postcondition '{0}' to the autoproperty", post);
#endif

                                var p = new BoxedExpression.AssertExpression(neqNull, "ensures", APC.Dummy, null, null);

                                result.Add(new Tuple <Method, BoxedExpression.AssertExpression, Provenance>(m, p, null));
                            }
                        }
                    }
                }
            }
            return(result);
        }