Exemplo n.º 1
0
                public bool TryRetrievePreAndPostPartitions(
                    APC pc,
                    BoxedVariable <Variable> array,
                    out Pair <IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression>, IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> > partitions)
                {
                    SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> prePartitions;
                    SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> postPartitions;

                    if (this.partitions.TryPartitionAt(pc, out prePartitions))
                    {
                        IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> prePartition;
                        if (prePartitions.TryGetValue(array, out prePartition))
                        {
                            if (this.partitions.TryPartitionAt(this.Context.Post(pc), out postPartitions))
                            {
                                IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> postPartition;

                                if (postPartitions.TryGetValue(array, out postPartition))
                                {
                                    partitions = new Pair <IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression>, IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> >(prePartition, postPartition);
                                    return(true);
                                }
                            }
                        }
                    }

                    partitions = default(Pair <IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression>, IPartitionAbstraction <BoxedVariable <Variable>, BoxedExpression> >);
                    return(false);
                }
Exemplo n.º 2
0
                public bool LookupState(IMethodResult <Variable> mr, APC pc, out SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate)
                {
                    astate = null;
                    PartitionAnalysis an = mr as PartitionAnalysis;

                    if (an == null)
                    {
                        return(false);
                    }

                    return(an.PreStateLookup(pc, out astate));
                }
Exemplo n.º 3
0
                public bool AssignInParallel(IMethodResult <Variable> mr, ref SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate, Dictionary <BoxedVariable <Variable>, FList <BoxedVariable <Variable> > > mapping, Converter <BoxedVariable <Variable>, BoxedExpression> convert)
                {
                    PartitionAnalysis an = mr as PartitionAnalysis;

                    if (an == null)
                    {
                        return(false);
                    }

                    astate.AssignInParallel(mapping, convert);
                    return(true);
                }
Exemplo n.º 4
0
 internal ContainerAnalysis(
     string methodName,
     IMethodDriver <APC, Local, Parameter, Method, Field, Property, Type, Attribute, Assembly, ExternalExpression, Variable, ILogOptions> mdriver,
     PartitionAnalysis partitions,
     List <Analyzers.Containers.ContainerOptions> optionsList)
     : base(methodName, mdriver, optionsList[0])
 {
     // TODO : we can imagine that the analysis used to handle indexes is choose wrt optionsList.
     //this.indexesAnalysis = new NumericalAnalysis<Options>(this.MethodName, this.MethodDriver, new List<Analyzers.Bounds.BoundsOptions>());
     this.indexesAnalysis = new NumericalAnalysis <Analyzers.Containers.ContainerOptions>(this.MethodName, this.MethodDriver, optionsList);
     this.partitions      = partitions;
     this.obligations     = new ContainersObligations(mdriver, optionsList[0]);
 }
Exemplo n.º 5
0
                public SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> Join(IMethodResult <Variable> mr, SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate1, SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate2)
                {
                    PartitionAnalysis an = mr as PartitionAnalysis;

                    if (an == null)
                    {
                        return(null);
                    }

                    bool bWeaker;

                    return(an.Join(new Pair <APC, APC>(), astate1, astate2, out bWeaker, false));
                }
Exemplo n.º 6
0
                public List <BoxedExpression> ExtractAssertions(
                    IMethodResult <Variable> mr,
                    SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate,
                    IExpressionContext <APC, Local, Parameter, Method, Field, Type, ExternalExpression, Variable> context,
                    IDecodeMetaData <Local, Parameter, Method, Field, Property, Type, Attribute, Assembly> metaDataDecoder)
                {
                    PartitionAnalysis an = mr as PartitionAnalysis;

                    if (an == null)
                    {
                        return(null);
                    }

                    BoxedExpressionReader <APC, Local, Parameter, Method, Field, Property, Type, Variable, ExternalExpression, Attribute, Assembly> br = new BoxedExpressionReader <APC, Local, Parameter, Method, Field, Property, Type, Variable, ExternalExpression, Attribute, Assembly>(context, metaDataDecoder);

                    return(an.ToListOfBoxedExpressions(astate, br));
                }
Exemplo n.º 7
0
            HelperForPartitionAnalysis(string methodName,
                                       IMethodDriver <APC, Local, Parameter, Method, Field, Property, Type, Attribute, Assembly, ExternalExpression, Variable, ILogOptions> driver,
                                       List <Analyzers.Containers.ContainerOptions> optionsList,
                                       IFactQuery <BoxedExpression, Variable> factQuery)
            {
                PartitionAnalysis analysis;

                analysis = new PartitionAnalysis(methodName, driver, optionsList, factQuery);

                // *** The next lines must be strictly sequential ***
                var closure = driver.CreateForward <SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> >(analysis);

                // At this point, CreateForward has called the Visitor, so the context has been created, so that now we can call initValue

                SimplePartitionAbstractDomain <BoxedVariable <Variable>, BoxedExpression> .Trace = optionsList[0].TracePartitionAnalysis;

                var initValue = analysis.InitialValue;

                closure(initValue); // Do the analysis

                return(analysis);
            }