private static void logInvokeMethod(String msg, Method method, Object[] args) { if (Interpreter.DEBUG) { Interpreter.debug(msg + method + " with args:"); for (int i = 0; i < args.length; i++) { final Object arg = args[i]; Interpreter.debug("args[" + i + "] = " + arg + " type = " + (arg == null ? "<unkown>" : arg.getClass())); } } }
static void logInvokeMethod(String msg, Invocable method, Object[] args) { if (Interpreter.DEBUG.get()) { Interpreter.debug(msg, method, " with args:"); for (int i = 0; i < args.length; i++) { final Object arg = args[i]; Interpreter.debug("args[", i, "] = ", arg, " type = ", (arg == null ? "<unknown>" : arg.getClass())); } } }
@Override public void addListener( Listener l ) { listeners.addElement( new WeakReference( l, refQueue) ); // clean up old listeners Reference deadref; while ( (deadref = refQueue.poll()) != null ) { if ( !listeners.removeElement( deadref ) ) Interpreter.debug( "tried to remove non-existent weak ref: ", deadref); } }
@Override public void addListener( Listener l ) { listeners.addElement( new WeakReference( l, refQueue) ); // clean up old listeners Reference deadref; while ( (deadref = refQueue.poll()) != null ) { boolean ok = listeners.removeElement( deadref ); if ( ok ) { //System.err.println("cleaned up weak ref: "+deadref); } else { if ( Interpreter.DEBUG ) Interpreter.debug( "tried to remove non-existent weak ref: "+deadref); } } }
void loadRCFiles() { try { // Default is c:\windows under win98, $HOME under Unix String rcfile = System.getProperty("user.home") + File.separator + ".bshrc"; source( rcfile, globalNameSpace ); } catch ( Exception e ) { // squeltch security exception, filenotfoundexception Interpreter.debug("Could not find rc file: ", e); } }
public Object eval( Class type, CallStack callstack, Interpreter interpreter ) throws EvalError { Interpreter.debug("array base type = ", type); baseType = type; if ( null == cached ) cached = eval( callstack, interpreter ); return cached; }
/** Evaluate the string in this interpreter's global namespace. */ public Object eval( String statements ) throws EvalError { if ( Interpreter.DEBUG ) debug("eval(String): "+statements); return eval(statements, globalNameSpace); }
/** Evaluate the string in this interpreter's global namespace. */ public Object eval( String statements ) throws EvalError { Interpreter.debug("eval(String): ", statements); return eval(statements, globalNameSpace); }
void loadRCFiles() { try { String rcfile = // Default is c:\windows under win98, $HOME under Unix System.getProperty("user.home") + File.separator + ".bshrc"; source( rcfile, globalNameSpace ); } catch ( Exception e ) { // squeltch security exception, filenotfoundexception if ( Interpreter.DEBUG ) debug("Could not find rc file: "+e); } }
public Object evalArrayDimensions( BSHArrayDimensions node, Class type ) throws EvalError { if ( Interpreter.DEBUG ) Interpreter.debug("array base type = "+type); node.baseType = type; return node.accept(this); }
public void paintComponent( Graphics g ) { // copy buffered image if ( imageBuffer != null ) g.drawImage(imageBuffer, 0,0, this); // Delegate call to scripted paint() method if ( ths != null ) { try { ths.invokeMethod( "paint", new Object[] { g } ); } catch(EvalError e) { Interpreter.debug( "BshCanvas: method invocation error:", e); } } }
/** Read text from fileName and eval it. */ public Object source( String filename, NameSpace nameSpace ) throws FileNotFoundException, IOException, EvalError { File file = pathToFile( filename ); if ( Interpreter.DEBUG ) debug("Sourcing file: "+file); Reader sourceIn = new BufferedReader( new FileReader(file) ); try { return eval( sourceIn, nameSpace, filename ); } finally { sourceIn.close(); } }
public static Object getIndex(Object array, int index) throws ReflectError, UtilTargetError { if (Interpreter.DEBUG) { Interpreter.debug("getIndex: " + array + ", index=" + index); } try { Object val = Array.get(array, index); return Primitive.wrap(val, array.getClass().getComponentType()); } catch (ArrayIndexOutOfBoundsException e1) { throw new UtilTargetError(e1); } catch (Exception e) { throw new ReflectError("Array access:" + e); } }
/** * Invoke a method known to be static. * No object instance is needed and there is no possibility of the * method being a bsh scripted method. */ public static Object invokeStaticMethod(BshClassManager bcm, Class clas, String methodName, Object[] args) throws ReflectError, UtilEvalError, InvocationTargetException { Interpreter.debug("invoke static Method"); Method method = resolveExpectedJavaMethod(bcm, clas, null, methodName, args, true); return invokeMethod(method, null, args); }
public static void setObjectProperty(Object obj, String propName, Object value) throws ReflectError, UtilEvalError { String accessorName = accessorName("set", propName); Object[] args = new Object[]{value}; Interpreter.debug("property access: "); try { Method method = resolveExpectedJavaMethod(null/*bcm*/, obj.getClass(), obj, accessorName, args, false); invokeMethod(method, obj, args); } catch (InvocationTargetException e) { throw new UtilEvalError("Property accessor threw exception: " + e.getTargetException()); } }
/** Read text from fileName and eval it. */ public Object source( String filename, NameSpace nameSpace ) throws FileNotFoundException, IOException, EvalError { File file = pathToFile( filename ); Interpreter.debug("Sourcing file: ", file); Reader sourceIn = new BufferedReader( new FileReader(file) ); try { return eval( sourceIn, nameSpace, filename ); } finally { sourceIn.close(); } }
public Object lhsUnaryOperation( LHS lhs, boolean strictJava ) throws UtilEvalError { if ( Interpreter.DEBUG ) Interpreter.debug("lhsUnaryOperation"); Object prevalue, postvalue; prevalue = lhs.getValue(); postvalue = unaryOperation(prevalue, kind); Object retVal; if ( postfix ) retVal = prevalue; else retVal = postvalue; lhs.assign( postvalue, strictJava ); return retVal; }
private Object lhsUnaryOperation( LHS lhs, boolean strictJava ) throws UtilEvalError { Interpreter.debug("lhsUnaryOperation"); Object prevalue, postvalue; prevalue = lhs.getValue(); postvalue = unaryOperation(prevalue, kind); Object retVal; if ( postfix ) retVal = prevalue; else retVal = postvalue; lhs.assign( postvalue, strictJava ); return retVal; }
/** Invoke a method known to be static. No object instance is needed and there is no possibility of the method being a bsh scripted method. */ public static Object invokeStaticMethod( BshClassManager bcm, Class<?> clas, String methodName, Object [] args, SimpleNode callerInfo ) throws ReflectError, UtilEvalError, InvocationTargetException { Interpreter.debug("invoke static Method"); NameSpace ns = getThisNS(clas); if (null != ns) ns.setNode(callerInfo); Invocable method = resolveExpectedJavaMethod( bcm, clas, null, methodName, args, true ); return method.invoke(null, args); }
final public boolean Line() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 0: jj_consume_token(0); Interpreter.debug("End of File!"); {if (true) return true;} break; default: if (jj_2_1(1)) { BlockStatement(); {if (true) return false;} } else { jj_consume_token(-1); throw new ParseException(); } } throw new Error("Missing return statement in function"); }