Control Flow Analysis.
422300
ControlFlowGraph<Node> computeCFG() {
    logger.fine("Computing Control Flow Graph");
    Tracer tracer = newTracer("computeCFG");
    ControlFlowAnalysis cfa = new ControlFlowAnalysis(this, true, false);
    process(cfa);
    stopTracer(tracer, "computeCFG");
    return cfa.getCfg();
  }
1093759
public void analyze(Analyzer analyzer, boolean allowFlow)
    throws Exception
  {
    _pendingTargets = new IntArray();
    _completedTargets = new IntArray();
    
    analyzeImpl(analyzer, allowFlow, _pendingTargets, _completedTargets);
  }
174770
private boolean fastAllPathsReturnCheck(ControlFlowGraph<Node> cfg) {
    for (DiGraphEdge<Node, Branch> s : cfg.getImplicitReturn().getInEdges()) {
      Node n = s.getSource().getValue();
      // NOTE(dimvar): it is possible to change ControlFlowAnalysis.java, so
      // that the calls that always throw are treated in the same way as THROW
      // in the CFG. Then, we would not need to use the coding convention here.
      if (!n.isReturn() && !convention.isFunctionCallThatAlwaysThrows(n)) {
        return false;
      }
    }
    return true;
  }
250259
def extract_control_blocks(head, blocks, cfg)

      # Find the last control block, i.e. the block that has a successor that is not in the loop.
      last_control_block = nil
      blocks.each do |b|
        cfg.successors[b].each do |succ|
          next if blocks.include?(succ)
          # The last control block has to be unique.
          raise StandardError if last_control_block
          last_control_block = b
        end
      end

      # The control block's succesor that is not in the loop is the unique exit block.
      exit_block = cfg.successors[last_control_block].select{|b| !blocks.include?(b)}
      raise StandardError unless exit_block.size == 1

      # In the case of a simple control statement, the last control block is the head block
      # and there are no other control blocks.
      return [last_control_block], exit_block if last_control_block == head

      # If the loop has a complicated control statement, there will be multiple control
      # blocks. Identify them all the way up to the head block.
      work_list = [last_control_block]
      control_blocks = [last_control_block]
      until work_list.empty?
        cfg.predecessors[work_list.shift].each do |pred|
          next if control_blocks.include?(pred)
          next if pred == head && (control_blocks.push(pred) || true)
          control_blocks.push(pred)
          work_list |= [pred]
        end
      end

      return control_blocks, exit_block
    end
1054402
def _upstream_analysis(self, compile_contexts, classpath_entries):
    """"""
    # Reorganize the compile_contexts by class directory.
    compile_contexts_by_directory = {}
    for compile_context in compile_contexts.values():
      compile_context = self.select_runtime_context(compile_context)
      compile_contexts_by_directory[compile_context.classes_dir.path] = compile_context
    # If we have a compile context for the target, include it.
    for entry in classpath_entries:
      path = entry.path
      if not path.endswith('.jar'):
        compile_context = compile_contexts_by_directory.get(path)
        if not compile_context:
          self.context.log.debug('Missing upstream analysis for {}'.format(path))
        else:
          yield compile_context.classes_dir.path, compile_context.analysis_file
