DartBlockEnvironment class
Models the scope of variables by storing the values for each variable name in a simple Map.
- Annotations
-
- @JsonSerializable.new(explicitToJson: true)
Constructors
-
DartBlockEnvironment(int key, {DartBlockEnvironment? parent, required List<
DartBlockEnvironment> children}) -
DartBlockEnvironment.fromJson(Map<
String, dynamic> json) -
NOTE: The serialized form intentionally omits the upward
parentlink to avoid infinite recursion (child -> parent -> child ...) during JSON (de)serialization. We call the generated_$DartBlockEnvironmentFromJsonto deserialize children (downward links) and then restore parent references in-memory via_rebuildParentReferences().factory
Properties
-
children
→ List<
DartBlockEnvironment> -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → int
-
If indicated, the parent property provides the link to the parent Environment
which contains this Environment. This models for example the nesting of
code blocks, where for example variables declared in a for-loop should not
be accessible after exiting the loop.
The highest-up Environment (scope) has its parent property set to null,
thus indicating it is the "global" scope.
final
- parent → DartBlockEnvironment?
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addChild(
DartBlockEnvironment child) → void -
assignValueToVariable(
DartBlockArbiter arbiter, String variableName, DartBlockValue? value) → void - Assign a value to an existing variable based on its name.
-
clearChildren(
) → void -
clearMemory(
) → void -
clone(
) → DartBlockEnvironment - Create a deep copy of this environment (including children and memory).
-
copyFrom(
DartBlockEnvironment environment) → void -
declareVariable(
DartBlockArbiter arbiter, String variableName, DartBlockDataType dataType, DartBlockValue? value) → void - Declare a variable using the given name and optionally the initial value.
-
get(
String variableName) → DartBlockValue? - Get the current value associated with the given variable name.
-
getAllValues(
DartBlockArbiter arbiter) → Map< DartBlockVariableDefinition, String?> -
getContainingEnvironment(
String variableName) → DartBlockEnvironment? - Search for the Environment which stores the value mapped to the given variable name (key). If a given key is not found in the current Environment, it may still be found in a higher up (parent) Environment, hence this function recursively searches for the parent Environment which contains this key.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setParent(
DartBlockEnvironment? parent) → void -
toJson(
) → Map< String, dynamic> -
NOTE:
parentis excluded from JSON output on purpose to prevent cyclic traversal of the object graph (parent -> child -> parent -> ...), which causes stack overflows. Only downward links (children) are serialized. Parent links are restored afterfromJsonruns_rebuildParentReferences(). -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited