SymbolTable<T> class
A hierarchical mechanism to hold a set of variables, which supports scoping and constant variables.
Constructors
-
SymbolTable({Map<
String, T> values = const {}}) - Initializes an empty symbol table.
Properties
-
allPublicVariables
→ List<
Variable< T> > -
Helper for calling allVariablesWithVisibility to fetch all public variables.
no setter
-
allVariables
→ List<
Variable< T> > -
Retrieves every variable within this scope and its ancestors.
no setter
- context ↔ T?
-
Returns the nearest context this symbol table belongs to. Returns
null
if none was set within the entire tree.getter/setter pair - depth → int
-
The depth of this symbol table within the tree. At the root, this is
0
.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isRoot → bool
-
Returns
true
if this scope has no parent.no setter -
parent
→ SymbolTable<
T> ? -
Gets the parent of this symbol table.
no setter
-
root
→ SymbolTable<
T> ? -
Resolves the symbol table at the very root of the hierarchy.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
String name, {T? value, bool? constant}) → Variable< T> - Use create instead.
-
allVariablesOfVisibility(
Visibility visibility) → List< Variable< T> > - Use allVariablesWithVisibility instead.
-
allVariablesWithVisibility(
Visibility visibility) → List< Variable< T> > -
Retrieves every variable of the given
visibility
within this scope and its ancestors. -
assign(
String name, T value) → Variable< T> -
Assigns a
value
to the variable with the givenname
, or creates a new variable. -
clone(
) → SymbolTable< T> - Creates a scope identical to this one, but with no children.
-
create(
String name, {T? value, bool? constant}) → Variable< T> - Create a new variable within this scope.
-
createChild(
{Map< String, T> values = const {}}) → SymbolTable<T> - Creates a child scope within this one.
-
fork(
{Map< String, T> values = const {}}) → SymbolTable<T> -
Creates a forked scope, derived from this one.
You may provide starter
values
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
String name, T value) → Variable< T> - Use assign instead.
-
remove(
String name) → Variable< T> ? -
Removes the variable with the given
name
from this scope, or an ancestor. -
resolve(
String name) → Variable< T> ? - Finds the variable with the given name, either within this scope or an ancestor.
-
resolveOrCreate(
String name, {T? value, bool? constant}) → Variable< T> - Finds the variable with the given name, either within this scope or an ancestor. Creates a new variable if none was found.
-
toString(
) → String -
A string representation of this object.
inherited
-
uniqueName(
String name) → String -
Returns a variation on the input
name
that is guaranteed to never be repeated within this scope.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String name) → Variable< T> ? -
operator []=(
String name, T value) → void