import type { PresentArray } from './array.js'; import type { EncoderError } from './compile/encoder.js'; import type { Operand, SerializedInlineBlock, SerializedTemplateBlock } from './compile/index.js'; import type { Nullable } from './core.js'; import type { InternalComponentCapabilities } from './managers/internal/component.js'; import type { CompileTimeCompilationContext, ConstantPool, SerializedHeap } from './program.js'; import type { Owner } from './runtime.js'; import type { BlockSymbolTable, ProgramSymbolTable, SymbolTable } from './tier1/symbol-table.js'; export interface CompilableProgram extends CompilableTemplate { moduleName: string; } export type CompilableBlock = CompilableTemplate; export interface LayoutWithContext { readonly id: string; readonly block: SerializedTemplateBlock; readonly moduleName: string; readonly owner: Owner | null; readonly scope: (() => unknown[]) | undefined | null; readonly isStrictMode: boolean; } export interface BlockWithContext { readonly block: SerializedInlineBlock; readonly containingLayout: LayoutWithContext; } /** * Environment specific template. */ export interface TemplateOk { result: 'ok'; /** * Module name associated with the template, used for debugging purposes */ moduleName: string; // internal casts, these are lazily created and cached asLayout(): CompilableProgram; asWrappedLayout(): CompilableProgram; } export interface TemplateError { result: 'error'; problem: string; span: { start: number; end: number; }; } export type Template = TemplateOk | TemplateError; export type TemplateFactory = (owner?: Owner) => Template; export interface STDLib { main: number; 'cautious-append': number; 'trusting-append': number; 'cautious-non-dynamic-append': number; 'trusting-non-dynamic-append': number; } export type SerializedStdlib = [number, number, number]; export type STDLibName = keyof STDLib; export type CompilerBuffer = Array; export interface ResolvedLayout { handle: number; capabilities: InternalComponentCapabilities; compilable: Nullable; } export type OkHandle = number; export interface ErrHandle { handle: number; errors: PresentArray; } export type HandleResult = OkHandle | ErrHandle; export interface NamedBlocks { get(name: string): Nullable; has(name: string): boolean; with(name: string, block: Nullable): NamedBlocks; hasAny: boolean; names: string[]; } export interface ContainingMetadata { evalSymbols: Nullable; upvars: Nullable; scopeValues: unknown[] | null; isStrictMode: boolean; moduleName: string; owner: Owner | null; size: number; } export interface CompilerArtifacts { heap: SerializedHeap; constants: ConstantPool; } export interface CompilableTemplate { symbolTable: S; compile(context: CompileTimeCompilationContext): HandleResult; }