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

Duplicator.java

00001 package edu.ksu.cis.bandera.birc;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998, 1999   James Corbett (corbett@hawaii.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 import edu.ksu.cis.bandera.bir.*;
00036 
00037 import ca.mcgill.sable.soot.*;
00038 
00039 public class Duplicator extends AbstractExprSwitch 
00040 {
00041     Object result;
00042 
00043     public void caseAddExpr(AddExpr expr)
00044     {
00045     expr.getOp1().apply(this);
00046     Expr op1 = (Expr) getResult();
00047     expr.getOp2().apply(this);
00048     Expr op2 = (Expr) getResult();
00049         setResult(new AddExpr(op1, op2));
00050     }
00051     public void caseAndExpr(AndExpr expr)
00052     {
00053     expr.getOp1().apply(this);
00054     Expr op1 = (Expr) getResult();
00055     expr.getOp2().apply(this);
00056     Expr op2 = (Expr) getResult();
00057         setResult(new AndExpr(op1, op2));
00058     }
00059     public void caseArrayExpr(ArrayExpr expr)
00060     {
00061     expr.getArray().apply(this);
00062     Expr op1 = (Expr) getResult();
00063     expr.getIndex().apply(this);
00064     Expr op2 = (Expr) getResult();
00065         setResult(new ArrayExpr(op1, op2));
00066     }
00067     public void caseAssignAction(AssignAction assign) 
00068     {
00069     assign.getLhs().apply(this);
00070     Expr lhs = (Expr) getResult();
00071     assign.getRhs().apply(this);
00072     Expr rhs = (Expr) getResult();
00073         setResult(new AssignAction(lhs, rhs));
00074     }
00075     public void caseBoolLit(BoolLit expr)
00076     {
00077         setResult(expr);
00078     }
00079     public void caseChooseExpr(ChooseExpr expr)
00080     {
00081         setResult(expr);
00082     }
00083     public void caseConstant(Constant expr)
00084     {
00085         setResult(expr);
00086     }
00087     public void caseDerefExpr(DerefExpr expr)
00088     {
00089     expr.getTarget().apply(this);
00090     Expr target = (Expr) getResult();
00091     setResult(new DerefExpr(target));
00092     }
00093     public void caseDivExpr(DivExpr expr)
00094     {
00095     expr.getOp1().apply(this);
00096     Expr op1 = (Expr) getResult();
00097     expr.getOp2().apply(this);
00098     Expr op2 = (Expr) getResult();
00099         setResult(new DivExpr(op1, op2));
00100     }
00101     public void caseEqExpr(EqExpr expr)
00102     {
00103     expr.getOp1().apply(this);
00104     Expr op1 = (Expr) getResult();
00105     expr.getOp2().apply(this);
00106     Expr op2 = (Expr) getResult();
00107         setResult(new EqExpr(op1, op2));
00108     }
00109     public void caseIntLit(IntLit expr)
00110     {
00111         setResult(expr);
00112     }
00113     public void caseLeExpr(LeExpr expr)
00114     {
00115     expr.getOp1().apply(this);
00116     Expr op1 = (Expr) getResult();
00117     expr.getOp2().apply(this);
00118     Expr op2 = (Expr) getResult();
00119         setResult(new LeExpr(op1, op2));
00120     }
00121     public void caseLengthExpr(LengthExpr expr)
00122     {
00123     expr.getArray().apply(this);
00124     Expr array = (Expr) getResult();
00125         setResult(new LengthExpr(array));
00126     }
00127     public void caseLockAction(LockAction lockAction) 
00128     {
00129     lockAction.getLockExpr().apply(this);
00130     setResult(new LockAction((Expr)getResult(),
00131                       lockAction.getOperation(),
00132                       lockAction.getThread()));
00133     }
00134     public void caseLockTest(LockTest lockTest) 
00135     {
00136     lockTest.getLockExpr().apply(this);
00137     setResult(new LockTest((Expr)getResult(),
00138                     lockTest.getOperation(),
00139                     lockTest.getThread()));
00140     }
00141     public void caseLtExpr(LtExpr expr)
00142     {
00143     expr.getOp1().apply(this);
00144     Expr op1 = (Expr) getResult();
00145     expr.getOp2().apply(this);
00146     Expr op2 = (Expr) getResult();
00147         setResult(new LtExpr(op1, op2));
00148     }
00149     public void caseMulExpr(MulExpr expr)
00150     {
00151     expr.getOp1().apply(this);
00152     Expr op1 = (Expr) getResult();
00153     expr.getOp2().apply(this);
00154     Expr op2 = (Expr) getResult();
00155         setResult(new MulExpr(op1, op2));
00156     }
00157     public void caseNeExpr(NeExpr expr)
00158     {
00159     expr.getOp1().apply(this);
00160     Expr op1 = (Expr) getResult();
00161     expr.getOp2().apply(this);
00162     Expr op2 = (Expr) getResult();
00163         setResult(new NeExpr(op1, op2));
00164     }
00165     public void caseNewArrayExpr(NewArrayExpr expr)
00166     {
00167     setResult(new NewArrayExpr(expr.getCollection(), expr.getLength()));
00168     }
00169     public void caseNewExpr(NewExpr expr)
00170     {
00171     setResult(new NewExpr(expr.getCollection()));
00172     }
00173     public void caseNotExpr(NotExpr expr)
00174     {
00175     expr.getOp().apply(this);
00176     Expr op1 = (Expr) getResult();
00177         setResult(new NotExpr(op1));
00178     }
00179     public void caseNullExpr(NullExpr expr)
00180     {
00181         setResult(expr);
00182     }
00183     public void caseOrExpr(OrExpr expr)
00184     {
00185     expr.getOp1().apply(this);
00186     Expr op1 = (Expr) getResult();
00187     expr.getOp2().apply(this);
00188     Expr op2 = (Expr) getResult();
00189         setResult(new OrExpr(op1, op2));
00190     }
00191     public void caseRecordExpr(RecordExpr expr)
00192     {
00193     expr.getRecord().apply(this);
00194     Expr record = (Expr) getResult();
00195         setResult(new RecordExpr(record, expr.getField())); 
00196     }
00197     public void caseRefExpr(RefExpr expr)
00198     {
00199     setResult(new RefExpr(expr.getTarget()));
00200     }
00201     public void caseRemExpr(RemExpr expr)
00202     {
00203     expr.getOp1().apply(this);
00204     Expr op1 = (Expr) getResult();
00205     expr.getOp2().apply(this);
00206     Expr op2 = (Expr) getResult();
00207         setResult(new RemExpr(op1, op2));
00208     }
00209     public void caseStateVar(StateVar expr)
00210     {
00211         setResult(expr);
00212     }
00213     public void caseSubExpr(SubExpr expr)
00214     {
00215     expr.getOp1().apply(this);
00216     Expr op1 = (Expr) getResult();
00217     expr.getOp2().apply(this);
00218     Expr op2 = (Expr) getResult();
00219         setResult(new SubExpr(op1, op2));
00220     }
00221     public Object getResult()
00222     {
00223         return result;
00224     }
00225     public void setResult(Object result)
00226     {
00227         this.result = result;
00228     }
00229 }

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