Fix the bug of assignment conversion: 'short s = 12' should be allowed. And for such...
[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   String disjointId;
13   ArrayInitializerNode ain;
14
15   public CreateObjectNode(TypeDescriptor type, boolean isglobal, String disjointId) {
16     td=type;
17     argumentlist=new Vector();
18     this.isglobal=isglobal;
19     this.disjointId=disjointId;
20     this.ain = null;
21   }
22
23   public boolean isGlobal() {
24     return isglobal;
25   }
26
27   public String getDisjointId() {
28     return disjointId;
29   }
30
31   public void addFlagEffects(FlagEffects fe) {
32     this.fe=fe;
33   }
34
35   public FlagEffects getFlagEffects() {
36     return fe;
37   }
38
39   public void addArgument(ExpressionNode en) {
40     argumentlist.add(en);
41   }
42
43   public void setConstructor(MethodDescriptor md) {
44     this.md=md;
45   }
46
47   public MethodDescriptor getConstructor() {
48     return md;
49   }
50
51   public TypeDescriptor getType() {
52     return td;
53   }
54
55   public int numArgs() {
56     return argumentlist.size();
57   }
58
59   public ExpressionNode getArg(int i) {
60     return (ExpressionNode) argumentlist.get(i);
61   }
62   
63   public void addArrayInitializer(ArrayInitializerNode ain) {
64    this.ain = ain; 
65   }
66   
67   public ArrayInitializerNode getArrayInitializer() {
68     return this.ain;
69   }
70
71   public String printNode(int indent) {
72     String st;
73     boolean isarray=td.isArray();
74     if (isarray)
75       st="new "+td.toString()+"[";
76     else
77       st="new "+td.toString()+"(";
78     for(int i=0; i<argumentlist.size(); i++) {
79       ExpressionNode en=(ExpressionNode)argumentlist.get(i);
80       st+=en.printNode(indent);
81       if ((i+1)!=argumentlist.size()) {
82         if (isarray)
83           st+="][";
84         else
85           st+=", ";
86       }
87     }
88     if (isarray)
89       st += "]";
90     else
91       st += ")";
92     if(isarray && this.ain != null) {
93       st += "{";
94       st += this.ain.printNode(indent);
95       st += "}";
96     }
97     return st;
98   }
99
100   public int kind() {
101     return Kind.CreateObjectNode;
102   }
103   
104   public Long evaluate() {
105     eval = null;
106     return eval; //null;
107   }
108 }