How to use the @glimmer/program.Program function in @glimmer/program

To help you get started, we’ve selected a few @glimmer/program examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / lazy-env.ts View on Github external
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());
github emberjs / ember.js / packages / ember-glimmer / lib / compile-options.ts View on Github external
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;
  }
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / lazy.ts View on Github external
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);
  }