UNPKG

6.29 kBTypeScriptView Raw
1import { CompilableTemplate, Destroyable, DynamicScope, ElementBuilder, Environment, Option, PartialScope, RenderResult, RichIteratorResult, RuntimeConstants, RuntimeContext, RuntimeProgram, Scope, CompileTimeCompilationContext, VM as PublicVM, ResolutionTimeConstants, Owner, UpdatingOpcode } from '@glimmer/interfaces';
2import { OpaqueIterationItem, OpaqueIterator, Reference } from '@glimmer/reference';
3import { MachineRegister, Register, SyscallRegister } from '@glimmer/vm';
4import { ARGS, CONSTANTS, DESTROYABLE_STACK, HEAP, INNER_VM, STACKS } from '../symbols';
5import { VMArgumentsImpl } from './arguments';
6import LowLevelVM from './low-level';
7import { EvaluationStack } from './stack';
8import { ListBlockOpcode, ListItemOpcode, ResumableVMState, VMState } from './update';
9/**
10 * This interface is used by internal opcodes, and is more stable than
11 * the implementation of the Append VM itself.
12 */
13export interface InternalVM {
14 readonly [CONSTANTS]: RuntimeConstants & ResolutionTimeConstants;
15 readonly [ARGS]: VMArgumentsImpl;
16 readonly env: Environment;
17 readonly stack: EvaluationStack;
18 readonly runtime: RuntimeContext;
19 readonly context: CompileTimeCompilationContext;
20 loadValue(register: MachineRegister, value: number): void;
21 loadValue(register: Register, value: unknown): void;
22 loadValue(register: Register | MachineRegister, value: unknown): void;
23 fetchValue(register: MachineRegister.ra | MachineRegister.pc): number;
24 fetchValue<T>(register: Register): T;
25 fetchValue(register: Register): unknown;
26 load(register: Register): void;
27 fetch(register: Register): void;
28 compile(block: CompilableTemplate): number;
29 scope(): Scope;
30 elements(): ElementBuilder;
31 getOwner(): Owner;
32 getSelf(): Reference;
33 updateWith(opcode: UpdatingOpcode): void;
34 associateDestroyable(d: Destroyable): void;
35 beginCacheGroup(name?: string): void;
36 commitCacheGroup(): void;
37 enterList(iterableRef: Reference<OpaqueIterator>, offset: number): void;
38 exitList(): void;
39 enterItem(item: OpaqueIterationItem): ListItemOpcode;
40 registerItem(item: ListItemOpcode): void;
41 pushRootScope(size: number, owner: Owner): PartialScope;
42 pushChildScope(): void;
43 popScope(): void;
44 pushScope(scope: Scope): void;
45 dynamicScope(): DynamicScope;
46 bindDynamicScope(names: string[]): void;
47 pushDynamicScope(): void;
48 popDynamicScope(): void;
49 enter(args: number): void;
50 exit(): void;
51 goto(pc: number): void;
52 call(handle: number): void;
53 pushFrame(): void;
54 referenceForSymbol(symbol: number): Reference;
55 execute(initialize?: (vm: this) => void): RenderResult;
56 pushUpdating(list?: UpdatingOpcode[]): void;
57 next(): RichIteratorResult<null, RenderResult>;
58}
59export default class VM implements PublicVM, InternalVM {
60 readonly runtime: RuntimeContext;
61 private readonly elementStack;
62 readonly context: CompileTimeCompilationContext;
63 private readonly [STACKS];
64 private readonly [HEAP];
65 private readonly destructor;
66 private readonly [DESTROYABLE_STACK];
67 readonly [CONSTANTS]: RuntimeConstants & ResolutionTimeConstants;
68 readonly [ARGS]: VMArgumentsImpl;
69 readonly [INNER_VM]: LowLevelVM;
70 get stack(): EvaluationStack;
71 get pc(): number;
72 s0: unknown;
73 s1: unknown;
74 t0: unknown;
75 t1: unknown;
76 v0: unknown;
77 fetch(register: SyscallRegister): void;
78 load(register: SyscallRegister): void;
79 fetchValue(register: MachineRegister): number;
80 fetchValue<T>(register: Register): T;
81 loadValue<T>(register: Register | MachineRegister, value: T): void;
82 /**
83 * Migrated to Inner
84 */
85 pushFrame(): void;
86 popFrame(): void;
87 goto(offset: number): void;
88 call(handle: number): void;
89 returnTo(offset: number): void;
90 return(): void;
91 /**
92 * End of migrated.
93 */
94 constructor(runtime: RuntimeContext, { pc, scope, dynamicScope, stack }: VMState, elementStack: ElementBuilder, context: CompileTimeCompilationContext);
95 static initial(runtime: RuntimeContext, context: CompileTimeCompilationContext, { handle, self, dynamicScope, treeBuilder, numSymbols, owner }: InitOptions): InternalVM;
96 static empty(runtime: RuntimeContext, { handle, treeBuilder, dynamicScope, owner }: MinimalInitOptions, context: CompileTimeCompilationContext): InternalVM;
97 private resume;
98 compile(block: CompilableTemplate): number;
99 get program(): RuntimeProgram;
100 get env(): Environment;
101 captureState(args: number, pc?: number): VMState;
102 capture(args: number, pc?: number): ResumableVMState;
103 beginCacheGroup(name?: string): void;
104 commitCacheGroup(): void;
105 enter(args: number): void;
106 enterItem({ key, value, memo }: OpaqueIterationItem): ListItemOpcode;
107 registerItem(opcode: ListItemOpcode): void;
108 enterList(iterableRef: Reference<OpaqueIterator>, offset: number): void;
109 private didEnter;
110 exit(): void;
111 exitList(): void;
112 pushUpdating(list?: UpdatingOpcode[]): void;
113 popUpdating(): UpdatingOpcode[];
114 updateWith(opcode: UpdatingOpcode): void;
115 listBlock(): ListBlockOpcode;
116 associateDestroyable(child: Destroyable): void;
117 tryUpdating(): Option<UpdatingOpcode[]>;
118 updating(): UpdatingOpcode[];
119 elements(): ElementBuilder;
120 scope(): Scope;
121 dynamicScope(): DynamicScope;
122 pushChildScope(): void;
123 pushDynamicScope(): DynamicScope;
124 pushRootScope(size: number, owner: Owner): PartialScope;
125 pushScope(scope: Scope): void;
126 popScope(): void;
127 popDynamicScope(): void;
128 getOwner(): Owner;
129 getSelf(): Reference<any>;
130 referenceForSymbol(symbol: number): Reference;
131 execute(initialize?: (vm: this) => void): RenderResult;
132 private _execute;
133 next(): RichIteratorResult<null, RenderResult>;
134 bindDynamicScope(names: string[]): void;
135}
136export interface MinimalInitOptions {
137 handle: number;
138 treeBuilder: ElementBuilder;
139 dynamicScope: DynamicScope;
140 owner: Owner;
141}
142export interface InitOptions extends MinimalInitOptions {
143 self: Reference;
144 numSymbols: number;
145}
146export declare type VmInitCallback = (this: void, runtime: RuntimeContext, state: VMState, builder: ElementBuilder) => InternalVM;
147//# sourceMappingURL=append.d.ts.map
\No newline at end of file