Esempio n. 1
0
            public void EndAnalysis()
            {
                if (RemoveInferredPreconditions)
                {
                    // we are done validating the inferred preconditions, so we can remove them from the method cache
                    specializedParent.RemoveInferredPrecondition(this.method);
                }
                else
                {
                    specializedParent.InstallPreconditions(this.inferredPreconditions, this.method);
                }
                specializedParent.InstallPostconditions(this.inferredPostconditions, this.method);

                // Let's add the witness
                specializedParent.MethodCache.AddWitness(this.method, this.MayReturnNull);

                // Install postconditons for other methods
                if (otherPostconditions != null)
                {
                    foreach (var tuple in otherPostconditions.GroupBy(t => t.Item1))
                    {
                        Contract.Assume(tuple.Any());
                        specializedParent.InstallPostconditions(tuple.Select(t => t.Item2).ToList(), tuple.First().Item1);
                    }
                }

                if (classDriver != null)
                {
                    var methodThis = this.MetaDataDecoder.This(this.method);
                    classDriver.InstallInvariantsAsConstructorPostconditions(methodThis, this.inferredObjectInvariants, this.method);

                    // Really install object invariants. TODO: readonly fields only
                    // Missing something... how do I build a Contract.Invariant(...)?

                    var asAssume = this.inferredObjectInvariants.Select(be => (new BoxedExpression.AssumeExpression(be.One, "invariant", this.CFG.EntryAfterRequires, be.Two, be.One.ToString <Type>(type => OutputPrettyCS.TypeHelper.TypeFullName(this.MetaDataDecoder, type))))).Cast <BoxedExpression>();
                    specializedParent.InstallObjectInvariants(asAssume.ToList(), classDriver.ClassType);
                }
            }