예제 #1
0
        private HashSet <VariableDescriptor> GetControlDependencyVariables(string proc, Block b)
        {
            // This method works under the assumption that assume statements
            // relevant to control flow between basic blocks have the "partition" attribute

            HashSet <VariableDescriptor> result = new HashSet <VariableDescriptor>();
            var gotoCmd = b.TransferCmd as GotoCmd;

            if (gotoCmd != null && gotoCmd.labelTargets.Count >= 2)
            {
                foreach (Block succ in gotoCmd.labelTargets)
                {
                    foreach (Cmd c in succ.Cmds)
                    {
                        AssumeCmd a = c as AssumeCmd;
                        if (a != null && QKeyValue.FindBoolAttribute(a.Attributes, "partition"))
                        {
                            var VarCollector = new VariableCollector();
                            VarCollector.VisitExpr(a.Expr);
                            result.UnionWith(VarCollector.usedVars.Where(Item => VariableRelevantToAnalysis(Item, proc)).
                                             Select(Item => MakeDescriptor(proc, Item)));
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return(result);
        }
예제 #2
0
        private void AddDependences(AnnotationInstance ci)
        {
            VariableCollector vc = new VariableCollector();

            vc.VisitExpr(ci.Expr);

            foreach (var v in vc.usedVars.Where(Item => varDepAnalyser.VariableRelevantToAnalysis(Item, ci.Proc)))
            {
                VariableDescriptor vd =
                    varDepAnalyser.MakeDescriptor(ci.Proc, v);
                if (!variableDirectlyReferredToByAnnotations.ContainsKey(vd))
                {
                    variableDirectlyReferredToByAnnotations[vd] = new HashSet <string>();
                }
                variableDirectlyReferredToByAnnotations[vd].Add(ci.AnnotationIdentifier);

                foreach (var w in varDepAnalyser.DependsOn(vd))
                {
                    annotationDependsOn[ci.AnnotationIdentifier].Add(w);
                }
            }
        }
        private void AddDependences(CandidateInstance ci)
        {
            VariableCollector vc = new VariableCollector();
              vc.VisitExpr(ci.Expr);

              foreach (var v in vc.usedVars.Where(Item => varDepAnalyser.VariableRelevantToAnalysis(Item, ci.Proc))) {
            VariableDescriptor vd =
              varDepAnalyser.MakeDescriptor(ci.Proc, v);
            if (!variableDirectlyReferredToByCandidates.ContainsKey(vd)) {
              variableDirectlyReferredToByCandidates[vd] = new HashSet<string>();
            }
            variableDirectlyReferredToByCandidates[vd].Add(ci.Candidate);

            foreach (var w in varDepAnalyser.DependsOn(vd)) {
              candidateDependsOn[ci.Candidate].Add(w);
            }
              }
        }