Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright (C) 2015 The Pennsylvania State University and the University of Wisconsin
   * Systems and Internet Infrastructure Security Laboratory
   * Author: Damien Octeau
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
 package edu.psu.cse.siis.coal.arguments;
 import java.util.List;
 import java.util.Set;
 import soot.Local;
 import soot.Unit;
An abstract backward argument value analysis, which provides utility functions.
 public abstract class BackwardValueAnalysis implements ArgumentValueAnalysis {
   private final Logger logger = LoggerFactory.getLogger(getClass());

Returns all assignments for a local variable. This walks the interprocedural control flow graph back from a statement looking for all assignments to a given local variable.

start The statement where the analysis should start.
local The local variable whose assignments should be found.
init A boolean that indicates whether the analysis should be initialized. This should always be true for non-recursive calls.
visitedUnits The set of statements visited by the analysis.
The set of assignment statements for the local variable.
   protected List<DefinitionStmtfindAssignmentsForLocal(Unit startLocal localboolean init,
       Set<Pair<UnitLocal>> visitedUnits) {
     if (.isDebugEnabled()) {
       .debug("Finding assignments for local " + local);
     SootMethod method = AnalysisParameters.v().getIcfg().getMethodOf(start);
     ExceptionalUnitGraph graph = new ExceptionalUnitGraph(method.getActiveBody());
     List<DefinitionStmtresult = new ArrayList<DefinitionStmt>();
     Stack<Unitstack = new Stack<Unit>();
     if (init) {
     while (!stack.empty()) {
       Unit current = stack.pop();
       if (.isDebugEnabled()) {
         .debug(current + " " + current.getClass());
       Pair<UnitLocalpair = new Pair<UnitLocal>(currentlocal);
       if (visitedUnits.contains(pair)) {
       if (current instanceof IdentityStmt) {
         IdentityStmt identityStmt = (IdentityStmtcurrent;
         // method.
         if (identityStmt.getLeftOp().equivTo(local)) {
       } else if (current instanceof AssignStmt) {
         AssignStmt assignStmt = (AssignStmtcurrent;
         if (assignStmt.getLeftOp().equivTo(local)) {
           if (assignStmt.getRightOp() instanceof Local) {
             result.addAll(findAssignmentsForLocal(current, (LocalassignStmt.getRightOp(), false,
           } else {
           // The assignment generates the local on that path.
           // Anything before is irrelevant.
      for (Unit pred : graph.getPredsOf(current)) {
    return result;
New to GrepCode? Check out our FAQ X