1 33 34 package bsh; 35 36 38 class BSHClassDeclaration extends SimpleNode 39 { 40 48 static final String CLASSINITNAME = "_bshClassInit"; 49 50 String name; 51 Modifiers modifiers; 52 int numInterfaces; 53 boolean extend; 54 boolean isInterface; 55 56 BSHClassDeclaration(int id) { super(id); } 57 58 60 public Object eval( CallStack callstack, Interpreter interpreter ) 61 throws EvalError 62 { 63 int child = 0; 64 65 Class superClass = null; 67 if ( extend ) 68 { 69 BSHAmbiguousName superNode = (BSHAmbiguousName)jjtGetChild(child++); 70 superClass = superNode.toClass( callstack, interpreter ); 71 } 72 73 Class [] interfaces = new Class [numInterfaces]; 75 for( int i=0; i<numInterfaces; i++) { 76 BSHAmbiguousName node = (BSHAmbiguousName)jjtGetChild(child++); 77 interfaces[i] = node.toClass(callstack, interpreter); 78 if ( !interfaces[i].isInterface() ) 79 throw new EvalError( 80 "Type: "+node.text+" is not an interface!", 81 this, callstack ); 82 } 83 84 BSHBlock block; 85 if ( child < jjtGetNumChildren() ) 87 block = (BSHBlock)jjtGetChild(child); 88 else 89 block = new BSHBlock( ParserTreeConstants.JJTBLOCK ); 90 91 try { 92 return ClassGenerator.getClassGenerator().generateClass( 93 name, modifiers, interfaces, superClass, block, isInterface, 94 callstack, interpreter ); 95 } catch ( UtilEvalError e ) { 96 throw e.toEvalError( this, callstack ); 97 } 98 99 } 100 101 public String toString() { 102 return "ClassDeclaration: "+name; 103 } 104 } 105 | Popular Tags |