ExecutionContext class

Represents a single execution context in the context stack.

Each context tracks:

  • Working directory for relative path resolution
  • Source file being executed (null for interactive)
  • Session recording preference
  • Output suppression (silent mode)
  • Multiline mode and buffer (per-context to fix nesting bug)

Example context stack during nested replay:

1. cli.replay('setup.d4rt')
   └── Context: { cwd: '/project', file: 'setup.d4rt' }

2. setup.d4rt calls .load libs/common.d4rt
   └── Context: { cwd: '/project/libs', file: 'common.d4rt' }

3. common.d4rt completes → pop → restore cwd to '/project'
4. setup.d4rt completes → pop → restore original cwd

Constructors

ExecutionContext({required String workingDirectory, String? sourceFile, bool recordToSession = true, bool silent = false, ExecutionContext? parent})
Creates an execution context.

Properties

depth → int
The depth of this context (0 for root).
no setter
hashCode → int
The hash code for this object.
no setterinherited
isMultilineMode → bool
Whether this context is in multiline mode.
no setter
isRoot → bool
Whether this is the root (interactive) context.
no setter
multilineBuffer → List<String>
Accumulated lines in multiline mode for this context.
final
multilineMode ↔ MultilineMode
Current multiline input mode for this context.
getter/setter pair
parent → ExecutionContext?
The parent context in the stack.
final
recordToSession → bool
Whether commands should be recorded to the active session.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
silent → bool
Whether output is suppressed.
final
sourceFile → String?
The source file being executed.
final
workingDirectory → String
The working directory for this context.
final

Methods

addMultilineLine(String line) → void
Adds a line to the multiline buffer.
clearMultilineBuffer() → void
Clears the multiline buffer and resets mode to none.
getMultilineCode() → String
Gets the accumulated multiline buffer as joined code.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startMultilineMode(MultilineMode mode) → void
Starts multiline mode with the given type.
toString() → String
A string representation of this object.
override

Operators

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