From: jjenista Date: Tue, 23 Feb 2010 23:46:21 +0000 (+0000) Subject: a helpful method X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e4c0d5f358064a55cfa2af0f3bf889f2023b0363;p=IRC.git a helpful method --- diff --git a/Robust/src/IR/Flat/FlatCall.java b/Robust/src/IR/Flat/FlatCall.java index 5130b1c4..ed24815c 100644 --- a/Robust/src/IR/Flat/FlatCall.java +++ b/Robust/src/IR/Flat/FlatCall.java @@ -70,6 +70,38 @@ public class FlatCall extends FlatNode { return args[i-1]; } + // return the temp for the argument in caller that + // becomes the given parameter + public TempDescriptor getArgMatchingParam(FlatMethod fm, + TempDescriptor tdParam) { + // in non-static methods the "this" pointer + // affects the matching index + if( method.isStatic() ) { + assert numArgs() == fm.numParameters(); + } else { + assert numArgs()+1 == fm.numParameters(); + } + + for( int i = 0; i < fm.numParameters(); ++i ) { + TempDescriptor tdParamI = fm.getParameter( i ); + + if( tdParamI.equals( tdParam ) ) { + + if( method.isStatic() ) { + return args[i]; + } + + if( i == 0 ) { + return this_temp; + } + + return args[i-1]; + } + } + + return null; + } + public String toString() { String st="FlatCall_"; if (dst==null) {