Scope class

A simple lexical scope to track the lifetime of variables. This helps our mapping algorithm preserve variable correctness across the entire program.

Constructors

Scope([Scope? parent])
Ctor.

Properties

hashCode int
The hash code for this object.
no setterinherited
ids Map<String, String>
ID or constant -> remapped id.
final
parent Scope?
Optional parent scope. If null, this is global scope.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

advanceNextId() → void
Advances the next ID and returns it using the following algorithm: Bumps the last letter in the set to the next in the collection [a-z, A-Z, 0-9]. If the last letter was '9', then flip it back to 'a' and append a new alphabet entry to the _newId list. If _newId is empty, then the letter "a" is inserted. If _newId is of length 1 and is letter "Z", then skip numbers [0-9] b/c lua needs a non-number character for valid identifiers.
createID(String id) String
If id is not already assigned a new identifier, then constructs one with _newId. Then advances the new id set via advanceNextId.
getID(String id) String?
Returns the mapped id stored in ids. If the mapped id is not found in this scope, then walks up the Scope.parent chain until it is found. In this way we preserve lexical scoping and globals. If no id is found, null is returned.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resetNextIdFrom(Scope other) → void
Clears _nextId and copies the contents of the other's own nextId. This should be used with caution as the two scopes could shadow variables where this is not wanted.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited