Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return this.lookup('component', name, referrer);
}
lookupPartial(name: string, referrer?: TestSpecifier): Option {
return this.lookup('partial', name, referrer);
}
resolve(handle: number): T {
let registry = this.handleLookup[handle];
return registry.getByHandle(handle) as T;
}
}
export class TestEnvironment extends AbstractTestEnvironment {
public resolver = new TestResolver();
protected program = new Program(new LazyConstants(this.resolver));
public compileOptions: TemplateOptions = {
lookup: new LookupResolver(this.resolver),
program: this.program,
macros: new TestMacros(),
Builder: LazyOpcodeBuilder as OpcodeBuilderConstructor
};
constructor(options?: TestEnvironmentOptions) {
super(testOptions(options));
// recursive field, so "unsafely" set one half late (but before the resolver is actually used)
this.resolver['options'] = this.compileOptions;
this.registerHelper("if", ([cond, yes, no]) => cond ? yes : no);
this.registerHelper("unless", ([cond, yes, no]) => cond ? no : yes);
this.registerInternalHelper("-get-dynamic-var", getDynamicVar);
this.registerModifier("action", new InertModifierManager());
constructor(resolver: RuntimeResolver) {
const program = new Program(new LazyConstants(resolver));
const macros = new Macros();
populateMacros(macros);
this.program = program;
this.macros = macros;
this.resolver = new CompileTimeLookup(resolver);
this.Builder = LazyOpcodeBuilder as OpcodeBuilderConstructor;
}
static create(
lookup: CompileTimeLookup,
resolver: RuntimeResolver,
macros: Macros
): LazyCompiler {
let constants = new LazyConstants(resolver);
let program = new Program(constants);
return new LazyCompiler(macros, program, lookup);
}