Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export { CompilableTemplate };
export class BundleCompilerCompilationContext implements WholeProgramCompilationContext {
readonly compilableTemplates = new ModuleLocatorMap();
readonly compiledBlocks = new ModuleLocatorMap();
readonly meta = new ModuleLocatorMap();
// implement WholeProgramCompilationContext
readonly constants: CompileTimeConstants;
readonly resolverDelegate: BundleCompilerLookup = new BundleCompilerLookup(
this.delegate,
this.compilableTemplates,
this.meta
);
readonly heap: CompileTimeHeap = new HeapImpl();
readonly mode = CompileMode.aot;
readonly stdlib: STDLib;
constructor(
readonly delegate: BundleCompilerDelegate,
options: BundleCompilerOptions
) {
if (options.constants) {
this.constants = options.constants;
} else {
this.constants = new DebugConstants();
}
this.stdlib = compileStd(this);
}
}
function invokeStatic(
context: SyntaxCompilationContext,
action: InvokeStaticOp
): StatementCompileActions {
let compilable = action.op1;
if (context.program.mode === CompileMode.aot) {
let handle = compilable.compile(context);
// If the handle for the invoked component is not yet known (for example,
// because this is a recursive invocation and we're still compiling), push a
// function that will produce the correct handle when the heap is
// serialized.
if (handle === PLACEHOLDER_HANDLE) {
return op(MachineOp.InvokeStatic, () => compilable.compile(context));
} else {
return op(MachineOp.InvokeStatic, handle);
}
} else {
return [op(Op.Constant, other(action.op1)), op(Op.CompileBlock), op(MachineOp.InvokeVirtual)];
}
}
export function Context(
resolver: ResolverDelegate = {},
mode: CompileMode = CompileMode.aot,
macros = new MacrosImpl()
) {
return {
program: new ProgramCompilationContext(new DefaultCompileTimeResolverDelegate(resolver), mode),
macros,
};
}
export function AotContext(resolver: ResolverDelegate = {}, macros = new MacrosImpl()) {
return {
program: new ProgramCompilationContext(
new DefaultCompileTimeResolverDelegate(resolver),
CompileMode.aot
),
macros,
};
}