213599
function (o) {
      var pattern, state;
      /** @type {string[]} */
      var stateArray;
      var i;
      //
      // 1. Collect all states
      //
      /** @type {Transitions} */
      var transitions = {};
      for (pattern in o) {
        for (state in o[pattern]) {
          stateArray = state.split("|");
          o[pattern][state].stateArray = stateArray;
          for (i=0; i<stateArray.length; i++) {
            transitions[stateArray[i]] = [];
          }
        }
      }
      //
      // 2. Fill states
      //
      for (pattern in o) {
        for (state in o[pattern]) {
          stateArray = o[pattern][state].stateArray || [];
          for (i=0; i<stateArray.length; i++) {
            //
            // 2a. Normalize actions into array:  'text=' ==> [{type_:'text='}]
            // (Note to myself: Resolving the function here would be problematic. It would need .bind (for *this*) and currying (for *option*).)
            //
            /** @type {any} */
            var p = o[pattern][state];
            if (p.action_) {
              p.action_ = [].concat(p.action_);
              for (var k=0; k<p.action_.length; k++) {
                if (typeof p.action_[k] === "string") {
                  p.action_[k] = { type_: p.action_[k] };
                }
              }
            } else {
              p.action_ = [];
            }
            //
            // 2.b Multi-insert
            //
            var patternArray = pattern.split("|");
            for (var j=0; j<patternArray.length; j++) {
              if (stateArray[i] === '*') {  // insert into all
                for (var t in transitions) {
                  transitions[t].push({ pattern: patternArray[j], task: p });
                }
              } else {
                transitions[stateArray[i]].push({ pattern: patternArray[j], task: p });
              }
            }
          }
        }
      }
      return transitions;
    }
103159
private void analyseAdditionalStepImplementations(final Class<?> loadedClass, final Syntax syntax,
        final Class<?>[] additionalStepImplementationClasses) {
        for (final Class<?> stepImplClass : additionalStepImplementationClasses) {
            analyseClass(stepImplClass, syntax);
        }
    }
943177
public void compileProgram() {
		program.inputs().forEach(var -> var.calculateFuzzySpace());
		program.outputs().forEach(var -> var.calculateFuzzySpace());

		program.rules().forEach(rule -> {
			updateMemberReferenceCount(rule.getCondition());
			rule.assignmentMembers().forEach(member -> member.incrReferenceCount());
		});
	}
1160943
def handleFlow(self):
        
        #TODO replace sorting loops with sorted function
        self.targets = {}
        self.api = []
        #flow = []
        
        addrs = []
        internals = []
        
        for instr in self.bb_insns:
            if isinstance(instr, CallInsn):
                if instr.is_api:
                    self.targets[instr.addr] = "API:" + instr.fcn_name
                    
                    self.api.append({"name": instr.fcn_name})
                else:
                    internals.append(instr.addr)
                    
            else:
                if instr.jumpout:
                    internals.append(instr.addr)
                else:
                    addrs.append(instr.addr)
                    addrs.append(instr.offset)
        
        addrs.sort()
        addrs_dict = {}
        for i in range(len(addrs)):
            addrs_dict[addrs[i]] = i
        
        internals_sorted = internals[:]
        internals_sorted.sort()
        calleds_dict = {}
        for i in range(len(internals_sorted)):
            calleds_dict[internals_sorted[i]] = str(i)
            
        flowhash = datasketch.MinHash(num_perm=32)
        
        for instr in self.bb_insns:
            if isinstance(instr, CallInsn):
                if instr.is_api:
                    #flow.append(hex(instr.offset)+"  API:" + instr.fcn_name)
                    flowhash.update("API:" + instr.fcn_name)
                else:
                    #flow.append(hex(instr.offset)+"  OUT:" + calleds_dict[instr.addr])
                    flowhash.update("OUT:" + calleds_dict[instr.addr])
                    self.targets[instr.addr] = "OUT:" + calleds_dict[instr.addr]
            else:
                if instr.jumpout:
                    #flow.append(hex(instr.offset)+"  OUT:" + calleds_dict[instr.addr])
                    flowhash.update("OUT:" + calleds_dict[instr.addr])
                    self.targets[instr.addr] = "OUT:" + calleds_dict[instr.addr]
                else:
                    off = addrs_dict[instr.offset]
                    tgt = addrs_dict[instr.addr]
                    #flow.append("%x (%d)   JMP:%s   - %x (%d)" % (instr.offset, off, str(tgt - off), instr.addr, tgt))
                    flowhash.update("JMP:" + str(tgt - off))
                    self.targets[instr.addr] = "JMP:" + str(tgt - off)
        
        lean_flowhash = datasketch.LeanMinHash(flowhash)
        flowhash_buf = bytearray(lean_flowhash.bytesize())
        lean_flowhash.serialize(flowhash_buf)
        
        self.flowhash = str(flowhash_buf)
        '''
        
        '''
