org.concord.util.script
Class NameStack
java.lang.Object
|
+--org.concord.util.script.ScriptObject
|
+--org.concord.util.script.NameStack
- All Implemented Interfaces:
- java.beans.BeanInfo
- public class NameStack
- extends ScriptObject
The NameStack class implements a stack frame mechanism for the
script interpreter. It is responsible for storing and finding
variables and varible values. Each time a script method is invoked
a new NameStack stack frame is created and linked to the previous
one. All values calculated by the interpreter are pushed on and
popped off the current instance of the NameStack. This makes it
easier to provide global, script and method variables scope.
The NameStack consists of two Java Stack objects, one for names and
one for values. Name-value pairs can be pushed and popped, and in
addition, name lookup and enter methods are provided to make it
easy to read and write variable values.
- Version:
- $Revision: 1.2 $ $Date: 2001/11/08 20:51:36 $
- Author:
- $Author: ed $
Fields inherited from class org.concord.util.script.ScriptObject |
beginColumn, beginLine, debug, deleted, doConversion, endColumn, endLine, name, nil, runtimeTable, script |
Fields inherited from interface java.beans.BeanInfo |
ICON_COLOR_16x16, ICON_COLOR_32x32, ICON_MONO_16x16, ICON_MONO_32x32 |
Methods inherited from class org.concord.util.script.ScriptObject |
findConstructor, findMethod, getAdditionalBeanInfo, getArrayValue, getAtom, getBeanDescriptor, getCurrentFrame, getDefaultEventIndex, getDefaultPropertyIndex, getEventSetDescriptors, getField, getFieldValue, getIcon, getMethodDescriptors, getName, getPropertyDescriptors, getScript, interpret, popFrame, pushFrame, setArrayValue, setCurrentFrame, setFieldValue, setName, setScript, setSourceBounds |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
frameSize
protected int frameSize
globals
protected NameStack globals
members
protected NameStack members
imports
protected NameStack imports
values
protected java.util.Stack values
names
protected java.util.Stack names
indent
protected static java.lang.String indent
skipped
public boolean skipped
finished
public boolean finished
returned
public boolean returned
throwUp
public boolean throwUp
isWhen
public boolean isWhen
result
public java.lang.Object result
node
public ScriptObject node
NameStack
public NameStack()
NameStack
public NameStack(boolean doThrow)
NameStack
public NameStack(NameStack previous)
delete
public void delete()
- Overrides:
delete
in class ScriptObject
deleteAll
public void deleteAll()
init
protected void init(NameStack previous,
boolean doThrow)
getNames
public java.util.Stack getNames()
getValues
public java.util.Stack getValues()
lookup
public java.lang.Object lookup(java.lang.String varName)
- Find a variable value in the stack frame.
- Parameters:
String
- varName - name of the variable- Returns:
- Object objValue - value of the variable
- Throws:
NoSuchElementException
- (RuntimeException)
lookup
public java.lang.Object lookup(java.lang.String varName,
boolean doThrow)
enter
public void enter(java.lang.String varName,
java.lang.Object objValue)
- Set a variable value in the stack frame.
- Parameters:
String
- varName - name of the variableObject
- objValue - value of the variable- Throws:
NoSuchElementException
- (RuntimeException)
enter
public void enter(java.lang.String varName,
java.lang.Object objValue,
boolean doThrow)
addLocals
public int addLocals(java.util.Stack nameStack,
java.lang.Object[] args)
- Add parameters and locals to stack frame.
This method is used to set up the stack frame context
so that the method statements can be interpreted and
have access to the parameters and locals.
- Parameters:
Stack
- parameters - formal parameters name listStack
- actuals - actual parameters value listStack
- locals - local variables name list
removeLocals
public void removeLocals(int n)
getParent
public NameStack getParent()
- This method is used to pop a stack frame. When a acript method
is done it calls this to restore the getCurrentFrame() variable.
getSize
public int getSize()
setMembers
public void setMembers(NameStack stack)
getMembers
public NameStack getMembers()
setGlobals
public void setGlobals(NameStack stack)
getGlobals
public NameStack getGlobals()
setImports
public void setImports(NameStack stack)
getImports
public NameStack getImports()
push
public void push(java.lang.String varName,
java.lang.Object objValue)
push
public void push(java.lang.Object objValue)
pop
public java.lang.Object pop()
remove
public boolean remove(java.lang.String objName)
print
public void print()