2 import IR.MethodDescriptor;
4 public class FlatCall extends FlatNode {
6 TempDescriptor this_temp;
8 MethodDescriptor method;
10 public FlatCall(MethodDescriptor md, TempDescriptor dst, TempDescriptor this_temp, TempDescriptor[] args) {
13 this.this_temp=this_temp;
16 public void rewriteUse(TempMap t) {
17 for(int i=0;i<args.length;i++)
18 args[i]=t.tempMap(args[i]);
19 this_temp=t.tempMap(this_temp);
21 public void rewriteDef(TempMap t) {
24 public FlatNode clone(TempMap t) {
25 TempDescriptor ndst=t.tempMap(dst);
26 TempDescriptor nthis=t.tempMap(this_temp);
27 TempDescriptor[] nargs=new TempDescriptor[args.length];
28 for(int i=0;i<nargs.length;i++)
29 nargs[i]=t.tempMap(args[i]);
30 return new FlatCall(method, ndst, nthis, nargs);
33 public MethodDescriptor getMethod() {
37 public TempDescriptor getThis() {
41 public TempDescriptor getReturnTemp() {
45 public int numArgs() {
49 public TempDescriptor getArg(int i) {
53 public TempDescriptor getArgMatchingParamIndex(FlatMethod fm, int i) {
54 // in non-static methods the "this" pointer
55 // affects the matching index
56 if( method.isStatic() ) {
57 assert numArgs() == fm.numParameters();
59 assert numArgs()+1 == fm.numParameters();
62 if( method.isStatic() ) {
73 public String toString() {
74 String st="FlatCall_";
79 st+=method.getSymbol()+"(";
81 st+=dst+"="+method.getSymbol()+"(";
82 if (this_temp!=null) {
88 for(int i=0; i<args.length; i++) {
89 st+=args[i].toString();
90 if ((i+1)<args.length)
97 return FKind.FlatCall;
100 public TempDescriptor [] readsTemps() {
101 int size=args.length;
104 TempDescriptor [] t=new TempDescriptor[size];
107 t[offset++]=this_temp;
108 for(int i=0; i<args.length; i++)
113 public TempDescriptor [] writesTemps() {
115 return new TempDescriptor[] {dst};
117 return new TempDescriptor[0];