1 | import { CompilableBlock } from '../template';
|
2 |
|
3 | import { Reference } from '@glimmer/reference';
|
4 | import { Option, Dict } from '../core';
|
5 | import { BlockSymbolTable } from '../tier1/symbol-table';
|
6 | import { Owner } from './owner';
|
7 |
|
8 | export type Block = CompilableBlock | number;
|
9 |
|
10 | export type ScopeBlock = [CompilableBlock, Scope, BlockSymbolTable];
|
11 | export type BlockValue = ScopeBlock[0 | 1 | 2];
|
12 | export type ScopeSlot = Reference | ScopeBlock | null;
|
13 |
|
14 | export interface Scope {
|
15 |
|
16 | readonly slots: Array<ScopeSlot>;
|
17 | readonly owner: Owner;
|
18 |
|
19 | getSelf(): Reference;
|
20 | getSymbol(symbol: number): Reference;
|
21 | getBlock(symbol: number): Option<ScopeBlock>;
|
22 | getEvalScope(): Option<Dict<ScopeSlot>>;
|
23 | getPartialMap(): Option<Dict<Reference>>;
|
24 | bind(symbol: number, value: ScopeSlot): void;
|
25 | bindSelf(self: Reference): void;
|
26 | bindSymbol(symbol: number, value: Reference): void;
|
27 | bindBlock(symbol: number, value: Option<ScopeBlock>): void;
|
28 | bindEvalScope(map: Option<Dict<ScopeSlot>>): void;
|
29 | bindPartialMap(map: Dict<Reference>): void;
|
30 | child(): Scope;
|
31 | }
|
32 |
|
33 | export interface PartialScope extends Scope {
|
34 | bindEvalScope(scope: Option<Dict<ScopeSlot>>): void;
|
35 | }
|
36 |
|
37 | export interface DynamicScope {
|
38 | get(key: string): Reference<unknown>;
|
39 | set(key: string, reference: Reference<unknown>): Reference<unknown>;
|
40 | child(): DynamicScope;
|
41 | }
|