5379b6f50fa514a0d13bd431614200839d667fc0
[IRC.git] / Robust / src / IR / Tree / CreateObjectNode.java
1 package IR.Tree;
2 import java.util.Vector;
3 import IR.TypeDescriptor;
4 import IR.MethodDescriptor;
5
6 public class CreateObjectNode extends ExpressionNode {
7   TypeDescriptor td;
8   Vector argumentlist;
9   MethodDescriptor md;
10   FlagEffects fe;
11   boolean isglobal;
12   boolean isdisjoint;  
13
14   public CreateObjectNode(TypeDescriptor type, boolean isglobal, boolean isdisjoint) {
15     td=type;
16     argumentlist=new Vector();
17     this.isglobal=isglobal;
18     this.isdisjoint=isdisjoint;
19   }
20
21   public boolean isGlobal() {
22     return isglobal;
23   }
24
25   public boolean isDisjoint() {
26     return isdisjoint;
27   }
28
29   public void addFlagEffects(FlagEffects fe) {
30     this.fe=fe;
31   }
32
33   public FlagEffects getFlagEffects() {
34     return fe;
35   }
36
37   public void addArgument(ExpressionNode en) {
38     argumentlist.add(en);
39   }
40
41   public void setConstructor(MethodDescriptor md) {
42     this.md=md;
43   }
44
45   public MethodDescriptor getConstructor() {
46     return md;
47   }
48
49   public TypeDescriptor getType() {
50     return td;
51   }
52
53   public int numArgs() {
54     return argumentlist.size();
55   }
56
57   public ExpressionNode getArg(int i) {
58     return (ExpressionNode) argumentlist.get(i);
59   }
60
61   public String printNode(int indent) {
62     String st;
63     boolean isarray=td.isArray();
64     if (isarray)
65       st="new "+td.toString()+"[";
66     else
67       st="new "+td.toString()+"(";
68     for(int i=0; i<argumentlist.size(); i++) {
69       ExpressionNode en=(ExpressionNode)argumentlist.get(i);
70       st+=en.printNode(indent);
71       if ((i+1)!=argumentlist.size()) {
72         if (isarray)
73           st+="][";
74         else
75           st+=", ";
76       }
77     }
78     if (isarray)
79       return st+"]";
80     else
81       return st+")";
82   }
83
84   public int kind() {
85     return Kind.CreateObjectNode;
86   }
87 }