Example #1
0
                public bool LookupState(IMethodResult <Variable> mr, APC pc, out SimpleStringAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate)
                {
                    astate = null;
                    StringValueAnalysis an = mr as StringValueAnalysis;

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

                    return(an.PreStateLookup(pc, out astate));
                }
Example #2
0
                public bool AssignInParallel(IMethodResult <Variable> mr, ref SimpleStringAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate, Dictionary <BoxedVariable <Variable>, FList <BoxedVariable <Variable> > > mapping, Converter <BoxedVariable <Variable>, BoxedExpression> convert)
                {
                    StringValueAnalysis an = mr as StringValueAnalysis;

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

                    astate.AssignInParallel(mapping, convert);
                    return(true);
                }
Example #3
0
                public SimpleStringAbstractDomain <BoxedVariable <Variable>, BoxedExpression> Join(IMethodResult <Variable> mr, SimpleStringAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate1, SimpleStringAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate2)
                {
                    StringValueAnalysis an = mr as StringValueAnalysis;

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

                    bool bWeaker;

                    return(an.Join(new Pair <APC, APC>(), astate1, astate2, out bWeaker, false));
                }
Example #4
0
                public List <BoxedExpression> ExtractAssertions(
                    IMethodResult <Variable> mr,
                    SimpleStringAbstractDomain <BoxedVariable <Variable>, BoxedExpression> astate,
                    IExpressionContext <Local, Parameter, Method, Field, Type, Expression, Variable> context,
                    IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> metaDataDecoder)
                {
                    StringValueAnalysis an = mr as StringValueAnalysis;

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

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

                    return(an.ToListOfBoxedExpressions(astate, br));
                }
            /// <summary>
            /// It runs the analysis.
            /// It is there because so we can use the typebinding, and make the code less verbose
            /// </summary>
            internal static IMethodResult <Variable> HelperForStringAnalysis(string methodName,
                                                                             IMethodDriver <APC, Local, Parameter, Method, Field, Property, Type, Attribute, Assembly, ExternalExpression, Variable, ILogOptions> driver, IValueAnalysisOptions options)
            {
                StringValueAnalysis analysis;

                analysis = new StringValueAnalysis(methodName, driver, options);

                // *** The next lines must be strictly sequential ***
                Action <SimpleStringAbstractDomain <BoxedExpression> > closure = driver.CreateForward <SimpleStringAbstractDomain <BoxedExpression> >(analysis);

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

                SimpleStringAbstractDomain <BoxedExpression> initValue = analysis.InitialValue;

                closure(initValue); // Do the analysis

                return(analysis);
            }
Example #6
0
            /// <summary>
            /// It runs the analysis.
            /// It is there because so we can use the typebinding, and make the code less verbose
            /// </summary>
            internal static IMethodResult <Variable> HelperForStringAnalysis
            (
                string methodName,
                IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, ILogOptions> driver,
                IValueAnalysisOptions options,
                Predicate <APC> cachePCs, DFAController controller
            )
            {
                var analysis = new StringValueAnalysis(methodName, driver, options, cachePCs);

                var closure = driver.HybridLayer.CreateForward(analysis, new DFAOptions {
                    Trace = false
                }, controller);

                closure(analysis.GetTopValue()); // Do the analysis

                return(analysis);
            }