Class MixedBasicVariableMap
- All Implemented Interfaces:
HierarchicalVariableMap,LocalVariableMap,VariableMap
- Author:
- Peter Verhas date June 22, 2012
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringConverts 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.voidInform the object that variables have to be created on the fly without previous proper registration.voidInform 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.voidInform 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.Get the set of the variables stored in the variable map so that the caller can iterate through the variables.getVariableValue(String variableName) Get the value of a variable.voidregisterGlobalVariable(String variableName) Register a variable as a global variable.voidInform 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.voidTell the object that the variable names has to be cased only one way.voidTell the object that the variable handling is case insensitive.voidTell the object that the variable names are handled in a case sensitive way.voidsetVariable(String variableName, RightValue rightValue) Set the value of the variable.variableDefined(String variableName) Checks that a variable exists and has a defined value in this map.variableExists(String variableName) Checks that a variable exists in this map.Methods inherited from class com.scriptbasic.memory.BasicLocalVariableMap
currentScopeIsGlobal, dropFrame, isGlobal, isLocal, newFrame, registerLocalVariableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.scriptbasic.interfaces.LocalVariableMap
dropFrame, newFrame, registerLocalVariableMethods inherited from interface com.scriptbasic.interfaces.VariableMap
getVariableNameSet
-
Constructor Details
-
MixedBasicVariableMap
public MixedBasicVariableMap()
-
-
Method Details
-
getGlobalMap
- Specified by:
getGlobalMapin interfaceHierarchicalVariableMap
-
getVariableValue
Description copied from interface:VariableMapGet the value of a variable.- Specified by:
getVariableValuein interfaceVariableMap- Overrides:
getVariableValuein classBasicLocalVariableMap- Parameters:
variableName- parameter- Returns:
- the right value the variable has or
nullif the variable is not defined or does not exists. - Throws:
ScriptBasicException- in case there is an exception
-
variableExists
Description copied from interface:VariableMapChecks that a variable exists in this map.- Specified by:
variableExistsin interfaceVariableMap- Overrides:
variableExistsin classBasicLocalVariableMap- Parameters:
variableName- parameter- Returns:
trueif the variable exists, even if the variable has undefined value.falseif the variable does not exist in this map.- Throws:
ScriptBasicException- in case there is an exception
-
variableDefined
Description copied from interface:VariableMapChecks that a variable exists and has a defined value in this map. Undefined value is represented bynull.- Specified by:
variableDefinedin interfaceVariableMap- Overrides:
variableDefinedin classBasicLocalVariableMap- Parameters:
variableName- parameter- Returns:
trueif the variable exists and has a defined value.- Throws:
ScriptBasicException- in case there is an exception
-
requireVariableDeclaration
public 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. -
createVariablesOnTheFly
public void createVariablesOnTheFly()Inform the object that variables have to be created on the fly without previous proper registration. This is the usual BASIC way that BASIC programmers got used to, though this is more dangerous.Nevertheless this is the default behavior.
-
defaultVariableScopeShallBeLocal
public 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.This is the safer solution and this is the default, since there is no previous BASIC style in this aspect.
-
defaultVariableScopeShallBeGlobal
public 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.This is generally dangerous, however it is up to the programmer embedding the interpreter to his/her application.
-
registerGlobalVariable
Description copied from interface:LocalVariableMapRegister 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.
- Specified by:
registerGlobalVariablein interfaceLocalVariableMap- Overrides:
registerGlobalVariablein classBasicLocalVariableMap- Parameters:
variableName- parameter- Throws:
ScriptBasicException- in case of exception
-
setVariable
Description copied from interface:VariableMapSet the value of the variable. If the variable did not exist then the variable is automatically created. If the variable had undefined value then the new value will be the one defined by the argument.You can set a variable to undefined passing
nullto this method asrightValue.- Specified by:
setVariablein interfaceVariableMap- Overrides:
setVariablein classBasicLocalVariableMap- Parameters:
variableName- parameterrightValue- the new value of the variable- Throws:
ScriptBasicException- in case there is an exception
-
setCaseSensitive
public void setCaseSensitive()Tell the object that the variable names are handled in a case sensitive way. It means that the variables 'vaRIable' and 'variABLE' are two different variables and can live in the global or the actual local variable name space along with each other in peace.It is not recommended to use this mode, however most modern programming languages do this.
-
setCaseFreak
public void setCaseFreak()Tell the object that the variable names has to be cased only one way. It means that there can not be a variable named "vaRIable' and 'variABLE' at the same time.It is the recommended behavior, however BASIC implementations rarely exhibit such variable name handling this is not the default.
-
setCaseIgnorant
public void setCaseIgnorant()Tell the object that the variable handling is case insensitive. It means that the variables 'vaRIable' and 'variABLE' denote the same variable.It is not recommended to use this mode, however most BASIC implementation do this. This is the default behavior.
-
getVariableNameSet
Description copied from interface:VariableMapGet the set of the variables stored in the variable map so that the caller can iterate through the variables.- Specified by:
getVariableNameSetin interfaceVariableMap- Returns:
- return value
-
converted
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. The generic approach is simply upper casing.- Parameters:
name- parameter- Returns:
- return value
-