This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
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=='\r')
40                 new_st+="\\r";
41             else if (x=='"')
42                 new_st+="\\\"";
43             else new_st+=x;
44         }
45         return new_st;
46     }
47
48     public int kind() {
49         return FKind.FlatLiteralNode;
50     }
51
52     public TempDescriptor [] writesTemps() {
53         return new TempDescriptor[] {dst};
54     }
55 }