All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.wala.demandpa.flowgraph.IFlowGraph Maven / Gradle / Ivy

/*
 * Copyright (c) 2007 IBM Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 */
package com.ibm.wala.demandpa.flowgraph;

import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IField;
import com.ibm.wala.demandpa.flowgraph.IFlowLabel.IFlowLabelVisitor;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.propagation.LocalPointerKey;
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ipa.callgraph.propagation.StaticFieldKey;
import com.ibm.wala.ipa.callgraph.propagation.cfa.CallerSiteContext;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.util.graph.labeled.LabeledGraph;
import java.util.Iterator;
import java.util.Set;

public interface IFlowGraph extends LabeledGraph {

  /** Apply a visitor to the successors of some node. */
  void visitSuccs(Object node, IFlowLabelVisitor v);

  /** Apply a visitor to the predecessors of some node. */
  void visitPreds(Object node, IFlowLabelVisitor v);

  /**
   * add representation of flow for a node, if not already present
   *
   * @throws IllegalArgumentException if node == null
   */
  void addSubgraphForNode(CGNode node) throws IllegalArgumentException;

  boolean hasSubgraphForNode(CGNode node);

  /**
   * @return {@code true} iff {@code pk} is a formal parameter
   */
  boolean isParam(LocalPointerKey pk);

  /**
   * @return the {@link SSAInvokeInstruction}s passing some pointer as a parameter
   */
  Iterator getInstrsPassingParam(LocalPointerKey pk);

  /**
   * get the {@link SSAInvokeInstruction} whose return value is assigned to a pointer key.
   *
   * @return the instruction, or {@code null} if no return value is assigned to pk
   */
  SSAAbstractInvokeInstruction getInstrReturningTo(LocalPointerKey pk);

  /**
   * @param sfk the static field
   * @return all the variables whose values are written to sfk
   * @throws IllegalArgumentException if sfk == null
   */
  Iterator getWritesToStaticField(StaticFieldKey sfk)
      throws IllegalArgumentException;

  /**
   * @param sfk the static field
   * @return all the variables that get the value of sfk
   * @throws IllegalArgumentException if sfk == null
   */
  Iterator getReadsOfStaticField(StaticFieldKey sfk)
      throws IllegalArgumentException;

  Iterator getWritesToInstanceField(PointerKey pk, IField f);

  Iterator getReadsOfInstanceField(PointerKey pk, IField f);

  /**
   * @param formalPk a {@link PointerKey} representing either a formal parameter or return value
   * @return the {@link CallerSiteContext}s representing pointer callers of {@code formalPk}'s
   *     method
   */
  Set getPotentialCallers(PointerKey formalPk);

  /**
   * get the callees that should be considered at a particular call site
   *
   * @param caller the caller
   * @param site the call site
   * @param actualPk a {@link LocalPointerKey} corresponding to the actual parameter or return value
   *     of interest. This may be used to filter out certain callees.
   * @return the callees of interest
   */
  Set getPossibleTargets(CGNode caller, CallSiteReference site, LocalPointerKey actualPk);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy