Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
): Option {
let definitionHandle = this.lookupComponentHandle(name, referrer);
if (definitionHandle === null) {
return null;
}
let templateHandle = this.lookup('template-source', name, null);
if (templateHandle === null) {
throw new Error('BUG: missing dynamic layout');
}
// TODO: This whole thing probably should have a more first-class
// structure.
let template = unwrapTemplate(
this.customCompilableTemplate(templateHandle, name, source => {
let factory = createTemplate(source);
return factory.create();
})
);
return {
handle: definitionHandle,
capabilities: this.getCapabilities(definitionHandle),
compilable: template.asWrappedLayout(),
};
// let handle = this.resolver.lookupComponentHandle(name, referrer);
// if (handle === null) {
// return null;
export function Compilable(source: any) {
// console.log('In Compilable: ' + source);
const precompiled = precompile(source);
// console.log('Precompiled');
const component = Component(precompiled);
// console.log(`Compiled Component: ${component}`);
return component;
}
static lookupComponent(name) {
// console.log(`lookupComponent: ${name}`);
let component = ResolverDelegate.components[name];
if (component === null) {
return null;
}
// console.log(`component found: ${component}`);
//source should now be compiled
let { handle, source, capabilities } = component;
return {
handle,
source,
compilable: Component(source),
capabilities
};
}
static lookupModifier(name) {
static lookupComponent(name: any) {
// console.log(`lookupComponent: ${name}`);
let component = ResolverDelegate.components[name];
if (component === null) {
return null;
}
// console.log(`component found: ${component}`);
//source should now be compiled
let { handle, source, capabilities } = component;
return {
handle,
source,
compilable: Component(source),
capabilities
};
}
export function Compilable(source) {
// console.log('In Compilable: ' + source);
const precompiled = precompile(source);
// console.log('Precompiled');
const component = Component(precompiled);
// console.log(`Compiled Component: ${component}`);
return component;
}
export class ResolverDelegate {
}
if (evalScope) {
for (let i = 0; i < partialSymbols.length; i++) {
let name = partialSymbols[i];
let symbol = i + 1;
let value = evalScope[name];
if (value !== undefined) partialScope.bind(symbol, value);
}
}
partialScope.bindPartialMap(locals);
vm.pushFrame(); // sp += 2
vm.call(unwrapHandle(vmHandle!));
}
},
'jit'
const resolverDelegate = new ResolverDelegate();
const resolver = new Resolver();
Application.resolver = resolver;
Application.resolverDelegate = resolverDelegate;
//Order here is important due to handle's being generated by plugin
this.parseTemplates(appFolder);
// this.parseComponents(appFolder);
this.registerState(components);
setupGlimmer(resolverDelegate, resolver);
this.registerHelpers(helpers);
//-----------------------------------------------------------------
Application.document = new DocumentNode();
Application.rootFrame = createElement('Frame');
Application.rootFrame.setAttribute('id', 'root');
Application.document.appendChild(Application.rootFrame);
Application.context = Context(GlimmerResolverDelegate);
}
static renderPage(name, containerElement, nextSibling = null, state) {
const resolverDelegate = new ResolverDelegate();
const resolver = new Resolver();
Application.resolver = resolver;
Application.resolverDelegate = resolverDelegate;
//Order here is important due to handle's being generated by plugin
this.parseTemplates(appFolder);
// this.parseComponents(appFolder);
this.registerState(components);
setupGlimmer(resolverDelegate, resolver);
this.registerHelpers(helpers);
//-----------------------------------------------------------------
Application.document = new DocumentNode();
Application.rootFrame = createElement('Frame') as FrameElement;
Application.rootFrame.setAttribute('id', 'root');
Application.document.appendChild(Application.rootFrame);
Application.context = Context(GlimmerResolverDelegate);
}
let vmHandle:
| number
| { handle: number; errors: EncoderError[] }
| undefined = this.compilerModuleLocatorResolver().getHandleByLocator(locator);
if (vmHandle !== undefined) return vmHandle;
// It's an error to try to compile a template that wasn't first added to the
// bundle via the add() or addCompilableTemplate() methods.
let compilableTemplate = expect(
this.context.compilableTemplates.get(locator),
`Can't compile a template that wasn't already added to the bundle (${locator.name} @ ${locator.module})`
);
// Compile the template, which writes opcodes to the heap and returns the VM
// handle (the address of the compiled program in the heap).
vmHandle = compilableTemplate.compile(syntaxCompilationContext(this.context, this.macros));
if (typeof vmHandle !== 'number') {
return vmHandle;
}
// Index the locator by VM handle and vice versa for easy lookups.
this.compilerModuleLocatorResolver().setHandleByLocator(locator, vmHandle);
return vmHandle;
}
}
export function preprocess(
template: string,
meta?: AnnotatedModuleLocator
): Template {
let wrapper = JSON.parse(rawPrecompile(template));
let factory = templateFactory(wrapper);
return factory.create(meta || DEFAULT_TEST_META);
}