1 package polyglot.ext.jl.ast; 2 3 import polyglot.ast.ClassLit; 4 import polyglot.ast.Expr; 5 import polyglot.ast.Node; 6 import polyglot.ast.TypeNode; 7 import polyglot.types.SemanticException; 8 import polyglot.util.CodeWriter; 9 import polyglot.util.Position; 10 import polyglot.visit.NodeVisitor; 11 import polyglot.visit.PrettyPrinter; 12 import polyglot.visit.TypeChecker; 13 14 20 public class ClassLit_c extends Lit_c implements ClassLit 21 { 22 protected TypeNode typeNode; 23 24 public ClassLit_c(Position pos, TypeNode typeNode) { 25 super(pos); 26 this.typeNode = typeNode; 27 } 28 29 public TypeNode typeNode() { 30 return this.typeNode; 31 } 32 33 public ClassLit typeNode(TypeNode typeNode) { 34 if (this.typeNode == typeNode) { 35 return this; 36 } 37 ClassLit_c n = (ClassLit_c) copy(); 38 n.typeNode = typeNode; 39 return n; 40 } 41 42 46 public Object objValue() { 47 return null; 48 } 49 50 public Node visitChildren(NodeVisitor v) { 51 TypeNode tn = (TypeNode)visitChild(this.typeNode, v); 52 return this.typeNode(tn); 53 } 54 55 56 public Node typeCheck(TypeChecker tc) throws SemanticException { 57 return type(tc.typeSystem().Class()); 58 } 59 60 public String toString() { 61 return typeNode.toString() + ".class"; 62 } 63 64 65 public void prettyPrint(CodeWriter w, PrettyPrinter tr) 66 { 67 w.begin(0); 68 print(typeNode, w, tr); 69 w.write(".class"); 70 w.end(); 71 } 72 73 77 public boolean isConstant() { 78 return false; 79 } 80 81 public Object constantValue() { 82 return null; 83 } 84 } 85 | Popular Tags |