001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
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: /*
021: * Modified by the Sable Research Group and others 1997-1999.
022: * See the 'credits' file distributed with Soot for the complete list of
023: * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
024: */
025:
026: package soot.baf.internal;
027:
028: import soot.*;
029: import soot.jimple.*;
030: import soot.baf.*;
031: import soot.util.*;
032: import java.util.*;
033:
034: public class BIncInst extends AbstractInst implements IncInst {
035: ValueBox localBox;
036: ValueBox defLocalBox;
037: List useBoxes;
038: Constant mConstant;
039: List mDefBoxes;
040:
041: public BIncInst(Local local, Constant constant) {
042: mConstant = constant;
043:
044: localBox = new BafLocalBox(local);
045:
046: useBoxes = new ArrayList();
047: useBoxes.add(localBox);
048: useBoxes = Collections.unmodifiableList(useBoxes);
049:
050: defLocalBox = new BafLocalBox(local);
051:
052: //((LinkedBafLocalBox) defLocalBox).setOtherBox(localBox);
053: //((LinkedBafLocalBox) localBox).setOtherBox(defLocalBox);
054:
055: mDefBoxes = new ArrayList();
056: mDefBoxes.add(defLocalBox);
057: mDefBoxes = Collections.unmodifiableList(mDefBoxes);
058:
059: }
060:
061: public int getInCount() {
062: return 0;
063: }
064:
065: public Object clone() {
066: return new BIncInst(getLocal(), getConstant());
067: }
068:
069: public int getInMachineCount() {
070: return 0;
071: }
072:
073: public int getOutCount() {
074: return 0;
075: }
076:
077: public int getOutMachineCount() {
078: return 0;
079: }
080:
081: public Constant getConstant() {
082: return mConstant;
083: }
084:
085: public void setConstant(Constant aConstant) {
086: mConstant = aConstant;
087: }
088:
089: final public String getName() {
090: return "inc.i";
091: }
092:
093: final String getParameters() {
094: return " " + localBox.getValue().toString();
095: }
096:
097: protected void getParameters(UnitPrinter up) {
098: up.literal(" ");
099: localBox.toString(up);
100: }
101:
102: public void apply(Switch sw) {
103: ((InstSwitch) sw).caseIncInst(this );
104: }
105:
106: public void setLocal(Local l) {
107: localBox.setValue(l);
108: }
109:
110: public Local getLocal() {
111: return (Local) localBox.getValue();
112: }
113:
114: public List getUseBoxes() {
115: return useBoxes;
116: }
117:
118: public List getDefBoxes() {
119: return mDefBoxes;
120: }
121:
122: public String toString() {
123: return "inc.i" + " " + getLocal() + " " + getConstant();
124: }
125:
126: public void toString(UnitPrinter up) {
127: up.literal("inc.i");
128: up.literal(" ");
129: localBox.toString(up);
130: up.literal(" ");
131: up.constant(mConstant);
132: }
133:
134: }
|