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     String str = "FlatLiteralNode_"+dst;
29     if (value==null)
30       str += "=null";
31     else
32       str += "="+escapeString(value.toString());
33     return str;
34   }
35   protected static String escapeString(String st) {
36     String new_st="";
37     for(int i=0; i<st.length(); i++) {
38       char x=st.charAt(i);
39       if (x=='\n')
40         new_st+="\\n";
41       else if (x=='\r')
42         new_st+="\\r";
43       else if (x=='"')
44         new_st+="\\\"";
45       else new_st+=x;
46     }
47     return new_st;
48   }
49
50   public int kind() {
51     return FKind.FlatLiteralNode;
52   }
53
54   public TempDescriptor [] writesTemps() {
55     return new TempDescriptor[] {dst};
56   }
57 }