1 33 34 35 package bsh; 36 37 class BSHImportDeclaration extends SimpleNode 38 { 39 public boolean importPackage; 40 public boolean staticImport; 41 public boolean superImport; 42 43 BSHImportDeclaration(int id) { super(id); } 44 45 public Object eval( CallStack callstack, Interpreter interpreter) 46 throws EvalError 47 { 48 NameSpace namespace = callstack.top(); 49 if ( superImport ) 50 try { 51 namespace.doSuperImport(); 52 } catch ( UtilEvalError e ) { 53 throw e.toEvalError( this, callstack ); 54 } 55 else 56 { 57 if ( staticImport ) 58 { 59 if ( importPackage ) 60 { 61 Class clas = ((BSHAmbiguousName)jjtGetChild(0)).toClass( 62 callstack, interpreter ); 63 namespace.importStatic( clas ); 64 } else 65 throw new EvalError( 66 "static field imports not supported yet", 67 this, callstack ); 68 } else 69 { 70 String name = ((BSHAmbiguousName)jjtGetChild(0)).text; 71 if ( importPackage ) 72 namespace.importPackage(name); 73 else 74 namespace.importClass(name); 75 } 76 } 77 78 return Primitive.VOID; 79 } 80 } 81 82 | Popular Tags |