5 public class TokenLiteralExpr extends LiteralExpr {
10 static int count = 100;
11 static Hashtable tokens = new Hashtable();
13 public TokenLiteralExpr(String token) {
15 td = ReservedTypeDescriptor.INT;
17 if (tokens.containsKey(token)) {
18 num = (Integer) tokens.get(token);
20 num = new Integer(count++);
21 tokens.put(token, num);
25 public boolean usesDescriptor(Descriptor d) {
29 public String name() {
33 public boolean equals(Map remap, Expr e) {
34 if (e==null||!(e instanceof TokenLiteralExpr))
36 else return ((TokenLiteralExpr)e).num.equals(num);
39 public String getValue() {
43 public void generate(CodeWriter writer, VarDescriptor dest) {
44 writer.outputline("int " + dest.getSafeSymbol() + " = " + num.toString().toString() + ";");
47 public void prettyPrint(PrettyPrinter pp) {
48 pp.output("{" + token + " = " + num + "}");
51 public TypeDescriptor typecheck(SemanticAnalyzer sa) {
52 td = ReservedTypeDescriptor.INT;