static DelayedEvalBshMethod[] getDeclaredMethods( BSHBlock body, CallStack callstack, Interpreter interpreter, String defaultPackage) throws EvalError { List<DelayedEvalBshMethod> methods = new ArrayList<DelayedEvalBshMethod>(); for (int child = 0; child < body.jjtGetNumChildren(); child++) { SimpleNode node = (SimpleNode) body.jjtGetChild(child); if (node instanceof BSHMethodDeclaration) { BSHMethodDeclaration md = (BSHMethodDeclaration) node; md.insureNodesParsed(); Modifiers modifiers = md.modifiers; String name = md.name; String returnType = md.getReturnTypeDescriptor(callstack, interpreter, defaultPackage); BSHReturnType returnTypeNode = md.getReturnTypeNode(); BSHFormalParameters paramTypesNode = md.paramsNode; String[] paramTypes = paramTypesNode.getTypeDescriptors(callstack, interpreter, defaultPackage); DelayedEvalBshMethod bm = new DelayedEvalBshMethod( name, returnType, returnTypeNode, md.paramsNode.getParamNames(), paramTypes, paramTypesNode, md.blockNode, null /*declaringNameSpace*/, modifiers, callstack, interpreter); methods.add(bm); } } return methods.toArray(new DelayedEvalBshMethod[methods.size()]); }
static Variable[] getDeclaredVariables( BSHBlock body, CallStack callstack, Interpreter interpreter, String defaultPackage) { List<Variable> vars = new ArrayList<Variable>(); for (int child = 0; child < body.jjtGetNumChildren(); child++) { SimpleNode node = (SimpleNode) body.jjtGetChild(child); if (node instanceof BSHTypedVariableDeclaration) { BSHTypedVariableDeclaration tvd = (BSHTypedVariableDeclaration) node; Modifiers modifiers = tvd.modifiers; String type = tvd.getTypeDescriptor(callstack, interpreter, defaultPackage); BSHVariableDeclarator[] vardec = tvd.getDeclarators(); for (BSHVariableDeclarator aVardec : vardec) { String name = aVardec.name; try { Variable var = new Variable(name, type, null /*value*/, modifiers); vars.add(var); } catch (UtilEvalError e) { // value error shouldn't happen } } } } return vars.toArray(new Variable[vars.size()]); }