2 import IR.MethodDescriptor;
4 public class FlatCall extends FlatNode {
6 TempDescriptor this_temp;
8 MethodDescriptor method;
11 public FlatCall(MethodDescriptor md, TempDescriptor dst, TempDescriptor this_temp, TempDescriptor[] args) {
12 this(md, dst, this_temp, args, false);
15 public FlatCall(MethodDescriptor md, TempDescriptor dst, TempDescriptor this_temp, TempDescriptor[] args, boolean isSuper) {
18 this.this_temp=this_temp;
22 public void rewriteUse(TempMap t) {
23 for(int i=0; i<args.length; i++)
24 args[i]=t.tempMap(args[i]);
25 this_temp=t.tempMap(this_temp);
27 public void rewriteDef(TempMap t) {
30 public FlatNode clone(TempMap t) {
31 TempDescriptor ndst=t.tempMap(dst);
32 TempDescriptor nthis=t.tempMap(this_temp);
33 TempDescriptor[] nargs=new TempDescriptor[args.length];
34 for(int i=0; i<nargs.length; i++)
35 nargs[i]=t.tempMap(args[i]);
37 return new FlatCall(method, ndst, nthis, nargs);
39 public boolean getSuper() {
43 public MethodDescriptor getMethod() {
47 public TempDescriptor getThis() {
51 public TempDescriptor getReturnTemp() {
55 public int numArgs() {
59 public TempDescriptor getArg(int i) {
63 public TempDescriptor getArgMatchingParamIndex(FlatMethod fm, int i) {
64 // in non-static methods the "this" pointer
65 // affects the matching index
66 if( method.isStatic() ) {
67 assert numArgs() == fm.numParameters();
69 assert numArgs()+1 == fm.numParameters();
72 if( method.isStatic() ) {
83 // return the temp for the argument in caller that
84 // becomes the given parameter
85 public TempDescriptor getArgMatchingParam(FlatMethod fm,
86 TempDescriptor tdParam) {
87 // in non-static methods the "this" pointer
88 // affects the matching index
89 if( method.isStatic() ) {
90 assert numArgs() == fm.numParameters();
92 assert numArgs()+1 == fm.numParameters();
95 for( int i = 0; i < fm.numParameters(); ++i ) {
96 TempDescriptor tdParamI = fm.getParameter(i);
98 if( tdParamI.equals(tdParam) ) {
100 if( method.isStatic() ) {
115 public String toString() {
116 String st="FlatCall_";
121 st+=method.getSymbol()+"(";
123 st+=dst+"="+method.getSymbol()+"(";
124 if (this_temp!=null) {
130 for(int i=0; i<args.length; i++) {
131 st+=args[i].toString();
132 if ((i+1)<args.length)
139 return FKind.FlatCall;
142 public TempDescriptor [] readsTemps() {
143 int size=args.length;
146 TempDescriptor [] t=new TempDescriptor[size];
149 t[offset++]=this_temp;
150 for(int i=0; i<args.length; i++)
155 public TempDescriptor [] writesTemps() {
157 return new TempDescriptor[] {dst};
159 return new TempDescriptor[0];