runtime library
D4rt Runtime - Interpreter and execution environment
This library provides the runtime components for D4rt:
- Interpreter visitor for executing SAstNode trees
- Environment for variable scope management
- Bridge infrastructure for native-interpreted interop
- Standard library implementations
This library has NO dependency on the analyzer package. It can execute pre-parsed SAstNode trees from JSON or any source.
For parsing source code to SAstNode, use the tom_d4rt_exec package which provides the full D4rt API with parser integration.
Classes
- AstBundle
- A transportable unit containing an entry point and all required modules.
- AstBundleFormat
- Configuration constants for the AstBundle file format.
- AstBundleManifest
- Describes the contents of an AstBundle ZIP archive.
- AstModuleLoader
- Lookup-only module resolver for pre-parsed AST bundles.
- AsyncExecutionState
- Represents the state of an ongoing asynchronous function execution. This object tracks the progress and context needed for resumption.
- AsyncSuspensionRequest
- Represents a request to suspend execution and wait for a Future. This object is returned by visitor methods when an await is encountered.
- BoundBridgedSuper
- Represents 'super' bound to an instance when the direct superclass is bridged.
- BoundExtensionCallable
- A bound wrapper for any ExtensionMemberCallable.
- BoundExtensionMethodCallable
- Represents an extension method bound to a target instance.
- BoundSuper
- BridgedClass
- Represents a natively defined class that is accessible to the interpreter.
- BridgedClassInfo
- Information about a bridged class.
- BridgedEnum
- Represents an enum type defined in the host Dart environment and bridged into the interpreter. It holds the definition and provides access to its values.
-
BridgedEnumDefinition<
T extends Enum> - BridgedEnumInfo
- Information about a bridged enum.
- BridgedEnumMixinMethodCallable
- Callable for bridged mixin methods on enum values
- BridgedEnumValue
- Represents a specific value of a BridgedEnum. It holds the value's name, index, and the original native enum value.
- BridgedExtensionDefinition
- Definition for a bridged native extension.
-
BridgedInstance<
T extends Object> - Represents an instance of a bridged native class.
- BridgedMethodCallable
- BridgedMixinMethodCallable
- Represents a method call on a bridged mixin applied to an interpreted instance.
- BridgedStaticMethodCallable
- Represents a static method from a bridged class that can be passed as a value
- BridgedSuperMethodCallable
- Represents a method call on a bridged superclass object. Stores the specific native super object and the method adapter.
- Callable
- ClassInfo
- Information about a class declaration.
- D4
- D4 - Static helper class for D4rt bridge code generation.
- D4InterpretedProxy
- Marker for native objects produced by an interface-proxy factory that wrap an InterpretedInstance.
- D4rtConfiguration
- Complete configuration snapshot of a D4rt interpreter instance.
- D4rtDiag
- Lightweight, always-on interpreter instrumentation counters.
- D4rtGlobalsUserBridge
- Annotation to mark a class as a D4rt globals user bridge override.
- D4rtRunner
- D4rtRunner - Execute pre-parsed AST trees without analyzer dependency.
- D4rtUserBridge
- Annotation to mark a class as a D4rt user bridge override.
- D4UserBridge
- Base class for user-defined bridge overrides.
- D4UserProxy
- Base class for user-defined proxy-generation directives.
- D4UserRelaxer
- Base class for user-provided relaxer factories.
- DangerousPermission
- Dangerous permissions that should be granted with extreme caution.
- DeclarationInfo
- Represents information about a declaration in the executed code. This is the base class for all introspection results.
- DeclarationVisitor
- Visitor for the first pass: Declares class and mixin placeholders.
- EnumInfo
- Information about an enum declaration.
- Environment
- Represents the execution environment for interpreted code.
- EnvironmentState
- Represents the current state of the D4rt environment.
- EnvironmentVariableInfo
- Information about a variable in the environment.
- ErrorReporter
- Static error reporter that tracks all created D4rtExceptions.
- ExtensionInfo
- Information about an extension declaration.
- ExtensionMemberCallable
- Abstract interface for extension member callables.
- FilesystemPermission
- Filesystem permissions control file and directory operations.
- FunctionInfo
- Information about a function declaration.
-
GeneralizingSAstVisitor<
T> - A visitor that adds category-level fallback methods between specific visit methods and visitNode.
- GlobalFunctionInfo
- Information about a registered global function.
- GlobalGetter
- A wrapper for lazy-evaluated global getters with optional setter support.
- GlobalGetterInfo
- Information about a registered global getter.
- GlobalVariableInfo
- Information about a registered global variable.
- ImportConfiguration
- Configuration for a single import library.
- InterpretedClass
- Represents a class definition at runtime.
- InterpretedEnum
- Represents an enum definition at runtime.
- InterpretedEnumValue
- Represents a specific value within an enum at runtime.
- InterpretedExtension
- InterpretedExtensionMethod
- InterpretedExtensionType
- Lim-1 FIX: Represents an extension type definition at runtime. Extension types are inline classes that provide a zero-cost abstraction.
- InterpretedExtensionTypeInstance
- An instance of an extension type
- InterpretedFunction
- InterpretedInstance
- Represents an instance of an InterpretedClass at runtime.
- InterpretedRecord
- Represents an interpreted record value.
- InterpreterVisitor
- Main visitor that walks the AST and interprets the code. Uses a two-pass approach (DeclarationVisitor first).
- IntrospectionBuilder
- Helper class to build introspection results from an environment.
- IntrospectionResult
- Result of introspection containing all declarations found in the executed code.
- IsolatePermission
- Isolate permissions control isolate creation and communication.
- LateVariable
- Represents a late variable that supports lazy initialization
- LibraryClass
- Wrapper class for library-scoped bridged classes.
- LibraryEnum
- Wrapper class for library-scoped bridged enums.
- LibraryExtension
- Wrapper class for library-scoped bridged extensions.
- LibraryFunction
- Wrapper class for library-scoped functions.
- LibraryGetter
- Wrapper class for library-scoped getters.
- LibrarySetter
- Wrapper class for library-scoped setters.
- LibraryVariable
- Wrapper class for library-scoped variables.
- LoadedModule
- A loaded module with its AST and exported environment.
- Logger
- ModuleContext
- Abstract interface for module loading and context tracking.
- NativeExtensionCallable
- A callable for a native (bridged) extension member.
- NativeFunction
- NetworkPermission
- Network permissions control network operations.
- NoOpModuleContext
- A no-op module context for executing pre-parsed AST without import support.
- Permission
- Base class for all permissions in the d4rt security system.
- PermissionInfo
- Information about a granted permission.
- ProcessRunPermission
- Process permissions control process execution.
- RuntimeType
- Common interface for types defined at runtime (interpreted or bridged).
- RuntimeValue
- Common interface for values defined at runtime (interpreted or bridged instances).
- SAdjacentStrings
- SAnnotatedNode
-
Base class for nodes that have documentation comments and metadata.
Mirrors analyzer's
AnnotatedNode. - SAnnotation
- SArgumentList
- SAsExpression
- SAssertInitializer
- SAssertStatement
- SAssignedVariablePattern
- An assigned variable pattern that binds to an existing variable.
- SAssignmentExpression
- SAstNode
- Base class for all serializable AST nodes
- SAstNodeFactory
- Factory for deserializing AST nodes
-
SAstVisitor<
T> - A visitor for the serializable AST node hierarchy.
- SAwaitExpression
- SBinaryExpression
- SBlock
- SBlockFunctionBody
- SBooleanLiteral
- SBreakStatement
- SCascadeExpression
- SCaseClause
-
A
caseclause used in if-case statements. - SCastPattern
-
A cast pattern (e.g.,
pattern as Type). - SCatchClause
- SClassDeclaration
- SClassMember
-
Base class for class members (methods, fields, constructors).
Mirrors analyzer's
ClassMember. - SCollectionElement
-
Base class for collection elements (expressions, spread, if/for elements, map entries).
Mirrors analyzer's
CollectionElement. - SCombinator
-
Base class for show/hide combinators on directives.
Mirrors analyzer's
Combinator. - SComment
- SCompilationUnit
- A complete Dart compilation unit (file)
- SCompilationUnitMember
-
Base class for compilation unit members (top-level declarations).
Mirrors analyzer's
CompilationUnitMember. - SConditionalExpression
- SConstantPattern
-
A constant expression pattern (e.g.,
case 42:,case const Foo():). - SConstructorDeclaration
- SConstructorFieldInitializer
- SConstructorInitializer
-
Base class for constructor initializers.
Mirrors analyzer's
ConstructorInitializer. - SConstructorName
- SConstructorReference
-
A constructor reference expression:
MyClass.neworMyClass<T>.named - SContinueStatement
- SDartPattern
-
Base class for Dart patterns (Dart 3 pattern matching).
Mirrors analyzer's
DartPattern. - SDeclaration
-
Base class for all declarations.
Mirrors analyzer's
Declaration. - SDeclaredIdentifier
- Declared identifier in a for-each loop
- SDeclaredVariablePattern
-
A declared variable pattern (e.g.,
var x,int x,final String name). - SDefaultFormalParameter
- SDirective
-
Base class for all directives (import, export, part, library).
Mirrors analyzer's
Directive. - SDoStatement
- SDoubleLiteral
- SEmptyFunctionBody
- SEmptyStatement
- SEnumConstantDeclaration
- SEnumDeclaration
- SExportDirective
- SExpression
-
Base class for all expressions. Extends CollectionElement because
expressions can appear in collection literals.
Mirrors analyzer's
Expression. - SExpressionFunctionBody
- SExpressionStatement
- SExtendsClause
- SExtensionDeclaration
- SExtensionTypeDeclaration
-
An extension type declaration:
extension type MyType(int value) implements int { ... } - SFieldDeclaration
- SFieldFormalParameter
- SForEachParts
-
Base class for for-each loop parts.
Mirrors analyzer's
ForEachParts. - SForEachPartsWithDeclaration
- For-each loop parts with a declaration
- SForEachPartsWithIdentifier
- For-each loop parts with an identifier
- SForEachPartsWithPattern
- For-each loop parts with a pattern destructuring on each element.
- SForEachStatement
- SForElement
- SForLoopParts
-
Base class for for-loop parts.
Mirrors analyzer's
ForLoopParts. - SFormalParameter
-
Base class for formal parameters.
Mirrors analyzer's
FormalParameter. - SFormalParameterList
- SForParts
-
Base class for traditional for-loop parts.
Mirrors analyzer's
ForParts. - SForPartsWithDeclarations
- For loop parts for standard for loops
- SForPartsWithExpression
- For loop parts with an expression initializer
- SForStatement
- SFunctionBody
-
Base class for function bodies.
Mirrors analyzer's
FunctionBody. - SFunctionDeclaration
- SFunctionDeclarationStatement
- SFunctionExpression
- SFunctionExpressionInvocation
- SFunctionReference
-
A function reference expression:
myFunc<int>(tear-off with type args) - SFunctionTypedFormalParameter
- SGenericFunctionType
- SGuardedPattern
-
A pattern with an optional
whenguard clause. - SHideCombinator
- SIdentifier
-
Base class for identifiers (simple and prefixed).
Mirrors analyzer's
Identifier. - SIfElement
- SIfStatement
- SImplementsClause
- SImportDirective
- SIndexExpression
- SInstanceCreationExpression
- SIntegerLiteral
- SInterpolationElement
-
Base class for string interpolation elements.
Mirrors analyzer's
InterpolationElement. - SInterpolationExpression
- SInterpolationString
- SInvocationExpression
-
Base class for invocation expressions (method calls, function calls).
Mirrors analyzer's
InvocationExpression. - SIsExpression
- SLabel
- SLabeledStatement
- SLibraryDirective
- SListLiteral
- SListPattern
-
A list destructuring pattern (e.g.,
[a, b, ...rest]). - SLiteral
-
Base class for all literals.
Mirrors analyzer's
Literal. - SLogicalAndPattern
-
A logical AND pattern (e.g.,
pattern1 && pattern2). - SLogicalOrPattern
-
A logical OR pattern (e.g.,
pattern1 || pattern2). - SMapLiteralEntry
- SMapPattern
-
A map destructuring pattern (e.g.,
{'key': valuePattern}). - SMapPatternEntry
-
A single entry in a map pattern (e.g.,
key: valuePattern). - SMethodDeclaration
- SMethodInvocation
- SMixinDeclaration
- SNamedCompilationUnitMember
-
Base class for named compilation unit members.
Mirrors analyzer's
NamedCompilationUnitMember. - SNamedExpression
- SNamedType
- SNamespaceDirective
-
Base class for namespace directives (import, export).
Mirrors analyzer's
NamespaceDirective. - SNativeFunctionBody
- SNormalFormalParameter
-
Base class for normal (non-default) formal parameters.
Mirrors analyzer's
NormalFormalParameter. - SNullAssertPattern
-
A null-assert pattern (e.g.,
pattern!). - SNullAwareElement
-
Represents a null-aware element in a collection literal (
?expr). - SNullCheckPattern
-
A null-check pattern (e.g.,
pattern?). - SNullLiteral
- SObjectPattern
-
An object destructuring pattern (e.g.,
MyType(field: pattern)). - SOnClause
- SParenthesizedExpression
- SParenthesizedPattern
-
A parenthesized pattern (e.g.,
(pattern)). - SPartDirective
- SPartOfDirective
- SPatternAssignment
-
A pattern assignment expression:
(a, b) = expr - SPatternField
- A field in an object or record pattern.
- SPatternFieldName
- A field name identifier in a pattern field (null name for shorthand).
- SPatternVariableDeclaration
-
A pattern variable declaration (e.g.,
var (a, b) = expr). - SPatternVariableDeclarationStatement
-
A pattern variable declaration statement:
var (a, b) = expr; - SPostfixExpression
- SPrefixedIdentifier
- SPrefixExpression
- SPropertyAccess
- SRecordLiteral
- SRecordPattern
-
A record destructuring pattern (e.g.,
(pattern, name: pattern)). - SRecordTypeAnnotation
- SRedirectingConstructorInvocation
- SRelationalPattern
-
A relational pattern (e.g.,
< 5,>= 10). - SRepresentationDeclaration
-
The representation declaration of an extension type:
(int value) - SRestPatternElement
-
A rest element in a list or map pattern (e.g.,
...subPattern). - SRethrowExpression
- SReturnStatement
- SSetOrMapLiteral
- SShowCombinator
- SSimpleFormalParameter
- SSimpleIdentifier
- SSimpleStringLiteral
- SSingleStringLiteral
-
Base class for single string literals (non-adjacent).
Mirrors analyzer's
SingleStringLiteral. - SSpreadElement
- SStatement
-
Base class for all statements.
Mirrors analyzer's
Statement. - SStringInterpolation
- SStringLiteral
-
Base class for string literals.
Mirrors analyzer's
StringLiteral. - SSuperConstructorInvocation
- SSuperExpression
- SSuperFormalParameter
- SSwitchCase
- SSwitchDefault
- SSwitchExpression
-
A switch expression:
switch (expr) { case1 => val1, ... } - SSwitchExpressionCase
-
A case in a switch expression (e.g.,
pattern => expression). - SSwitchMember
-
Base class for switch case/default members.
Mirrors analyzer's
SwitchMember. - SSwitchPatternCase
- A Dart 3.0 switch statement case with pattern matching.
- SSwitchStatement
- SSymbolLiteral
- StaticResolver
- Static lexical resolver (plan_3 §4.4 / §9 S1–S2), operating directly on the serializable mirror AST.
- Stdlib
- SThisExpression
- SThrowExpression
- SToken
- Serializable token representation
- STopLevelVariableDeclaration
- STryStatement
- STypeAnnotation
-
Base class for type annotations.
Mirrors analyzer's
TypeAnnotation. - STypeArgumentList
- STypedefDeclaration
- STypedLiteral
-
Base class for typed literals (list, set/map).
Mirrors analyzer's
TypedLiteral. - STypeParameter
- STypeParameterList
- SUriBasedDirective
-
Base class for uri-based directives (import, export, part).
Mirrors analyzer's
UriBasedDirective. - SVariableDeclaration
- SVariableDeclarationList
- SVariableDeclarationStatement
- SVariablePattern
-
Base class for variable patterns.
Mirrors analyzer's
VariablePattern. - SWhenClause
-
A
whenclause that guards a pattern with a boolean expression. - SWhileStatement
- SWildcardPattern
-
A wildcard pattern
_, optionally typed (e.g.,int _,var _). - SWithClause
- SYieldStatement
- TypeParameter
- Represents a generic type parameter like T, U, etc.
- VariableInfo
- Information about a variable declaration.
- YieldValue
- Represents a yield operation in a generator function
Enums
Mixins
- SFunctionBodyOwner
- Mixin for declarations with a function body
- SNamedDeclaration
- Mixin for named declarations
Extensions
- InterpreterVisitorExtension on InterpreterVisitor
-
IterableExtensions
on Iterable<
T> -
ListExtension
on List<
T> -
MapExtension
on Map<
K, V>
Functions
-
opensLexicalFrame(
SAstNode node) → bool -
Does
nodeopen a new runtimeEnvironmentframe?
Typedefs
-
BridgedConstructorCallable
= Object? Function(InterpreterVisitor visitor, List<
Object?> positionalArgs, Map<String, Object?> namedArgs) - Calls a native constructor.
- BridgedInstanceGetterAdapter = Object? Function(InterpreterVisitor? visitor, Object target)
- Adapter for bridged instance getters. Takes interpreter context, the native target object. Returns the result of the native instance getter.
- BridgedInstanceSetterAdapter = void Function(InterpreterVisitor? visitor, Object target, Object? value)
- Adapter for bridged instance setters. Takes interpreter context, the native target object, the value to set.
-
BridgedMethodAdapter
= Object? Function(InterpreterVisitor visitor, Object target, List<
Object?> positionalArguments, Map<String, Object?> namedArguments, List<RuntimeType> ? typeArguments) - BridgedStaticGetterAdapter = Object? Function(InterpreterVisitor visitor)
- Adapter for bridged static getters. Takes interpreter context. Returns the result of the native static getter.
-
BridgedStaticMethodAdapter
= Object? Function(InterpreterVisitor visitor, List<
Object?> positionalArguments, Map<String, Object?> namedArguments, List<RuntimeType> ? typeArguments) - Adapter for bridged static methods. Takes interpreter context, positional args, named args, type args. Returns the result of the native static method call.
- BridgedStaticSetterAdapter = void Function(InterpreterVisitor visitor, Object? value)
- Adapter for bridged static setters. Takes interpreter context, the value to set.
-
GenericConstructorFactory
= Object? Function(InterpreterVisitor visitor, List<
Object?> positionalArgs, Map<String, Object?> namedArgs, List<RuntimeType> ? typeArguments) - RC-2: Factory for constructing generic bridged classes with type arguments.
- GenericTypeWrapperFactory = Object? Function(Object value, String innerTypeArg)
- GEN-079: Factory callback for creating typed wrappers.
- InterfaceProxyFactory = Object? Function(InterpreterVisitor visitor, InterpretedInstance instance)
- RC-1: Factory for creating native proxy objects that delegate method calls back to an InterpretedInstance.
-
NativeFunctionImpl
= Object? Function(InterpreterVisitor visitor, List<
Object?> arguments, Map<String, Object?> namedArguments, List<RuntimeType> ? typeArguments) - PermissionChecker = bool Function(dynamic operation)
- Callback signature for permission checking.
- TypeCoercionFactory = Object? Function(Object value)
- RC-3: Factory for converting one type to another when they represent the same concept but live in different packages.
Exceptions / Errors
- ArgumentD4rtException
- Exception for argument-related errors in D4rt components.
- BreakException
- Internal exception used to unwind the stack during a 'break' statement.
- ContinueException
- Internal exception used to unwind the stack during a 'continue' statement.
- ContinueSwitchLabel
- Internal exception for continue-to-label in switch statements. This is used to signal the switch handler to restart from a specific labeled case.
- D4rtException
- Base class for all D4rt-specific exceptions that should be tracked.
- D4UnwrapException
-
Exception thrown by D4.unwrapAs when an interpreter result cannot be
converted to the requested native type
T. - InternalInterpreterD4rtException
- Internal exception wrapper for user-thrown exceptions.
- LateInitializationError
- Exception thrown when accessing an uninitialized late variable
- PatternMatchD4rtException
- Exception specifically for pattern matching failures.
- Ranged4rtException
- Exception for range-related errors in D4rt components.
- ReturnException
- Internal exception used to unwind the stack during a 'return' statement.
- RuntimeD4rtException
- Custom exception for runtime errors during interpretation.
- SourceCodeD4rtException
- Exception thrown when there's an issue with the source code itself, like parsing errors or missing files.
- StateD4rtException
- Exception for state-related errors in D4rt components.
- SyncGeneratorYieldSuspension
- Exception used to pause sync* generator execution at a yield point
- UnimplementedD4rtException
- Exception for unimplemented features in D4rt components.
- UnsupportedD4rtException
- Exception for unsupported operations in D4rt components.