java.lang.Object
technology.sola.script.runtime.ScopeTable
ScopeTable holds variable resolutions at various depths of scope.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Begins a new scope for variables to be resolved.void
Marks a variable as declared for the current scope.void
Marks a variable is defined for the current scope.void
Marks a variable is defined for the current scope.void
endScope()
Ends the current scope for variables to be resolved.@Nullable Integer
getDistance
(Expr expr) Gets the distance needed to resolve the correct value for the desired variable.boolean
isDeclaredInScope
(Token name) Checks if a variable has been declared in the current scope or not.boolean
isDefinedInScope
(Token name) Checks if a variable has been defined in the current scope or not.boolean
isSelfReferenceVariableInitialization
(Expr.Variable expression) Utility method to check if aExpr.Variable
expression is being used to initialize itself.void
resolveLocal
(Expr expr, Token name) Resolves the nested depth of a local variable usage for anExpr
.
-
Constructor Details
-
ScopeTable
public ScopeTable()
-
-
Method Details
-
getDistance
Gets the distance needed to resolve the correct value for the desired variable.- Parameters:
expr
- theExpr
to get the value for- Returns:
- the distance to resolve the variable's value
-
beginScope
public void beginScope()Begins a new scope for variables to be resolved. -
endScope
public void endScope()Ends the current scope for variables to be resolved. -
resolveLocal
Resolves the nested depth of a local variable usage for anExpr
.- Parameters:
expr
- the expression to resolve the local variable usage forname
- theToken
for the name of the variable
-
declare
Marks a variable as declared for the current scope. A declared variable cannot be used to initialize itself.- Parameters:
name
- theToken
for the name of the variable
-
define
Marks a variable is defined for the current scope.- Parameters:
name
- theToken
for the name of the variable
-
define
Marks a variable is defined for the current scope.- Parameters:
name
- the name of the variable
-
isDeclaredInScope
Checks if a variable has been declared in the current scope or not. Return false if there has been no scope started.- Parameters:
name
- theToken
for the name of the variable- Returns:
- true if the variable has already been declared in the current scope
-
isDefinedInScope
Checks if a variable has been defined in the current scope or not. Return false if there has been no scope started.- Parameters:
name
- theToken
for the name of the variable- Returns:
- true if the variable has already been defined in the current scope
-
isSelfReferenceVariableInitialization
Utility method to check if aExpr.Variable
expression is being used to initialize itself.- Parameters:
expression
- the variable expression- Returns:
- true if it is a self referencing variable initialization
-