1 package polyglot.ext.jl.ast; 2 3 import polyglot.ast.*; 4 import polyglot.types.*; 5 import polyglot.visit.*; 6 import polyglot.util.*; 7 8 12 public class CharLit_c extends NumLit_c implements CharLit 13 { 14 public CharLit_c(Position pos, char value) { 15 super(pos, value); 16 } 17 18 19 public char value() { 20 return (char) longValue(); 21 } 22 23 24 public CharLit value(char value) { 25 CharLit_c n = (CharLit_c) copy(); 26 n.value = value; 27 return n; 28 } 29 30 31 public Node typeCheck(TypeChecker tc) throws SemanticException { 32 return type(tc.typeSystem().Char()); 33 } 34 35 public String toString() { 36 return "'" + StringUtil.escape((char) value) + "'"; 37 } 38 39 40 public void prettyPrint(CodeWriter w, PrettyPrinter tr) { 41 w.write("'"); 42 w.write(StringUtil.escape((char) value)); 43 w.write("'"); 44 } 45 46 public Object constantValue() { 47 return new Character ((char) value); 48 } 49 } 50 | Popular Tags |