1 33 34 35 package bsh; 36 37 class BSHAmbiguousName extends SimpleNode 38 { 39 public String text; 40 41 BSHAmbiguousName(int id) { super(id); } 42 43 public Name getName( NameSpace namespace ) 44 { 45 return namespace.getNameResolver( text ); 46 } 47 48 public Object toObject( CallStack callstack, Interpreter interpreter ) 49 throws EvalError 50 { 51 return toObject( callstack, interpreter, false ); 52 } 53 54 Object toObject( 55 CallStack callstack, Interpreter interpreter, boolean forceClass ) 56 throws EvalError 57 { 58 try { 59 return 60 getName( callstack.top() ).toObject( 61 callstack, interpreter, forceClass ); 62 } catch ( UtilEvalError e ) { 63 throw e.toEvalError( this, callstack ); 65 } 66 } 67 68 public Class toClass( CallStack callstack, Interpreter interpreter ) 69 throws EvalError 70 { 71 try { 72 return getName( callstack.top() ).toClass(); 73 } catch ( ClassNotFoundException e ) { 74 throw new EvalError( e.getMessage(), this, callstack ); 75 } catch ( UtilEvalError e2 ) { 76 throw e2.toEvalError( this, callstack ); 78 } 79 } 80 81 public LHS toLHS( CallStack callstack, Interpreter interpreter) 82 throws EvalError 83 { 84 try { 85 return getName( callstack.top() ).toLHS( callstack, interpreter ); 86 } catch ( UtilEvalError e ) { 87 throw e.toEvalError( this, callstack ); 88 } 89 } 90 91 95 public Object eval( CallStack callstack, Interpreter interpreter ) 96 throws EvalError 97 { 98 throw new InterpreterError( 99 "Don't know how to eval an ambiguous name!" 100 +" Use toObject() if you want an object." ); 101 } 102 103 public String toString() { 104 return "AmbigousName: "+text; 105 } 106 } 107 108 | Popular Tags |