1 28 29 package com.caucho.es.parser; 30 31 import com.caucho.es.ESException; 32 import com.caucho.es.ESId; 33 import com.caucho.server.util.CauchoSystem; 34 35 import java.io.IOException ; 36 import java.lang.reflect.Modifier ; 37 38 41 class PackageExpr extends Expr { 42 private Expr rawExpr; 43 private String name; 44 45 private PackageExpr(Block block, Expr rawExpr, String name) 46 { 47 super(block); 48 49 this.rawExpr = rawExpr; 50 this.name = name; 51 } 52 53 PackageExpr(Block block) 54 { 55 super(block); 56 57 this.rawExpr = block.newVar(ESId.intern("Packages")); 58 this.name = null; 59 } 60 61 static Expr create(Block block, Expr rawExpr, String name) 62 { 63 ClassLoader loader = block.getClassLoader(); 64 65 try { 66 Class cl; 67 68 cl = CauchoSystem.loadClass(name, false, loader); 69 70 if (Modifier.isPublic(cl.getModifiers())) 71 return new JavaClassExpr(block, cl); 72 } catch (Throwable e) { 73 } 74 75 return new PackageExpr(block, rawExpr, name); 76 } 77 78 void setType(int type) 79 { 80 } 81 82 int getType() 83 { 84 return TYPE_ES; 85 } 86 87 Expr getTypeExpr() 88 { 89 return null; 90 } 91 92 Expr fieldReference(ESId id) 93 throws ESException 94 { 95 String newName = null; 96 97 if (name == null) 98 newName = id.toString(); 99 else 100 newName = name + "." + id.toString(); 101 102 return PackageExpr.create(block, rawExpr.fieldReference(id), newName); 103 } 104 105 Expr fieldReference(Expr expr) 106 { 107 return rawExpr.fieldReference(expr); 108 } 109 110 CallExpr startCall() 111 throws ESException 112 { 113 return rawExpr.startCall(); 114 } 115 116 CallExpr startNew() 117 throws ESException 118 { 119 return rawExpr.startNew(); 120 } 121 122 void printImpl() throws IOException 123 { 124 rawExpr.printImpl(); 125 } 126 } 127 | Popular Tags |