AsyncExecutionState class
Represents the state of an ongoing asynchronous function execution. This object tracks the progress and context needed for resumption.
Constructors
-
AsyncExecutionState({required Environment environment, required Completer<
Object?> completer, required SAstNode? nextStateIdentifier, required InterpretedFunction function, Object? lastAwaitResult, Object? lastAwaitError, StackTrace? lastAwaitStackTrace, Iterator<Object?> ? currentForInIterator, bool forLoopInitialized = false, Environment? forLoopEnvironment, SBlock? pendingFinallyBlock, Object? currentError, StackTrace? currentStackTrace, STryStatement? activeTryStatement, Object? returnAfterFinally, bool isHandlingErrorForRethrow = false, InternalInterpreterD4rtException? originalErrorForRethrow, bool isHandlingContinue = false, StreamController<Object?> ? generatorStreamController}) - Creates a new async execution state.
Properties
- activeTryStatement ↔ STryStatement?
-
Track the STryStatement we are currently inside or handling
getter/setter pair
-
awaitForIndexStack
→ List<
int> -
Stack of indices for nested await-for loops
Each level of nesting has its own index
final
-
awaitForListStack
→ List<
List< Object?> > -
Stack of lists for nested await-for loops
Each level of nesting has its own list
final
-
awaitForNodeStack
→ List<
SForStatement> -
Stack of SForStatement nodes for nested await-for loops
Used to track which await-for loop we're in
final
- awaitingStreamConversion ↔ bool
-
Flag indicating if the interpreter is currently waiting for stream conversion.
When true, indicates that a stream is being converted to a list for await-for processing.
getter/setter pair
-
completer
→ Completer<
Object?> -
The completer associated with the Future returned to the caller.
final
- currentAwaitForIndex ↔ int?
-
Current index when processing await for loops with stream conversion.
Used to track position in the converted list from a stream.
getter/setter pair
-
currentAwaitForList
↔ List<
Object?> ? -
Fields for await for loop processing
getter/setter pair
- currentError ↔ Object?
-
Track the error currently being handled (either from await or sync throw)
getter/setter pair
-
currentForInIterator
↔ Iterator<
Object?> ? -
Optional: Store the iterator for ongoing for-in loops.
getter/setter pair
- currentStackTrace ↔ StackTrace?
-
Track the stack trace currently being handled (either from await or sync throw)
getter/setter pair
- environment → Environment
-
The unique environment for this specific function call.
final
-
forInIteratorMap
→ Map<
SForStatement, Iterator< Object?> ?> -
Map of SForStatement -> Iterator for for-in loops
final
- forLoopEnvironment ↔ Environment?
-
Optional: Environment for the current standard for-loop scope.
getter/setter pair
- forLoopInitialized ↔ bool
-
Optional: Flag for standard for-loops.
getter/setter pair
- function → InterpretedFunction
-
Optional: A reference back to the function definition might be useful.
final
-
generatorStreamController
↔ StreamController<
Object?> ? -
For async* generators: the stream controller to send yields to
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCurrentlyRethrowing ↔ bool
-
Flag to indicate we are currently executing a rethrow statement
(as opposed to just being in a catch block)
getter/setter pair
- isGenerator → bool
-
For async* generators: flag indicating this is a generator execution
no setter
- isHandlingContinue ↔ bool
-
Flag to indicate that a
continueis being handled for aforloop.getter/setter pair - isHandlingErrorForRethrow ↔ bool
-
Flag to indicate if we are currently executing a catch block body.
getter/setter pair
- isInvocationResumptionMode ↔ bool
-
Flag to indicate if we are resuming an invocation with await in arguments
When true, await expressions should return the last resolved value instead of suspending
getter/setter pair
- lastAwaitError ↔ Object?
-
The error from the most recently completed Future (if it failed).
getter/setter pair
- lastAwaitResult ↔ Object?
-
The result value from the most recently completed Future (from await).
getter/setter pair
- lastAwaitStackTrace ↔ StackTrace?
-
The stack trace from the most recently completed Future (if it failed).
getter/setter pair
-
loopEnvironmentStack
→ List<
Environment> -
Stack of loop environments for nested loops
final
-
loopInitializedStack
→ List<
bool> -
Stack of initialization flags for nested loops
final
-
loopNodeStack
→ List<
SForStatement> -
Stack of SForStatement nodes corresponding to the environments
final
-
loopStack
→ List<
SAstNode> -
Stack of loop nodes (SForStatement, SWhileStatement, etc.) for break/continue.
final
- nextStateIdentifier ↔ SAstNode?
-
An identifier for the next block of code (state) to execute.
This could be an integer index, an AST node reference, etc.
(Needs further definition based on the state machine implementation).
getter/setter pair
- originalErrorForRethrow ↔ InternalInterpreterD4rtException?
-
Store the original exception wrapped for potential rethrow.
getter/setter pair
- pendingFinallyBlock ↔ SBlock?
-
Track pending finally block to execute after try/catch
getter/setter pair
- resumedFromInitializer ↔ bool
-
NEW FLAG
getter/setter pair
- returnAfterFinally ↔ Object?
-
Store return value if a return happens inside a try with a finally.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited