Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
return this._opcode;
}
}
ComponentCapabilities,
Option,
ComponentDefinition,
AnnotatedModuleLocator,
CompileTimeComponent,
} from '@glimmer/interfaces';
import { Constants, HeapImpl, RuntimeProgramImpl } from '@glimmer/program';
import { TestJitRegistry } from './registry';
import { compileStd, unwrapTemplate } from '@glimmer/opcode-compiler';
import TestJitRuntimeResolver from './resolver';
export class TestJitCompilationContext implements WholeProgramCompilationContext {
readonly constants = new Constants();
readonly resolverDelegate: JitCompileTimeLookup;
readonly heap = new HeapImpl();
readonly mode = CompileMode.jit;
readonly stdlib: STDLib;
constructor(runtimeResolver: TestJitRuntimeResolver, registry: TestJitRegistry) {
this.stdlib = compileStd(this);
this.resolverDelegate = new JitCompileTimeLookup(runtimeResolver, registry);
}
program(): RuntimeProgram {
return new RuntimeProgramImpl(this.constants, this.heap);
}
}
export default class JitCompileTimeLookup implements CompileTimeResolverDelegate {
constructor(private resolver: TestJitRuntimeResolver, private registry: TestJitRegistry) {}
resolve(handle: number): T {
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);
}
}
readonly stdlib: STDLib;
constructor(delegate: CompileTimeResolverDelegate, readonly mode: CompileMode) {
this.resolverDelegate = delegate;
this.stdlib = compileStd(this);
}
}
export class JitProgramCompilationContext implements JitProgramCompilationContext {
readonly constants: CompileTimeConstants & RuntimeConstants = DEBUG
? new DebugConstants()
: new Constants();
readonly resolverDelegate: CompileTimeResolverDelegate;
readonly heap: CompileTimeHeap & RuntimeHeap = new HeapImpl();
readonly stdlib: STDLib;
readonly mode: CompileMode = CompileMode.jit;
constructor(delegate: CompileTimeResolverDelegate) {
this.resolverDelegate = delegate;
this.stdlib = compileStd(this);
}
}