Changes
[IRC.git] / Robust / src / IR / Flat / FlatLiteralNode.java
1 package IR.Flat;
2 import IR.TypeDescriptor;
3
4 public class FlatLiteralNode extends FlatNode {
5     Object value;
6     TypeDescriptor type;
7     TempDescriptor dst;
8
9     public FlatLiteralNode(TypeDescriptor type, Object o, TempDescriptor dst) {
10         this.type=type;
11         value=o;
12         this.dst=dst;
13     }
14
15     public TypeDescriptor getType() {
16         return type;
17     }
18
19     public TempDescriptor getDst() {
20         return dst;
21     }
22
23     public Object getValue() {
24         return value;
25     }
26
27     public String toString() {
28         if (value==null)
29             return dst+"=null";
30         else
31             return dst+"="+escapeString(value.toString());
32     }
33     protected static String escapeString(String st) {
34         String new_st="";
35         for(int i=0;i<st.length();i++) {
36             char x=st.charAt(i);
37             if (x=='\n')
38                 new_st+="\\n";
39             else if (x=='"')
40                 new_st+="'"+'"'+"'";
41             else new_st+=x;
42         }
43         return new_st;
44     }
45
46     public int kind() {
47         return FKind.FlatLiteralNode;
48     }
49
50     public TempDescriptor [] writesTemps() {
51         return new TempDescriptor[] {dst};
52     }
53 }