bsh
Class BlockNameSpace

java.lang.Object
  |
  +--bsh.NameSpace
        |
        +--bsh.BlockNameSpace
All Implemented Interfaces:
BshClassManager.Listener, NameSource, java.io.Serializable

class BlockNameSpace
extends NameSpace

A specialized namespace for Blocks, e.g. the body of a "for" statement. The Block acts like a child namespace but only for typed variables declared within it. Elsewhere variable assignment (including untyped variable usage) acts like it is part of the containing block.

Note: It *must* remain possible for a BlockNameSpace to be a child of another BlockNameSpace and have variable propogation pass all the way through. (This happens naturally and simply here). This is used in BSHForStatement (see notes there).


Nested Class Summary
 
Nested classes inherited from class bsh.NameSpace
NameSpace.TypedVariable
 
Nested classes inherited from class bsh.NameSource
NameSource.Listener
 
Field Summary
(package private)  boolean initMode
          When true, capture all variable assignment locally
 
Fields inherited from class bsh.NameSpace
callerInfoNode, JAVACODE, name, nameSourceListeners
 
Constructor Summary
BlockNameSpace(NameSpace parent)
           
 
Method Summary
 NameSpace getSuper()
          super is our parent's super
(package private)  This getThis(Interpreter declaringInterpreter)
          this is our parent's this
 void importClass(java.lang.String name)
          delegate import to our parent
 void importPackage(java.lang.String name)
          delegate import to our parent
 void setInitMode(boolean b)
          When set to true, handle all variable assignment in this local scope - don't delegate to parent.
 void setVariable(java.lang.String name, java.lang.Object o)
          Override the standard namespace behavior.
(package private)  boolean weHaveVar(java.lang.String name)
           
 
Methods inherited from class bsh.NameSpace
addNameSourceListener, checkAssignableFrom, classLoaderChanged, clear, doSuperImport, get, getAllNames, getAllNamesAux, getAssignableForm, getClass, getGlobal, getImportedPackages, getImportedPackages, getInvocationLine, getInvocationText, getMethod, getMethodNames, getMethods, getName, getNameResolver, getNode, getParent, getVariable, getVariable, getVariableImpl, getVariableNames, identifierToClass, invokeMethod, invokeMethod, loadDefaultImports, nameSpaceChanged, prune, setMethod, setName, setNode, setParent, setTypedVariable, toString, unwrapVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

initMode

boolean initMode
When true, capture all variable assignment locally

Constructor Detail

BlockNameSpace

public BlockNameSpace(NameSpace parent)
               throws EvalError
Method Detail

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object o)
                 throws EvalError
Override the standard namespace behavior. If the variables exists in our namespace assign it there, otherwise in the parent space. i.e. only allow typed var declaration to happen in this namespace. Typed vars are handled in the ordinary way... local scope.

Overrides:
setVariable in class NameSpace
Parameters:
o - a value of null will remove the variable definition.
EvalError
See Also:
Primitive

setInitMode

public void setInitMode(boolean b)
When set to true, handle all variable assignment in this local scope - don't delegate to parent. This is used in catch blocks to initialize local parameters to the block then turned off to allow the normal BlockNameSpace behavior (which is to keep only locally declared typed variables local and pass the rest to the parent).


weHaveVar

boolean weHaveVar(java.lang.String name)

getSuper

public NameSpace getSuper()
super is our parent's super

Overrides:
getSuper in class NameSpace

getThis

This getThis(Interpreter declaringInterpreter)
this is our parent's this

Overrides:
getThis in class NameSpace

importClass

public void importClass(java.lang.String name)
delegate import to our parent

Overrides:
importClass in class NameSpace

importPackage

public void importPackage(java.lang.String name)
delegate import to our parent

Overrides:
importPackage in class NameSpace