public class Scope
extends java.lang.Object
| Constructor and Description |
|---|
Scope(RtflRuntime runtime,
java.util.HashMap<java.lang.String,java.lang.Integer> localAliases,
java.util.ArrayList<java.lang.String> restrictedFunctions,
RtflInstruction causeInstruction,
Scope parentScope)
Instantiates a new Scope object
|
Scope(RtflRuntime runtime,
java.util.HashMap<java.lang.String,java.lang.Integer> localAliases,
RtflInstruction causeInstruction)
Instantiates a new Scope object
|
Scope(RtflRuntime runtime,
java.util.HashMap<java.lang.String,java.lang.Integer> localAliases,
RtflInstruction causeInstruction,
Scope parentScope)
Instantiates a new Scope object
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
assignVar(java.lang.String varName,
RtflType value)
Assigns the provided value to a variable with the specified name.
|
RtflInstruction |
cause()
Returns the instruction that caused the creation of this scope
|
int |
createLocalVar(java.lang.String varName,
RtflType value)
Creates a new local variable with the specified name and value.
|
Scope |
descend(RtflInstruction causeInstruction)
Descends a level and provides a new (non-reference) Scope for that level
|
RtflFunction |
function(java.lang.String funcName)
Returns the function with the specified name.
|
Scope |
parent()
Returns the parent of this Scope, null if it has none
|
void |
restrictFunc(java.lang.String funcName)
Restricts a function from being executed in this Scope
|
RtflRuntime |
runtime()
Returns this scope's Runtime
|
Scope[] |
scopeStack()
Returns the full scope stack, starting from the top level scope down to the current scope
|
void |
undefineFunc(java.lang.String funcName)
Undefines the specified function
|
int |
undefineVar(java.lang.String varName)
Undefines the variable with the specified name.
|
java.util.HashMap<java.lang.String,java.lang.Integer> |
variableAliases()
Returns a map of local variable name aliases to their internal IDs
|
RtflType |
varValue(java.lang.String varName)
Returns the value of the provided variable name.
|
public Scope(RtflRuntime runtime, java.util.HashMap<java.lang.String,java.lang.Integer> localAliases, RtflInstruction causeInstruction)
runtime - the Runtime associated with this scopelocalAliases - all aliases to local variables visible to this scopecauseInstruction - the instruction that caused this new scopepublic Scope(RtflRuntime runtime, java.util.HashMap<java.lang.String,java.lang.Integer> localAliases, RtflInstruction causeInstruction, Scope parentScope)
runtime - the Runtime associated with this scopelocalAliases - all aliases to local variables visible to this scopecauseInstruction - the instruction that caused this new scopeparentScope - the scope above this scopepublic Scope(RtflRuntime runtime, java.util.HashMap<java.lang.String,java.lang.Integer> localAliases, java.util.ArrayList<java.lang.String> restrictedFunctions, RtflInstruction causeInstruction, Scope parentScope)
runtime - the Runtime associated with this scopelocalAliases - all aliases to local variables visible to this scoperestrictedFunctions - a list of functions that cannot be called in this scope or any of its childrencauseInstruction - the instruction that caused this new scopeparentScope - the scope above this scopepublic Scope parent()
public RtflRuntime runtime()
public RtflInstruction cause()
public java.util.HashMap<java.lang.String,java.lang.Integer> variableAliases()
public boolean assignVar(java.lang.String varName,
RtflType value)
throws RuntimeException
varName - the name of the variablevalue - the value to assignRuntimeException - if the specified variable does not existpublic int createLocalVar(java.lang.String varName,
RtflType value)
varName - the variable namevalue - the value to assignpublic int undefineVar(java.lang.String varName)
throws RuntimeException
varName - the name of the variable to undefineRuntimeException - if no variable with the specified name existspublic void undefineFunc(java.lang.String funcName)
funcName - The Name of the function to undefinepublic void restrictFunc(java.lang.String funcName)
funcName - The name of the function to restrictpublic RtflType varValue(java.lang.String varName) throws RuntimeException
varName - the variable nameRuntimeException - if no variable with the specified name existspublic RtflFunction function(java.lang.String funcName) throws RuntimeException
funcName - the function nameRuntimeException - if the function does not exist or is restrictedpublic Scope[] scopeStack()
public Scope descend(RtflInstruction causeInstruction)
causeInstruction - the instruction that caused this new scope