a helpful method
authorjjenista <jjenista>
Tue, 23 Feb 2010 23:46:21 +0000 (23:46 +0000)
committerjjenista <jjenista>
Tue, 23 Feb 2010 23:46:21 +0000 (23:46 +0000)
Robust/src/IR/Flat/FlatCall.java

index 5130b1c476457d936c751e93449e6a3e99dd9d5f..ed24815cf05f7e21153708baad436ee001229f2e 100644 (file)
@@ -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) {