UNPKG

4.55 kBTypeScriptView Raw
1import { Expressions, GetContextualFreeOp, Option, PresentArray, VariableResolutionContext, WireFormat } from '@glimmer/interfaces';
2import { AttrNamespace } from '@simple-dom/interface';
3import { Builder, BuilderComment, BuilderStatement, NormalizedAngleInvocation, NormalizedAttrs, NormalizedBlocks, NormalizedExpression, NormalizedHash, NormalizedHead, NormalizedParams, NormalizedPath, NormalizedStatement, Variable } from './builder-interface';
4interface Symbols {
5 top: ProgramSymbols;
6 freeVar(name: string): number;
7 arg(name: string): number;
8 block(name: string): number;
9 local(name: string): number;
10 this(): number;
11 hasLocal(name: string): boolean;
12 child(params: string[]): LocalSymbols;
13}
14export declare class ProgramSymbols implements Symbols {
15 _freeVariables: string[];
16 _symbols: string[];
17 top: this;
18 toSymbols(): string[];
19 toUpvars(): string[];
20 freeVar(name: string): number;
21 block(name: string): number;
22 arg(name: string): number;
23 local(name: string): never;
24 this(): number;
25 hasLocal(_name: string): false;
26 symbol(name: string): number;
27 child(locals: string[]): LocalSymbols;
28}
29declare class LocalSymbols implements Symbols {
30 private parent;
31 private locals;
32 constructor(parent: Symbols, locals: string[]);
33 get paramSymbols(): number[];
34 get top(): ProgramSymbols;
35 freeVar(name: string): number;
36 arg(name: string): number;
37 block(name: string): number;
38 local(name: string): number;
39 this(): number;
40 hasLocal(name: string): boolean;
41 child(locals: string[]): LocalSymbols;
42}
43export interface BuilderGetFree {
44 type: 'GetFree';
45 head: string;
46 tail: string[];
47}
48export declare function buildStatements(statements: BuilderStatement[], symbols: Symbols): WireFormat.Statement[];
49export declare function buildNormalizedStatements(statements: NormalizedStatement[], symbols: Symbols): WireFormat.Statement[];
50export declare function buildStatement(normalized: NormalizedStatement, symbols?: Symbols): WireFormat.Statement[];
51export declare function s(arr: TemplateStringsArray, ...interpolated: unknown[]): [Builder.Literal, string];
52export declare function c(arr: TemplateStringsArray, ...interpolated: unknown[]): BuilderComment;
53export declare function unicode(charCode: string): string;
54export declare const NEWLINE = "\n";
55export declare function buildAngleInvocation({ attrs, block, head }: NormalizedAngleInvocation, symbols: Symbols): WireFormat.Statements.Component;
56export declare function buildElementParams(attrs: NormalizedAttrs, symbols: Symbols): {
57 params: WireFormat.ElementParameter[];
58 args: WireFormat.Core.Hash;
59};
60export declare function extractNamespace(name: string): Option<AttrNamespace>;
61export declare function buildAttributeValue(name: string, value: NormalizedExpression, namespace: Option<AttrNamespace>, symbols: Symbols): WireFormat.Attribute[];
62declare type ExprResolution = VariableResolutionContext | 'Append' | 'TrustedAppend' | 'AttrValue' | 'SubExpression' | 'Strict';
63export declare function buildExpression(expr: NormalizedExpression, context: ExprResolution, symbols: Symbols): WireFormat.Expression;
64export declare function buildCallHead(callHead: NormalizedHead, context: VarResolution, symbols: Symbols): Expressions.GetVar | Expressions.GetPath;
65export declare function buildGetPath(head: NormalizedPath, symbols: Symbols): Expressions.GetPath;
66declare type VarResolution = VariableResolutionContext | 'AppendBare' | 'AppendInvoke' | 'TrustedAppendBare' | 'TrustedAppendInvoke' | 'AttrValueBare' | 'AttrValueInvoke' | 'SubExpression' | 'Strict';
67export declare function buildVar(head: Variable, context: VarResolution, symbols: Symbols, path: PresentArray<string>): Expressions.GetPath;
68export declare function buildVar(head: Variable, context: VarResolution, symbols: Symbols): Expressions.GetVar;
69export declare function expressionContextOp(context: VariableResolutionContext): GetContextualFreeOp;
70export declare function buildParams(exprs: Option<NormalizedParams>, symbols: Symbols): Option<WireFormat.Core.Params>;
71export declare function buildConcat(exprs: [NormalizedExpression, ...NormalizedExpression[]], symbols: Symbols): WireFormat.Core.ConcatParams;
72export declare function buildHash(exprs: Option<NormalizedHash>, symbols: Symbols): WireFormat.Core.Hash;
73export declare function buildBlocks(blocks: NormalizedBlocks, blockParams: Option<string[]>, parent: Symbols): WireFormat.Core.Blocks;
74export {};
75//# sourceMappingURL=builder.d.ts.map
\No newline at end of file