예제 #1
0
        /// <summary>
        /// Run analysis starting at EntryMethodGraph
        /// </summary>
        private void analyse()
        {
            EntryInput.CommitTransaction();

            ProgramPointGraph = ProgramPointGraph.FromSource(EntryCFG);
            _services.SetProgramEnd(ProgramPointGraph.End);
            _services.SetServices(ProgramPointGraph);

            var output = _services.CreateEmptySet();

            ProgramPointGraph.Start.Initialize(EntryInput, output);

            _services.EnqueueEntryPoint(ProgramPointGraph.Start, ProgramPointGraph.End);


            //fix point computation
            while (_workList.HasWork)
            {
                var point = _workList.GetWork();

                //during flow through are enqueued all needed flow children
                point.FlowThrough();
            }

            //because of avoid incorrect use
            //_services.UnSetServices(ProgramPointGraph);
        }
예제 #2
0
 /// <summary>
 /// Set services for all points in given graph
 /// </summary>
 /// <param name="ppGraph">Graph which program points will be set</param>
 internal void SetServices(ProgramPointGraph ppGraph)
 {
     foreach (var point in ppGraph.Points)
     {
         SetServices(point);
     }
 }
예제 #3
0
 /// <summary>
 /// Unset services for all points in given graph
 /// </summary>
 /// <param name="ppGraph">Graph which program points will be unset</param>
 internal void UnSetServices(ProgramPointGraph ppGraph)
 {
     foreach (var point in ppGraph.Points)
     {
         point.SetServices(null);
     }
 }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ForwardAnalysisBase" /> class.
        /// Create forward analysis object for given entry method graph.
        /// </summary>
        /// <param name="analyzedPPG">The analyzed PPG.</param>
        /// <param name="direction">The direction of analysis.</param>
        /// <param name="analyzer">The analyzer.</param>
        public NextPhaseAnalysis(ProgramPointGraph analyzedPPG, AnalysisDirection direction, NextPhaseAnalyzer analyzer)
        {
            _analyzer = analyzer;

            Direction = direction;
            AnalyzedProgramPointGraph = analyzedPPG;
            WideningLimit             = int.MaxValue;
        }
예제 #5
0
        internal ProgramPointBase GetExitPoint(ProgramPointGraph ppg)
        {
            switch (Direction)
            {
            case AnalysisDirection.Forward:
                return(ppg.End);

            case AnalysisDirection.Backward:
                return(ppg.Start);

            default:
                throwUnknownDirection();
                return(null);
            }
        }
예제 #6
0
        private void resetPoints(HashSet <ProgramPointGraph> processedGraphs, ProgramPointGraph ppg)
        {
            processedGraphs.Add(ppg);
            foreach (var point in ppg.Points)
            {
                point.ResetInitialization();

                foreach (var branch in point.Extension.Branches)
                {
                    branch.ResetInitialization();
                    point.Extension.Sink.ResetInitialization();
                    if (!processedGraphs.Contains(branch.Graph))
                    {
                        resetPoints(processedGraphs, branch.Graph);
                    }
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Add extension branch indexed by given key
        /// </summary>
        /// <param name="key">Key of added extension</param>
        /// <param name="ppGraph">Extending program point graph</param>
        /// <param name="type">Type of extension</param>
        /// <returns>Extension point which connect extending ppGraph with Owner</returns>
        internal ExtensionPoint Add(object key, ProgramPointGraph ppGraph, ExtensionType type)
        {
            if (!IsConnected)
            {
                connect();
            }

            ppGraph.Context._callers.Add(Owner);

            Owner.Services.SetServices(ppGraph);
            var extension = new ExtensionPoint(Owner, ppGraph, type);

            Owner.Services.SetServices(extension);

            _extensions.Add(key, extension);

            //connect ppGraph into current graph
            Owner.AddFlowChild(extension);
            extension.Graph.End.AddFlowChild(Sink);

            return(extension);
        }
예제 #8
0
 public override void VisitNativeAnalyzerValue(NativeAnalyzerValue value)
 {
     Output = ProgramPointGraph.FromNative(value.Analyzer);
 }
예제 #9
0
 public override void VisitSourceMethodValue(SourceMethodValue value)
 {
     Output = ProgramPointGraph.FromSource(value.Declaration, value.DeclaringScript);
 }
예제 #10
0
 internal void InitializeNewPoint(ProgramPointBase point, ProgramPointGraph owningGraph)
 {
     point.Initialize(Services.CreateEmptySet(), Services.CreateEmptySet());
     point.SetServices(Services);
     point.SetOwningGraph(owningGraph);
 }
예제 #11
0
 /// <summary>
 /// Add extension branch into Point
 /// </summary>
 /// <param name="branchKey">Key of added branch</param>
 /// <param name="ppGraph">Extending program point used as branch</param>
 /// <param name="type">Type of extension</param>
 public void AddExtension(object branchKey, ProgramPointGraph ppGraph, ExtensionType type)
 {
     CurrentProgramPoint.Extension.Add(branchKey, ppGraph, type);
 }
예제 #12
0
 /// <summary>
 /// Extend snapshot as a call to function/method callee from given callerContext
 /// </summary>
 /// <param name="callerContext">The caller context.</param>
 /// <param name="callee">Program point graph of the callee (identification of function or method that was called).</param>
 /// <param name="thisObject">The this object.</param>
 /// <param name="arguments">The arguments.</param>
 internal void ExtendAsCall(FlowOutputSet callerContext, ProgramPointGraph callee, MemoryEntry thisObject, MemoryEntry[] arguments)
 {
     Snapshot.ExtendAsCall(getSnapshot(callerContext), callee, thisObject, arguments);
 }
예제 #13
0
        /// <summary>
        /// Creates program point graph for given control flow graph
        /// </summary>
        /// <param name="cfg">Input control flow graph</param>
        /// <returns>Created program point graph</returns>
        public static ProgramPointGraph FromSource(ControlFlowGraph.ControlFlowGraph cfg)
        {
            var ppgraph = new ProgramPointGraph(cfg, null);

            return(ppgraph);
        }
예제 #14
0
 internal PPGraphContext(ProgramPointGraph owningPPGraph)
 {
     OwningPPGraph = owningPPGraph;
 }
예제 #15
0
 internal void SetOwningGraph(ProgramPointGraph owningGraph)
 {
     this.OwningPPGraph = owningGraph;
     this.Extension.Sink.OwningPPGraph = owningGraph;
 }
예제 #16
0
 /// <summary>
 /// Creates context that will be used by owningPPG to build itself
 /// </summary>
 /// <param name="owningPPG">Program point graph using context to build itself</param>
 internal PPGraphBuildingContext(ProgramPointGraph owningPPG)
 {
     _owningPPG = owningPPG;
 }