00001 package edu.ksu.cis.bandera.pdgslicer; 00002 00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00004 * Bandera, a Java(TM) analysis and transformation toolkit * 00005 * Copyright (C) 1998, 1999 Hongjun Zheng (zheng@cis.ksu.edu) * 00006 * All rights reserved. * 00007 * * 00008 * This work was done as a project in the SAnToS Laboratory, * 00009 * Department of Computing and Information Sciences, Kansas State * 00010 * University, USA (http://www.cis.ksu.edu/santos). * 00011 * It is understood that any modification not identified as such is * 00012 * not covered by the preceding statement. * 00013 * * 00014 * This work is free software; you can redistribute it and/or * 00015 * modify it under the terms of the GNU Library General Public * 00016 * License as published by the Free Software Foundation; either * 00017 * version 2 of the License, or (at your option) any later version. * 00018 * * 00019 * This work is distributed in the hope that it will be useful, * 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this toolkit; if not, write to the * 00026 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * 00027 * Boston, MA 02111-1307, USA. * 00028 * * 00029 * Java is a trademark of Sun Microsystems, Inc. * 00030 * * 00031 * To submit a bug report, send a comment, or get the latest news on * 00032 * this project and other SAnToS projects, please visit the web-site * 00033 * http://www.cis.ksu.edu/santos * 00034 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00035 00036 import ca.mcgill.sable.soot.jimple.Stmt; 00037 import ca.mcgill.sable.util.*; 00038 /** 00039 * This class is for storing information about statement on which 00040 * other statements are data and interference dependent. 00041 */ 00042 public class DataBox { 00043 /** 00044 * The statement of interference dependent. 00045 */ 00046 private Stmt interStmt; //this is for interference statement 00047 /** 00048 * The statement of data dependent. 00049 */ 00050 private Stmt onstmt; 00051 /** 00052 * A set of {@link Value Value} on which other statements are 00053 * dependent. 00054 */ 00055 private Set var; 00056 private boolean isInvokeInit; 00057 private boolean isNewExprStmt; 00058 /** 00059 * Constructor of {@link DataBox DataBox}. 00060 * Initializing both <code>isInvokeInit</code> and <code>isNewExprStmt</code> 00061 * to <code>false</code>. 00062 * <p> 00063 * @param stmt the statement on which other statements are dependent. 00064 * @param data a set of value on which other statements are dependent. 00065 */ 00066 public DataBox(Stmt stmt, Set data) { 00067 onstmt = stmt; 00068 interStmt = stmt; 00069 var = data; 00070 isInvokeInit = false; 00071 isNewExprStmt = false; 00072 } 00073 public boolean equals(Object o) { 00074 DataBox ad = (DataBox) o; 00075 boolean stmtEq = false; 00076 /* 00077 if (this.interStmt != null) 00078 stmtEq = this.interStmt.equals(ad.getInterferStmt()); 00079 */ 00080 if (this.onstmt != null) 00081 stmtEq = this.onstmt.equals(ad.getStmt()); 00082 00083 00084 if (stmtEq){ 00085 this.var.addAll(ad.getDependVar()); 00086 //ad.var = new ArraySet(); 00087 //ad.var.addAll(this.var); 00088 } 00089 00090 return stmtEq; 00091 } 00092 /** 00093 * Get data dependent variables' value. 00094 * <p> 00095 * @return a set of {@link Value Value}. 00096 */ 00097 public Set getDependVar() { 00098 Set returnVar = new ArraySet(); 00099 returnVar.addAll(var); 00100 return returnVar; 00101 } 00102 /** 00103 * Get interference dependent statement. 00104 * <p> 00105 * @return {@link #interStmt interStmt}. 00106 */ 00107 public Stmt getInterferStmt() 00108 { 00109 return interStmt; 00110 } 00111 /** 00112 * Get interference variables' value. 00113 * <p> 00114 * @return a set of {@link Value Value}. 00115 */ 00116 public Set getInterferVars() { 00117 Set returnVar = new ArraySet(); 00118 returnVar.addAll(var); 00119 return returnVar; 00120 } 00121 /** 00122 * Get data dependent statement. 00123 * <p> 00124 * @return {@link #onstmt onstmt}. 00125 */ 00126 public Stmt getStmt() { 00127 return onstmt; 00128 } 00129 /** 00130 * See if the statatement involed in this <code>DataBox</code> is 00131 * new expression statement. 00132 * <p> 00133 * @return {@link #isNewExprStmt isNewExprStmt}. 00134 */ 00135 public boolean isNewExprStmt() 00136 { 00137 return isNewExprStmt; 00138 } 00139 /** 00140 * See if the statatement involed in this <code>DataBox</code> is 00141 * special invoke init method statement. 00142 * <p> 00143 * @return {@link #isInvokeInit isInvokeInit}. 00144 */ 00145 public boolean isSpecialInvokeInit() 00146 { 00147 return isInvokeInit; 00148 } 00149 /** 00150 * Set <code>isInvokeInit</code> to <code>true</code>. 00151 */ 00152 public void setToInvokeInit() 00153 { 00154 isInvokeInit = true; 00155 } 00156 /** 00157 * Set <code>isNewExprStmt</code> to <code>true</code>. 00158 */ 00159 public void setToNewExprStmt() 00160 { 00161 isNewExprStmt = true; 00162 } 00163 public String toString() 00164 { 00165 if (onstmt != null) 00166 return "dataBox {" + onstmt + "," + var + "}"; 00167 else 00168 return "dataBox {" + interStmt + "," + var + "}"; 00169 } 00170 }