public NameSpace( NameSpace parent, BshClassManager classManager, String name ) { // We might want to do this here rather than explicitly in Interpreter // for global (see also prune()) //if ( classManager == null && (parent == null ) ) // create our own class manager? setName(name); setParent(parent); setClassManager( classManager ); // Register for notification of classloader change if ( classManager != null ) classManager.addListener(this); }
public Class getType(BSHType tnode) throws EvalError { // return cached type if available if ( tnode.type != null ) return tnode.type; // first node will either be PrimitiveType or AmbiguousName SimpleNode node = tnode.getTypeNode(); if ( node instanceof BSHPrimitiveType ) tnode.baseType = ((BSHPrimitiveType)node).getType(); else tnode.baseType = ambiguousNameToClass(((BSHAmbiguousName)node)); if ( tnode.arrayDims > 0 ) { try { // Get the type by constructing a prototype array with // arbitrary (zero) length in each dimension. int[] dims = new int[tnode.arrayDims]; // int array default zeros Object obj = Array.newInstance(tnode.baseType, dims); tnode.type = obj.getClass(); } catch(Exception e) { throw new EvalError("Couldn't construct array type", tnode, callstack ); } } else tnode.type = tnode.baseType; // hack... sticking to first interpreter that resolves this // see comments on type instance variable interpreter.getClassManager().addListener(tnode); return tnode.type; }
/** Instantiates a new name space. * @param parent the parent * @param classManager the class manager * @param name the name */ public NameSpace(final NameSpace parent, final BshClassManager classManager, final String name) { // We might want to do this here rather than explicitly in Interpreter // for global (see also prune()) // if (classManager == null && (parent == null)) // create our own class manager? this.setName(name); this.setParent(parent); this.setClassManager(classManager); // Register for notification of classloader change this.getClassManager().addListener(this); }
interpreter.getClassManager().addListener(this);