public class BasicLocalVariableMap extends Object implements LocalVariableMap
Constructor and Description |
---|
BasicLocalVariableMap() |
Modifier and Type | Method and Description |
---|---|
protected String |
converted(String name)
Converts the name of a variable in a way that if the name 'a' and name
'b' results the same string converted then 'a' and 'b' are treated from
some aspects as the same variable name.
|
boolean |
currentScopeIsGlobal()
Returns true if the current scope is global, there no no any local stack
frame open.
|
void |
dropFrame()
Drop the current frame and pop off the map from the top of the stack.
|
Set<String> |
getVariableNameSet()
Get the set of the variables stored in the variable map so that the
caller can iterate through the variables.
|
RightValue |
getVariableValue(String variableName)
Get the value of a variable.
|
boolean |
isGlobal(String variableName) |
boolean |
isLocal(String variableName) |
void |
newFrame()
Push the actual Map onto the stack of maps and create a new empty stack.
|
void |
registerGlobalVariable(String variableName)
Register a variable as a global variable.
|
void |
registerLocalVariable(String variableName)
Define the variable as a local variable in a local environment.
|
void |
setCaseFreak()
Tell the object that the variable names has to be cased only one way.
|
void |
setCaseIgnorant()
Tell the object that the variable handling is case insensitive.
|
void |
setCaseSensitive()
Tell the object that the variable names are handled in a case sensitive
way.
|
void |
setVariable(String variableName,
RightValue rightValue)
Set the value of the variable.
|
Boolean |
variableDefined(String variableName)
Checks that a variable exists and has a defined value in this map.
|
Boolean |
variableExists(String variableName)
Checks that a variable exists in this map.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getVariableNameSet
public RightValue getVariableValue(String variableName) throws ExecutionException
VariableMap
getVariableValue
in interface VariableMap
null
if the variable
is not defined or does not exists.ExecutionException
public Boolean variableExists(String variableName) throws ExecutionException
VariableMap
variableExists
in interface VariableMap
true
if the variable exists, even if the variable has
undefined value. false
if the variable does not exist in
this map.ExecutionException
public Boolean variableDefined(String variableName) throws ExecutionException
VariableMap
null
.variableDefined
in interface VariableMap
true
if the variable exists and has a defined value.ExecutionException
public void setVariable(String variableName, RightValue rightValue) throws ExecutionException
VariableMap
You can set a variable to undefined passing null
to this method
as rightValue
.
setVariable
in interface VariableMap
rightValue
- the new value of the variableExecutionException
public void newFrame()
LocalVariableMap
newFrame
in interface LocalVariableMap
public void dropFrame()
LocalVariableMap
dropFrame
in interface LocalVariableMap
public boolean currentScopeIsGlobal()
public void registerGlobalVariable(String variableName) throws ExecutionException
LocalVariableMap
Interpreters 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 method can be used to declare that a variable is used in the local environment referring to the global variable.
registerGlobalVariable
in interface LocalVariableMap
ExecutionException
public void registerLocalVariable(String variableName) throws ExecutionException
LocalVariableMap
LocalVariableMap.registerGlobalVariable(String)
registerLocalVariable
in interface LocalVariableMap
ExecutionException
public boolean isGlobal(String variableName) throws ExecutionException
ExecutionException
public boolean isLocal(String variableName) throws ExecutionException
ExecutionException
public Set<String> getVariableNameSet()
VariableMap
getVariableNameSet
in interface VariableMap
public void setCaseSensitive()
It is not recommended to use this mode, however most modern programming languages do this.
public void setCaseFreak()
It is the recommended behavior, however BASIC implementations rarely exhibit such variable name handling this is not the default.
public void setCaseIgnorant()
It is not recommended to use this mode, however most BASIC implementation do this. This is the default behavior.
protected String converted(String name)
name
- Copyright © 2013 Verhas and Verhas Software Craftsmen. All Rights Reserved.