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