java.lang.Object
technology.sola.script.runtime.ScopeTable
ScopeTable holds variable resolutions at various depths of scope.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBegins a new scope for variables to be resolved.voidMarks a variable as declared for the current scope.voidMarks a variable is defined for the current scope.voidMarks a variable is defined for the current scope.voidendScope()Ends the current scope for variables to be resolved.@Nullable IntegergetDistance(Expr expr) Gets the distance needed to resolve the correct value for the desired variable.booleanisDeclaredInScope(Token name) Checks if a variable has been declared in the current scope or not.booleanisDefinedInScope(Token name) Checks if a variable has been defined in the current scope or not.booleanisSelfReferenceVariableInitialization(Expr.Variable expression) Utility method to check if aExpr.Variableexpression is being used to initialize itself.voidresolveLocal(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- theExprto 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- theTokenfor 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- theTokenfor the name of the variable
-
define
Marks a variable is defined for the current scope.- Parameters:
name- theTokenfor 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- theTokenfor 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- theTokenfor 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.Variableexpression is being used to initialize itself.- Parameters:
expression- the variable expression- Returns:
- true if it is a self referencing variable initialization
-