How to use the @glimmer/program.Constants 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 / modes / lazy / environment.ts View on Github external
document?: SimpleDocument;
  appendOperations?: GlimmerTreeConstruction;
  updateOperations?: GlimmerTreeChanges;
  program?: CompilableProgram;
}

export const DEFAULT_TEST_META: AnnotatedModuleLocator = Object.freeze({
  kind: 'unknown',
  meta: {},
  module: 'some/template',
  name: 'default',
});

export class TestCompilationContext implements WholeProgramCompilationContext, RuntimeProgram {
  readonly runtimeResolver = new LazyRuntimeResolver();
  readonly constants = new Constants(this.runtimeResolver);
  readonly resolverDelegate = new LazyCompileTimeLookup(this.runtimeResolver);
  readonly heap = new CompileTimeHeapImpl();
  readonly mode = CompileMode.jit;
  readonly stdlib: STDLib;

  constructor() {
    this.stdlib = compileStd(this);

    this._opcode = new RuntimeOpImpl(this.heap);
  }

  // TODO: This sucks
  private _opcode: RuntimeOpImpl;

  opcode(offset: number): RuntimeOpImpl {
    this._opcode.offset = offset;
github glimmerjs / glimmer-vm / packages / @glimmer / test-helpers / lib / environment / modes / lazy / compilation-context.ts View on Github external
import {
  WholeProgramCompilationContext,
  RuntimeProgram,
  CompileMode,
  STDLib,
} from '@glimmer/interfaces';
import { Constants, CompileTimeHeapImpl, RuntimeProgramImpl } from '@glimmer/program';
import LazyCompileTimeLookup from './lookup';
import LazyRuntimeResolver, { JitRegistry } from './runtime-resolver';
import { compileStd } from '@glimmer/opcode-compiler';

export class TestLazyCompilationContext implements WholeProgramCompilationContext {
  readonly constants = new Constants(this.runtimeResolver);
  readonly resolverDelegate: LazyCompileTimeLookup;
  readonly heap = new CompileTimeHeapImpl();
  readonly mode = CompileMode.jit;
  readonly stdlib: STDLib;

  constructor(private runtimeResolver: LazyRuntimeResolver, registry: JitRegistry) {
    this.stdlib = compileStd(this);
    this.resolverDelegate = new LazyCompileTimeLookup(runtimeResolver, registry);
  }

  program(): RuntimeProgram {
    return new RuntimeProgramImpl(this.constants, this.heap);
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / runtime / lib / environment.ts View on Github external
export function JitRuntime(
  options: EnvironmentOptions,
  resolver: RuntimeResolverDelegate = {},
  delegate: EnvironmentDelegate = {}
): JitRuntimeContext {
  let env = new EnvironmentImpl(options, delegate);

  let constants = new Constants();
  let heap = new HeapImpl();
  let program = new RuntimeProgramImpl(constants, heap);

  return {
    env,
    resolver: new DefaultRuntimeResolver(resolver),
    program,
  };
}