import IR.MethodDescriptor;
public class FlatCall extends FlatNode {
- TempDescriptor args[];
- TempDescriptor this_temp;
- TempDescriptor dst;
- MethodDescriptor method;
-
- public FlatCall(MethodDescriptor md, TempDescriptor dst, TempDescriptor this_temp, TempDescriptor[] args) {
- this.method=md;
- this.dst=dst;
- this.this_temp=this_temp;
- this.args=args;
- }
+ TempDescriptor args[];
+ TempDescriptor this_temp;
+ TempDescriptor dst;
+ MethodDescriptor method;
- public MethodDescriptor getMethod() {
- return method;
- }
+ public FlatCall(MethodDescriptor md, TempDescriptor dst, TempDescriptor this_temp, TempDescriptor[] args) {
+ this.method=md;
+ this.dst=dst;
+ this.this_temp=this_temp;
+ this.args=args;
+ }
- public TempDescriptor getThis() {
- return this_temp;
- }
+ public MethodDescriptor getMethod() {
+ return method;
+ }
- public TempDescriptor getReturnTemp() {
- return dst;
- }
+ public TempDescriptor getThis() {
+ return this_temp;
+ }
- public String toString() {
- String st="";
- if (dst==null)
- st+=method.getSymbol()+"(";
- else
- st+=dst+"="+method.getSymbol()+"(";
- if (this_temp!=null) {
- st+=this_temp;
- if (args.length!=0)
- st+=", ";
- }
+ public TempDescriptor getReturnTemp() {
+ return dst;
+ }
- for(int i=0;i<args.length;i++) {
- st+=args[i].toString();
- if ((i+1)<args.length)
- st+=", ";
- }
- return st+")";
- }
+ public int numArgs() {
+ return args.length;
+ }
- public int kind() {
- return FKind.FlatCall;
- }
+ public TempDescriptor getArg(int i) {
+ return args[i];
+ }
- public TempDescriptor [] readsTemps() {
- int size=args.length;
- if (this_temp!=null)
- size++;
- TempDescriptor [] t=new TempDescriptor[size];
- int offset=0;
- if (this_temp!=null)
- t[offset++]=this_temp;
- for(int i=0;i<args.length;i++)
- t[offset++]=args[i];
- return t;
+ public String toString() {
+ String st="FlatCall_";
+ if (dst==null) {
+ if (method==null)
+ st+="null(";
+ else
+ st+=method.getSymbol()+"(";
+ } else
+ st+=dst+"="+method.getSymbol()+"(";
+ if (this_temp!=null) {
+ st+=this_temp;
+ if (args.length!=0)
+ st+=", ";
}
- public TempDescriptor [] writesTemps() {
- if (dst!=null)
- return new TempDescriptor[] {dst};
- else
- return new TempDescriptor[0];
+ for(int i=0; i<args.length; i++) {
+ st+=args[i].toString();
+ if ((i+1)<args.length)
+ st+=", ";
}
+ return st+")";
+ }
+
+ public int kind() {
+ return FKind.FlatCall;
+ }
+
+ public TempDescriptor [] readsTemps() {
+ int size=args.length;
+ if (this_temp!=null)
+ size++;
+ TempDescriptor [] t=new TempDescriptor[size];
+ int offset=0;
+ if (this_temp!=null)
+ t[offset++]=this_temp;
+ for(int i=0; i<args.length; i++)
+ t[offset++]=args[i];
+ return t;
+ }
+
+ public TempDescriptor [] writesTemps() {
+ if (dst!=null)
+ return new TempDescriptor[] {dst};
+ else
+ return new TempDescriptor[0];
+ }
}