00001 package ca.mcgill.sable.soot.grimp; 00002 00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00004 * Grimp, an aggregated-expression Java(TM) bytecode representation. * 00005 * Copyright (C) 1998 Patrick Lam (plam@sable.mcgill.ca) * 00006 * All rights reserved. * 00007 * * 00008 * This work was done as a project of the Sable Research Group, * 00009 * School of Computer Science, McGill University, Canada * 00010 * (http://www.sable.mcgill.ca/). It is understood that any * 00011 * modification not identified as such is not covered by the * 00012 * This work was done as a project of the Sable Research Group, * 00013 * School of Computer Science, McGill University, Canada * 00014 * (http://www.sable.mcgill.ca/). It is understood that any * 00015 * modification not identified as such is not covered by the * 00016 * preceding statement. * 00017 * * 00018 * This work is free software; you can redistribute it and/or * 00019 * modify it under the terms of the GNU Library General Public * 00020 * License as published by the Free Software Foundation; either * 00021 * version 2 of the License, or (at your option) any later version. * 00022 * * 00023 * This work is distributed in the hope that it will be useful, * 00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00026 * Library General Public License for more details. * 00027 * * 00028 * You should have received a copy of the GNU Library General Public * 00029 * License along with this library; if not, write to the * 00030 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * 00031 * Boston, MA 02111-1307, USA. * 00032 * * 00033 * Java is a trademark of Sun Microsystems, Inc. * 00034 * * 00035 * To submit a bug report, send a comment, or get the latest news on * 00036 * this project and other Sable Research Group projects, please * 00037 * visit the web site: http://www.sable.mcgill.ca/ * 00038 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00039 00040 /* 00041 Reference Version 00042 ----------------- 00043 This is the latest official version on which this file is based. 00044 The reference version is: $SootVersion: 1.beta.4 $ 00045 00046 Change History 00047 -------------- 00048 A) Notes: 00049 00050 Please use the following template. Most recent changes should 00051 appear at the top of the list. 00052 00053 - Modified on [date (March 1, 1900)] by [name]. [(*) if appropriate] 00054 [description of modification]. 00055 00056 Any Modification flagged with "(*)" was done as a project of the 00057 Sable Research Group, School of Computer Science, 00058 McGill University, Canada (http://www.sable.mcgill.ca/). 00059 00060 You should add your copyright, using the following template, at 00061 the top of this file, along with other copyrights. 00062 00063 * * 00064 * Modifications by [name] are * 00065 * Copyright (C) [year(s)] [your name (or company)]. All rights * 00066 * reserved. * 00067 * * 00068 00069 B) Changes: 00070 00071 - Modified on February 3, 1999 by Patrick Lam (plam@sable.mcgill.ca). (*) 00072 First release of Grimp. 00073 */ 00074 00075 import ca.mcgill.sable.soot.*; 00076 import ca.mcgill.sable.soot.jimple.*; 00077 import ca.mcgill.sable.util.*; 00078 00079 class GInterfaceInvokeExpr extends AbstractInterfaceInvokeExpr 00080 implements InterfaceInvokeExpr, Precedence 00081 { 00082 GInterfaceInvokeExpr(Value base, SootMethod method, List args) 00083 { 00084 super(Grimp.v().newObjExprBox(base), method, 00085 new ValueBox[args.size()]); 00086 00087 for(int i = 0; i < args.size(); i++) 00088 this.argBoxes[i] = Grimp.v().newExprBox((Value) args.get(i)); 00089 } 00090 public int getPrecedence() { return 950; } 00091 public String toBriefString() 00092 { 00093 StringBuffer buffer = new StringBuffer(); 00094 00095 buffer.append("." + getMethod().getName() + "("); 00096 00097 for(int i = 0; i < argBoxes.length; i++) 00098 { 00099 if(i != 0) 00100 buffer.append(", "); 00101 00102 buffer.append(((ToBriefString) argBoxes[i].getValue()).toBriefString()); 00103 } 00104 00105 buffer.append(")"); 00106 00107 return toString(getBase(), 00108 ((ToBriefString)getBase()).toBriefString(), 00109 buffer.toString()); 00110 } 00111 public String toString() 00112 { 00113 StringBuffer buffer = new StringBuffer(); 00114 00115 buffer.append(".[" + getMethod().getSignature() + "]("); 00116 00117 for(int i = 0; i < argBoxes.length; i++) 00118 { 00119 if(i != 0) 00120 buffer.append(", "); 00121 00122 buffer.append(argBoxes[i].getValue().toString()); 00123 } 00124 00125 buffer.append(")"); 00126 00127 return toString(getBase(), getBase().toString(), 00128 buffer.toString()); 00129 } 00130 private String toString(Value op, String opString, String rightString) 00131 { 00132 String leftOp = opString; 00133 00134 if (getBase() instanceof Precedence && 00135 ((Precedence)getBase()).getPrecedence() < getPrecedence()) 00136 leftOp = "(" + leftOp + ")"; 00137 return leftOp + rightString; 00138 } 00139 }