mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-15 07:51:32 +00:00
Export function table by default and add an option to import it
This commit is contained in:
@ -147,6 +147,8 @@ export class Options {
|
||||
noMemory: bool = false;
|
||||
/** If true, imports the memory provided by the embedder. */
|
||||
importMemory: bool = false;
|
||||
/** If true, imports the function table provided by the embedder. */
|
||||
importTable: bool = false;
|
||||
/** Static memory start offset. */
|
||||
memoryBase: u32 = 0;
|
||||
/** If true, generates information necessary for source maps. */
|
||||
@ -327,6 +329,13 @@ export class Compiler extends DiagnosticEmitter {
|
||||
entries[i] = functionTable[i].ref;
|
||||
}
|
||||
module.setFunctionTable(entries);
|
||||
module.addTableExport("0", "table");
|
||||
}
|
||||
|
||||
// import table if requested
|
||||
if (options.importTable) {
|
||||
module.addTableImport("0", "env", "table");
|
||||
if (!functionTableSize) module.addTableExport("0", "table");
|
||||
}
|
||||
|
||||
return module;
|
||||
|
@ -110,6 +110,11 @@ export function setImportMemory(options: Options, importMemory: bool): void {
|
||||
options.importMemory = importMemory;
|
||||
}
|
||||
|
||||
/** Sets the `importTable` option. */
|
||||
export function setImportTable(options: Options, importTable: bool): void {
|
||||
options.importTable = importTable;
|
||||
}
|
||||
|
||||
/** Sets the `sourceMap` option. */
|
||||
export function setSourceMap(options: Options, sourceMap: bool): void {
|
||||
options.sourceMap = sourceMap;
|
||||
|
Reference in New Issue
Block a user