Package com.scriptbasic.interfaces
Interface LocalVariableMap
- All Superinterfaces:
VariableMap
- All Known Subinterfaces:
HierarchicalVariableMap
- All Known Implementing Classes:
BasicLocalVariableMap,MixedBasicVariableMap
public interface LocalVariableMap extends VariableMap
A variable map structure that can manage many maps in a stack structure. Any
call to methods inherited from
VariableMap works on the map at the top
of the stack.- Author:
- Peter Verhas date June 22, 2012
-
Method Summary
Modifier and Type Method Description voiddropFrame()Drop the current frame and pop off the map from the top of the stack.voidnewFrame()Push the actual Map onto the stack of maps and create a new empty stack.voidregisterGlobalVariable(java.lang.String variableName)Register a variable as a global variable.voidregisterLocalVariable(java.lang.String variableName)Define the variable as a local variable in a local environment.Methods inherited from interface com.scriptbasic.interfaces.VariableMap
getVariableNameSet, getVariableValue, setVariable, variableDefined, variableExists
-
Method Details
-
newFrame
void newFrame()Push the actual Map onto the stack of maps and create a new empty stack. This is what a program has to do when a function is called. The local variables (if any) are pushed on the stack and a new stack frame is opened. -
dropFrame
void dropFrame()Drop the current frame and pop off the map from the top of the stack. This is what programs have to do when a RETURN is executed from a function. -
registerGlobalVariable
Register a variable as a global variable. This is needed when an implementing class manages the global as well as the local variables.Interpreters may handle variables differently. When a variable is not defined using some keyword as 'LOCAL' or 'GLOBAL' then the interpreter may treat the variable default local, may treat default global or may raise error. This is configurable in ScriptBasic.
This method can be used to declare that a variable is used in the local environment referring to the global variable.
- Parameters:
variableName- parameter- Throws:
ScriptBasicException- in case of exception
-
registerLocalVariable
Define the variable as a local variable in a local environment. For more information see the documentation of the methodregisterGlobalVariable(String)- Parameters:
variableName- parameter- Throws:
ScriptBasicException- in case of exception
-