Exemple #1
0
 /** Transfer ordinary and exceptional return for the given call node and callee entry. */
 public void transferReturn(
     AbstractNode call_node,
     BasicBlock callee_entry,
     Context caller_context,
     Context callee_context,
     Context edge_context) {
   if (call_node instanceof BeginForInNode) {
     for (EndForInNode endNode : ((BeginForInNode) call_node).getEndNodes()) {
       BasicBlock end_block = endNode.getBlock();
       if (c.getAnalysisLatticeElement().getState(end_block, callee_context)
           != null) // (EndForInNode uses same context as corresponding BeginForInNode)
       c.addToWorklist(end_block, callee_context);
     }
   } else { // call_node is an ordinary call node
     Function callee = callee_entry.getFunction();
     BasicBlock ordinary_exit = callee.getOrdinaryExit();
     BasicBlock exceptional_exit = callee.getExceptionalExit();
     State ordinary_exit_state =
         c.getAnalysisLatticeElement()
             .getState(
                 ordinary_exit,
                 callee_context); // (ReturnNode uses same context as corresponding function entry
     // node)
     State exceptional_exit_state =
         c.getAnalysisLatticeElement().getState(exceptional_exit, callee_context);
     NodeAndContext<Context> caller = new NodeAndContext<>(call_node, caller_context);
     if (ordinary_exit_state != null) {
       if (ordinary_exit.getFirstNode() instanceof ReturnNode) {
         ReturnNode returnNode = (ReturnNode) ordinary_exit.getFirstNode();
         transferReturn(
             returnNode.getReturnValueRegister(),
             ordinary_exit,
             ordinary_exit_state.clone(),
             caller,
             edge_context);
       } else throw new AnalysisException("ReturnNode expected");
     }
     if (exceptional_exit_state != null) {
       transferExceptionalReturn(
           exceptional_exit, exceptional_exit_state.clone(), caller, edge_context);
     }
   }
 }