Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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);
}
}
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,
};
}