Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

JIfStmt.java

00001 package ca.mcgill.sable.soot.jimple;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Jimple, a 3-address code Java(TM) bytecode representation.        *
00005  * Copyright (C) 1997, 1998 Raja Vallee-Rai (kor@sable.mcgill.ca)    *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * Modifications by Patrick Lam (plam@sable.mcgill.ca) are           *
00009  * Copyright (C) 1999 Patrick Lam.  All rights reserved.             *
00010  *                                                                   *
00011  * This work was done as a project of the Sable Research Group,      *
00012  * School of Computer Science, McGill University, Canada             *
00013  * (http://www.sable.mcgill.ca/).  It is understood that any         *
00014  * modification not identified as such is not covered by the         *
00015  * preceding statement.                                              *
00016  *                                                                   *
00017  * This work is free software; you can redistribute it and/or        *
00018  * modify it under the terms of the GNU Library General Public       *
00019  * License as published by the Free Software Foundation; either      *
00020  * version 2 of the License, or (at your option) any later version.  *
00021  *                                                                   *
00022  * This work is distributed in the hope that it will be useful,      *
00023  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00025  * Library General Public License for more details.                  *
00026  *                                                                   *
00027  * You should have received a copy of the GNU Library General Public *
00028  * License along with this library; if not, write to the             *
00029  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00030  * Boston, MA  02111-1307, USA.                                      *
00031  *                                                                   *
00032  * Java is a trademark of Sun Microsystems, Inc.                     *
00033  *                                                                   *
00034  * To submit a bug report, send a comment, or get the latest news on *
00035  * this project and other Sable Research Group projects, please      *
00036  * visit the web site: http://www.sable.mcgill.ca/                   *
00037  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00038 
00039 /*
00040  Reference Version
00041  -----------------
00042  This is the latest official version on which this file is based.
00043  The reference version is: $SootVersion: 1.beta.4 $
00044 
00045  Change History
00046  --------------
00047  A) Notes:
00048 
00049  Please use the following template.  Most recent changes should
00050  appear at the top of the list.
00051 
00052  - Modified on [date (March 1, 1900)] by [name]. [(*) if appropriate]
00053    [description of modification].
00054 
00055  Any Modification flagged with "(*)" was done as a project of the
00056  Sable Research Group, School of Computer Science,
00057  McGill University, Canada (http://www.sable.mcgill.ca/).
00058 
00059  You should add your copyright, using the following template, at
00060  the top of this file, along with other copyrights.
00061 
00062  *                                                                   *
00063  * Modifications by [name] are                                       *
00064  * Copyright (C) [year(s)] [your name (or company)].  All rights     *
00065  * reserved.                                                         *
00066  *                                                                   *
00067 
00068  B) Changes:
00069 
00070  - Modified on February 3, 1999 by Patrick Lam (plam@sable.mcgill.ca) (*)
00071    Added changes in support of the Grimp intermediate
00072    representation (with aggregated-expressions).
00073 
00074  - Modified on November 2, 1998 by Raja Vallee-Rai (kor@sable.mcgill.ca) (*)
00075    Repackaged all source files and performed extensive modifications.
00076    First initial release of Soot.
00077 
00078  - Modified on 15-Jun-1998 by Raja Vallee-Rai (kor@sable.mcgill.ca). (*)
00079    First internal release (Version 0.1).
00080 */
00081 
00082 import ca.mcgill.sable.soot.*;
00083 import ca.mcgill.sable.util.*;
00084 
00085 public class JIfStmt extends AbstractStmt implements IfStmt
00086 {
00087     ValueBox conditionBox;
00088     UnitBox targetBox;
00089 
00090     List targetBoxes;
00091 
00092     JIfStmt(Value condition, Unit target)
00093     {
00094         this(Jimple.v().newConditionExprBox(condition),
00095          Jimple.v().newStmtBox(target));
00096     }
00097     protected JIfStmt(ValueBox conditionBox, UnitBox targetBox)
00098     {
00099         this.conditionBox = conditionBox;
00100         this.targetBox = targetBox;
00101 
00102         targetBoxes = new ArrayList();
00103         targetBoxes.add(this.targetBox);
00104         targetBoxes = Collections.unmodifiableList(targetBoxes);
00105     }
00106     public void apply(Switch sw)
00107     {
00108         ((StmtSwitch) sw).caseIfStmt(this);
00109     }
00110     public Value getCondition()
00111     {
00112         return conditionBox.getValue();
00113     }
00114     public ValueBox getConditionBox()
00115     {
00116         return conditionBox;
00117     }
00118     public List getDefBoxes()
00119     {
00120         return emptyList;
00121     }
00122     public Stmt getTarget()
00123     {
00124         return (Stmt) targetBox.getUnit();
00125     }
00126     public UnitBox getTargetBox()
00127     {
00128         return targetBox;
00129     }
00130     public List getUnitBoxes()
00131     {
00132         return targetBoxes;
00133     }
00134     public List getUseBoxes()
00135     {
00136         List useBoxes = new ArrayList();
00137 
00138         useBoxes.addAll(conditionBox.getValue().getUseBoxes());
00139         useBoxes.add(conditionBox);
00140 
00141         return useBoxes;
00142     }
00143     public void setCondition(Value condition)
00144     {
00145         conditionBox.setValue(condition);
00146     }
00147     public void setTarget(Unit target)
00148     {
00149         targetBox.setUnit(target);
00150     }
00151     public String toString()
00152     {
00153         return "if " + conditionBox.getValue().toString() + " goto ?";
00154     }
00155     protected String toString(boolean isBrief, Map stmtToName, String indentation)
00156     {
00157         if(isBrief)
00158             return indentation + "if " + 
00159                 ((ToBriefString) getCondition()).toBriefString() + " goto " + (String) stmtToName.get(getTarget());
00160         else
00161             return indentation + "if " + getCondition().toString() + " goto " + (String) stmtToName.get(getTarget());
00162     }
00163 }

Generated at Thu Feb 7 06:48:23 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001