protected NameSpace create(NameSpace key) { return new BlockNameSpace(key); } };
/** do we need this? */ private NameSpace getNonBlockParent() { NameSpace parent = super.getParent(); if ( parent instanceof BlockNameSpace ) return ((BlockNameSpace)parent).getNonBlockParent(); else return parent; }
/** Override the standard namespace behavior to make assignments happen in our parent (enclosing) namespace, unless the variable has already been assigned here via a typed declaration or through the special setBlockVariable() (used for untyped args in try/catch). <p> i.e. only allow typed var declaration to happen in this namespace. Typed vars are handled in the ordinary way local scope. All untyped assignments are delegated to the enclosing context. */ /* Note: it may see like with the new 1.3 scoping this test could be removed, but it cannot. When recurse is false we still need to set the variable in our parent, not here. */ public void setVariable( String name, Object value, boolean strictJava, boolean recurse ) throws UtilEvalError { if ( weHaveVar( name ) ) // set the var here in the block namespace super.setVariable( name, value, strictJava, false ); else // set the var in the enclosing (parent) namespace getParent().setVariable( name, value, strictJava, recurse ); }
new BlockNameSpace( enclosingNameSpace ); cbNameSpace.setBlockVariable( fp.name, thrown ); else cbNameSpace.setTypedVariable( fp.name, fp.type, thrown, new Modifiers()/*none*/ );
BlockNameSpace eachNameSpace = new BlockNameSpace( enclosingNameSpace ); callstack.swap( eachNameSpace ); value = Primitive.NULL; if ( elementType != null ) eachNameSpace.setTypedVariable( node.varName/*name*/, elementType/*type*/, value, new Modifiers()/*none*/ ); else eachNameSpace.setVariable( node.varName, value, false ); } catch ( UtilEvalError e ) { throw e.toEvalError(
while ( !Thread.interrupted() && iterator.hasNext() ) { try { BlockNameSpace eachNameSpace = new BlockNameSpace(enclosingNameSpace); callstack.swap(eachNameSpace); Object value = iterator.next(); if ( value == null ) value = Primitive.NULL; eachNameSpace.setTypedVariable( varName, elementType, value, modifiers); } catch ( UtilEvalError e ) {
/** delegate import to our parent */ public void importClass(String name) { getParent().importClass( name ); }
new BlockNameSpace( enclosingNameSpace ); cbNameSpace.setBlockVariable( mc.name, thrown ); else cbNameSpace.setTypedVariable( mc.name, mcType, thrown, modifiers); } catch ( UtilEvalError e ) {
/** delegate import to our parent */ public void importClass(String name) { getParent().importClass( name ); }
/** Override the standard namespace behavior to make assignments happen in our parent (enclosing) namespace, unless the variable has already been assigned here via a typed declaration or through the special setBlockVariable() (used for untyped args in try/catch). <p> i.e. only allow typed var declaration to happen in this namespace. Typed vars are handled in the ordinary way local scope. All untyped assignments are delegated to the enclosing context. */ /* Note: it may see like with the new 1.3 scoping this test could be removed, but it cannot. When recurse is false we still need to set the variable in our parent, not here. */ public Variable setVariable( String name, Object value, boolean strictJava, boolean recurse ) throws UtilEvalError { if ( weHaveVar( name ) ) // set the var here in the block namespace return super.setVariable( name, value, strictJava, false ); else // set the var in the enclosing (parent) namespace return getParent().setVariable( name, value, strictJava, recurse ); }
/** delegate import to our parent */ public void importPackage(String name) { getParent().importPackage( name ); }
/** super is our parent's super */ public This getSuper( Interpreter declaringInterpreter ) { return getNonBlockParent().getSuper( declaringInterpreter ); }
BlockNameSpace forNameSpace = new BlockNameSpace( enclosingNameSpace );
/** delegate import to our parent */ public void importPackage(String name) { getParent().importPackage( name ); }
/** super is our parent's super */ public This getSuper( Interpreter declaringInterpreter ) { return getNonBlockParent().getSuper( declaringInterpreter ); }
new BlockNameSpace( enclosingNameSpace );
public void setMethod(BshMethod method) throws UtilEvalError { getParent().setMethod( method ); } }
/** Get a 'this' reference is our parent's 'this' for the object closure. e.g. Normally a 'this' reference to a BlockNameSpace (e.g. if () { } ) resolves to the parent namespace (e.g. the namespace containing the "if" statement). @see #getBlockThis( Interpreter ) */ public This getThis( Interpreter declaringInterpreter ) { return getNonBlockParent().getThis( declaringInterpreter ); }
BlockNameSpace forNameSpace = new BlockNameSpace( enclosingNameSpace );
public void setMethod(BshMethod method) { getParent().setMethod( method ); } }