more 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 Object getValue() {
16         return value;
17     }
18
19     public String toString() {
20         if (value==null)
21             return dst+"=null";
22         else
23             return dst+"="+escapeString(value.toString());
24     }
25     private static String escapeString(String st) {
26         String new_st="";
27         for(int i=0;i<st.length();i++) {
28             char x=st.charAt(i);
29             if (x=='\n')
30                 new_st+="\\n";
31             else if (x=='"')
32                 new_st+="'"+'"'+"'";
33             else new_st+=x;
34         }
35         return new_st;
36     }
37 }