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
errorAfterFinally Object?
An error that is only passing through a finally block: it was raised in a protected region that has no matching catch clause, so it must be re-raised at the enclosing try once the finally has finished.
getter/setter pair
errorAfterFinallyStackTrace StackTrace?
The stack trace belonging to errorAfterFinally.
getter/setter pair
errorAfterFinallyTry STryStatement?
The try whose finally block errorAfterFinally is waiting for. Non-null exactly while an error is held, and used to recognise the moment the block ends — the error must resume at the enclosing try, not this one.
getter/setter pair
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 continue is being handled for a for loop.
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
loopEntryDepths Map<SAstNode, LoopStackDepths>
How deep each loop stack was when a for loop was entered.
final
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
resolvedAwaitResults Map<SAstNode, Object?>
Results of the await sites already resolved while resuming the statement currently in flight, keyed by the AwaitExpression node itself.
final
resumedFromInitializer bool
NEW FLAG
getter/setter pair
resumeErrorAfterFinally bool
Set when the finally block named by errorAfterFinallyTry has finished, so the next state-machine step re-raises the held error instead of executing the statement that follows the try.
getter/setter pair
resumingStatementHasMoreAwaits bool
Set while resuming a statement that still has an unreached await site.
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
recordLoopEntry(SAstNode loop) → void
Records that loop is being entered, before it pushes anything.
toString() String
A string representation of this object.
inherited
truncateLoopStacks(LoopStackDepths depths) → void
Restores every loop stack to depths, forgetting the loops that are removed — so a loop entered again later starts from scratch instead of resuming a stale iterator or list.

Operators

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