688990
def analyze(self, scratch, **kwargs):
        """"""
        file_blocks = Counter()
        for script in self.iter_scripts(scratch):
            for name, _, _ in self.iter_blocks(script.blocks):
                file_blocks[name] += 1
        self.blocks.update(file_blocks)  # Update the overall count
        return {'types': file_blocks}
1294857
def check(self, cfg, state, peek_blocks):
        

        # Get the current CFGNode
        node = self._get_cfg_node(cfg, state)

        if node is None:
            l.error("Failed to find CFGNode for state %s on the control flow graph.", state)
            return False

        # crawl the graph to see if we can reach the target function within the limited steps
        for src, dst in self._dfs_edges(cfg.graph, node, max_steps=peek_blocks):
            the_node = None
            if src.addr == self.function.addr:
                the_node = src
            elif dst.addr == self.function.addr:
                the_node = dst

            if the_node is not None:
                if self.arguments is None:
                    # we do not care about arguments
                    return True

                else:
                    # check arguments
                    arch = state.arch
                    state = the_node.input_state
                    same_arguments = self._check_arguments(arch, state)

                    if same_arguments:
                        # all arguments are the same!
                        return True

        l.debug("SimState %s will not reach function %s.", state, self.function)
        return False
285815
@Override
    public ConstantDataflow analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        MethodGen methodGen = getMethodGen(analysisCache, descriptor);
        if (methodGen == null) {
            return null;
        }
        ConstantAnalysis analysis = new ConstantAnalysis(methodGen, getDepthFirstSearch(analysisCache, descriptor));
        ConstantDataflow dataflow = new ConstantDataflow(getCFG(analysisCache, descriptor), analysis);
        dataflow.execute();

        return dataflow;
    }
1028120
function Flow(flowControlId) {
  Duplex.call(this, { objectMode: true });

  this._window = this._initialWindow = INITIAL_WINDOW_SIZE;
  this._flowControlId = flowControlId;
  this._queue = [];
  this._ended = false;
  this._received = 0;
  this._blocked = false;
}
51429
def _connect_control_flow_node(control_flow_node, next_node):
    """"""
    for last in control_flow_node.last_nodes:
        if isinstance(next_node, ControlFlowNode):
            last.connect(next_node.test)  # connect to next if test case
        elif isinstance(next_node, AssignmentCallNode):
            call_node = next_node.call_node
            inner_most_call_node = _get_inner_most_function_call(call_node)
            last.connect(inner_most_call_node)
        else:
            last.connect(next_node)
1135608
private void init() {

		handlers.put(FlowType.Action,   	new ActionHandler());
		handlers.put(FlowType.Decision, 	new DecisionHandler());
		handlers.put(FlowType.Return,   	new ReturnHandler());
		handlers.put(FlowType.ForEach,  	new ForEachHandler());
		handlers.put(FlowType.Store, 		new StoreHandler());
		handlers.put(FlowType.Aggregation,  new AggregationHandler());
		handlers.put(FlowType.Exception, 	new ExceptionHandler());
		handlers.put(FlowType.Filter,		new FilterHandler());
		handlers.put(FlowType.Fork,			new ForkHandler());
	}
36813
void robotMove(int nx, int ny)
    {
        oldX = x;
        oldY = y;
        x = nx;
        y = ny;
        wx = nx;
        wy = ny;
        mx = x - oldX;
        my = y - oldY;
        moved = true;
    }
372838
private boolean search(LinkedList<Control> list, Interaction inter)
	{
		if (list.getLast().getControlled().contains(inter)) return true;

		for (Process process : list.getLast().getControlled())
		{
			if (process instanceof Control)
			{
				// prevent searching in cycles
				if (list.contains(process)) continue;

				list.add((Control) process);
				if (search(list, inter)) return true;
				else list.removeLast();
			}
		}
		return false;
	}