1 33 34 35 package bsh; 36 37 import java.lang.reflect.InvocationTargetException ; 38 39 class BSHMethodInvocation extends SimpleNode 40 { 41 BSHMethodInvocation (int id) { super(id); } 42 43 BSHAmbiguousName getNameNode() { 44 return (BSHAmbiguousName)jjtGetChild(0); 45 } 46 47 BSHArguments getArgsNode() { 48 return (BSHArguments)jjtGetChild(1); 49 } 50 51 55 public Object eval( CallStack callstack, Interpreter interpreter ) 56 throws EvalError 57 { 58 NameSpace namespace = callstack.top(); 59 BSHAmbiguousName nameNode = getNameNode(); 60 61 if ( namespace.getParent() != null && namespace.getParent().isClass 64 && ( nameNode.text.equals("super") || nameNode.text.equals("this") ) 65 ) 66 return Primitive.VOID; 67 68 Name name = nameNode.getName(namespace); 69 Object [] args = getArgsNode().getArguments(callstack, interpreter); 70 71 try { 75 return name.invokeMethod( interpreter, args, callstack, this); 76 } catch ( ReflectError e ) { 77 throw new EvalError( 78 "Error in method invocation: " + e.getMessage(), 79 this, callstack ); 80 } catch ( InvocationTargetException e ) 81 { 82 String msg = "Method Invocation "+name; 83 Throwable te = e.getTargetException(); 84 85 90 boolean isNative = true; 91 if ( te instanceof EvalError ) 92 if ( te instanceof TargetError ) 93 isNative = ((TargetError)te).inNativeCode(); 94 else 95 isNative = false; 96 97 throw new TargetError( msg, te, this, callstack, isNative ); 98 } catch ( UtilEvalError e ) { 99 throw e.toEvalError( this, callstack ); 100 } 101 } 102 } 103 104 | Popular Tags |