import { Interval, ParseTree, Token, TokenStream } from "antlr4ng"; import { ICompiledST, IFormalArgument, RegionType } from "./common.js"; import { STGroup } from "../STGroup.js"; /** * The result of compiling an {@link ST}. Contains all the bytecode instructions, * string table, bytecode address to source code map, and other bookkeeping * info. It's the implementation of an ST you might say. All instances * of the same template share a single implementation ({@link ST#impl} field). */ export declare class CompiledST implements ICompiledST { name?: string; /** * Every template knows where it is relative to the group that loaded it. * The prefix is the relative path from the root. {@code "/prefix/name"} is * the fully qualified name of this template. All calls to * {@link STGroup#getInstanceOf} calls must use fully qualified names. A * {@code "/"} is added to the front if you don't specify one. Template * references within template code, however, uses relative names, unless of * course the name starts with {@code "/"}. *

* This has nothing to do with the outer filesystem path to the group dir or * group file.

*

* We set this as we load/compile the template.

*

* Always ends with {@code "/"}.

*/ prefix: string; /** * The original, immutable pattern (not really used again after * initial "compilation"). Useful for debugging. Even for * sub templates, this is entire overall template. */ template: string; /** The token that begins template definition; could be {@code <@r>} of region. */ templateDefStartToken?: Token; /** Overall token stream for template (debug only). */ tokens?: TokenStream; /** The parse tree of the parser run which created this instance. */ tree?: ParseTree; formalArguments?: Map; hasFormalArgs: boolean; numberOfArgsWithDefaultValues: number; /** * The group that physically defines this {@link ST} definition. We use it * to initiate interpretation via {@link ST#toString}. From there, it * becomes field {@link Interpreter#group} and is fixed until rendering * completes. */ nativeGroup: STGroup; /** * Does this template come from a {@code <@region>...<@end>} embedded in * another template? */ isRegion: boolean; /** * If someone refs {@code <@r()>} in template t, an implicit * *

* {@code @t.r() ::= ""}

*

* is defined, but you can overwrite this def by defining your own. We need * to prevent more than one manual def though. Between this var and * {@link #isRegion} we can determine these cases.

*/ regionDefType: RegionType; isAnonSubtemplate: boolean; readonly strings: string[]; codeSize: number; readonly sourceMap: Interval[]; instructions: Int8Array; /** A list of all regions and sub templates. */ private implicitlyDefinedTemplates; constructor(); /** * Cloning the {@link CompiledST} for an {@link ST} instance allows * {@link ST#add} to be called safely during interpretation for templates * that do not contain formal arguments. * * @returns A copy of the current {@link CompiledST} instance. The copy is a * shallow copy, with the exception of the {@link #formalArguments} field * which is also cloned. * * @throws CloneNotSupportedException If the current instance cannot be * cloned. */ clone(): CompiledST; addImplicitlyDefinedTemplate(sub: CompiledST): void; defineArgDefaultValueTemplates(group: STGroup): void; defineFormalArgs(args?: IFormalArgument[]): void; /** * Used by {@link ST#add} to add args one by one without turning on full formal args definition signal. */ addArg(a: IFormalArgument): void; defineImplicitlyDefinedTemplates(group: STGroup): void; getTemplateSource(): string; getTemplateRange(): Interval; instrs(): string; dump(): void; disassembled(): string; }