001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 2005 Nomair A. Naeem
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: package soot.dava.toolkits.base.renamer;
021:
022: import java.util.*;
023: import soot.*;
024:
025: public class heuristicSet {
026: HashMap<Local, heuristicTuple> set;
027:
028: public heuristicSet() {
029: set = new HashMap<Local, heuristicTuple>();
030: }
031:
032: private heuristicTuple getTuple(Local var) {
033: return set.get(var);
034: }
035:
036: public void add(Local var, int bits) {
037: heuristicTuple temp = new heuristicTuple(bits);
038: set.put(var, temp);
039: }
040:
041: public void addCastString(Local var, String castString) {
042: heuristicTuple retrieved = getTuple(var);
043: retrieved.addCastString(castString);
044: }
045:
046: public List<String> getCastStrings(Local var) {
047: heuristicTuple retrieved = getTuple(var);
048: return retrieved.getCastStrings();
049: }
050:
051: public void setFieldName(Local var, String fieldName) {
052: heuristicTuple retrieved = getTuple(var);
053: retrieved.setFieldName(fieldName);
054: }
055:
056: public List<String> getFieldName(Local var) {
057: heuristicTuple retrieved = getTuple(var);
058: return retrieved.getFieldName();
059: }
060:
061: public void setObjectClassName(Local var, String objectClassName) {
062: heuristicTuple retrieved = getTuple(var);
063: retrieved.setObjectClassName(objectClassName);
064: }
065:
066: public List<String> getObjectClassName(Local var) {
067: heuristicTuple retrieved = getTuple(var);
068: return retrieved.getObjectClassName();
069: }
070:
071: public void setMethodName(Local var, String methodName) {
072: heuristicTuple retrieved = getTuple(var);
073: retrieved.setMethodName(methodName);
074: }
075:
076: public List<String> getMethodName(Local var) {
077: heuristicTuple retrieved = getTuple(var);
078: return retrieved.getMethodName();
079: }
080:
081: public void setHeuristic(Local var, int bitIndex) {
082: heuristicTuple retrieved = getTuple(var);
083: retrieved.setHeuristic(bitIndex);
084: }
085:
086: public boolean getHeuristic(Local var, int bitIndex) {
087: heuristicTuple retrieved = getTuple(var);
088: return retrieved.getHeuristic(bitIndex);
089: }
090:
091: public boolean isAnyHeuristicSet(Local var) {
092: heuristicTuple retrieved = getTuple(var);
093: return retrieved.isAnyHeuristicSet();
094: }
095:
096: public void print() {
097: Iterator<Local> it = set.keySet().iterator();
098: while (it.hasNext()) {
099: Object local = it.next();
100: heuristicTuple temp = set.get(local);
101: String tuple = temp.getPrint();
102: System.out.println(local + " " + tuple + " DefinedType: "
103: + ((Local) local).getType());
104: }
105: }
106:
107: public Iterator<Local> getLocalsIterator() {
108: return set.keySet().iterator();
109: }
110:
111: public boolean contains(Local var) {
112: if (set.get(var) != null)
113: return true;
114: else
115: return false;
116: }
117: }
|