1
3 package jminusminus;
4
5
8 class JLiteralString extends JExpression {
9 private String text;
11
12
18 public JLiteralString(int line, String text) {
19 super(line);
20 this.text = text;
21 }
22
23
26 public JExpression analyze(Context context) {
27 type = Type.STRING;
28 return this;
29 }
30
31
34 public void codegen(CLEmitter output) {
35 String s = JAST.unescape(text);
36 output.addLDCInstruction(s.substring(1, s.length() - 1));
37 }
38
39
42 public void toJSON(JSONElement json) {
43 JSONElement e = new JSONElement();
44 json.addChild("JLiteralString:" + line, e);
45 e.addAttribute("type", type == null ? "" : type.toString());
46 e.addAttribute("value", text.substring(1, text.length() - 1));
47 }
48 }
49