1 33 34 35 package bsh; 36 37 44 class BSHCastExpression extends SimpleNode { 45 46 public BSHCastExpression(int id) { super(id); } 47 48 51 public Object eval( 52 CallStack callstack, Interpreter interpreter ) throws EvalError 53 { 54 NameSpace namespace = callstack.top(); 55 Class toType = ((BSHType)jjtGetChild(0)).getType( 56 callstack, interpreter ); 57 SimpleNode expression = (SimpleNode)jjtGetChild(1); 58 59 Object fromValue = expression.eval(callstack, interpreter); 61 Class fromType = fromValue.getClass(); 62 63 try { 66 return Types.castObject( fromValue, toType, Types.CAST ); 67 } catch ( UtilEvalError e ) { 68 throw e.toEvalError( this, callstack ); 69 } 70 } 71 72 } 73 | Popular Tags |