public class MixedBasicVariableMap extends BasicLocalVariableMap implements HierarchicalVariableMap
Constructor and Description |
---|
MixedBasicVariableMap() |
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.
|
void |
createVariablesOnTheFly()
Inform the object that variables have to be created on the fly without
previous proper registration.
|
void |
defaultVariableScopeShallBeGlobal()
Inform the object that when a variable is created on the fly without
prior declaration that would have specified if the variable is local or
global, then the variable has to be global by default.
|
void |
defaultVariableScopeShallBeLocal()
Inform the object that when a variable is created on the fly without
prior declaration that would have specified if the variable is local or
global, then the variable has to be local by default.
|
VariableMap |
getGlobalMap() |
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.
|
void |
registerGlobalVariable(String variableName)
Register a variable as a global variable.
|
void |
requireVariableDeclaration()
Inform the object that variables should not be created on the fly, but
first a variable has to be registered and can only be used afterwards.
|
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.
|
currentScopeIsGlobal, dropFrame, isGlobal, isLocal, newFrame, registerLocalVariable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dropFrame, newFrame, registerLocalVariable
getVariableNameSet
public VariableMap getGlobalMap()
getGlobalMap
in interface HierarchicalVariableMap
public RightValue getVariableValue(String variableName) throws ExecutionException
VariableMap
getVariableValue
in interface VariableMap
getVariableValue
in class BasicLocalVariableMap
null
if the variable
is not defined or does not exists.ExecutionException
public Boolean variableExists(String variableName) throws ExecutionException
VariableMap
variableExists
in interface VariableMap
variableExists
in class BasicLocalVariableMap
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
variableDefined
in class BasicLocalVariableMap
true
if the variable exists and has a defined value.ExecutionException
public void requireVariableDeclaration()
public void createVariablesOnTheFly()
Nevertheless this is the default behavior.
public void defaultVariableScopeShallBeLocal()
This is the safer solution and this is the default, since there is no previous BASIC style in this aspect.
public void defaultVariableScopeShallBeGlobal()
This is generally dangerous, however it is up to the programmer embedding the interpreter to his/her application.
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
registerGlobalVariable
in class BasicLocalVariableMap
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
setVariable
in class BasicLocalVariableMap
rightValue
- the new value of the variableExecutionException
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.
public Set<String> getVariableNameSet()
VariableMap
getVariableNameSet
in interface VariableMap
protected String converted(String name)
name
- Copyright © 2013 Verhas and Verhas Software Craftsmen. All Rights Reserved.