UNPKG

1.4 kBTypeScriptView Raw
1import { CompilableBlock } from '../template';
2// eslint-disable-next-line node/no-extraneous-import
3import { Reference } from '@glimmer/reference';
4import { Option, Dict } from '../core';
5import { BlockSymbolTable } from '../tier1/symbol-table';
6import { Owner } from './owner';
7
8export type Block = CompilableBlock | number;
9
10export type ScopeBlock = [CompilableBlock, Scope, BlockSymbolTable];
11export type BlockValue = ScopeBlock[0 | 1 | 2];
12export type ScopeSlot = Reference | ScopeBlock | null;
13
14export interface Scope {
15 // for debug only
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
33export interface PartialScope extends Scope {
34 bindEvalScope(scope: Option<Dict<ScopeSlot>>): void;
35}
36
37export interface DynamicScope {
38 get(key: string): Reference<unknown>;
39 set(key: string, reference: Reference<unknown>): Reference<unknown>;
40 child(): DynamicScope;
41}