mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Export function table by default and add an option to import it
This commit is contained in:
parent
2738eee9cd
commit
ec5bb7ad51
@ -360,6 +360,7 @@ exports.main = function main(argv, options, callback) {
|
||||
assemblyscript.setNoAssert(compilerOptions, !!args.noAssert);
|
||||
assemblyscript.setNoMemory(compilerOptions, !!args.noMemory);
|
||||
assemblyscript.setImportMemory(compilerOptions, !!args.importMemory);
|
||||
assemblyscript.setImportTable(compilerOptions, !!args.importTable);
|
||||
assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);
|
||||
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
|
||||
|
||||
|
@ -107,6 +107,10 @@
|
||||
"desc": "Sets the start offset of compiler-generated static memory.",
|
||||
"type": "number"
|
||||
},
|
||||
"importTable": {
|
||||
"desc": "Imports the function table instance provided by the embedder.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"noLib": {
|
||||
"desc": "Does not include the shipped standard library.",
|
||||
"type": "boolean"
|
||||
|
2
dist/asc.js
vendored
2
dist/asc.js
vendored
File diff suppressed because one or more lines are too long
2
dist/asc.js.map
vendored
2
dist/asc.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js
vendored
2
dist/assemblyscript.js
vendored
File diff suppressed because one or more lines are too long
2
dist/assemblyscript.js.map
vendored
2
dist/assemblyscript.js.map
vendored
File diff suppressed because one or more lines are too long
@ -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;
|
||||
|
@ -13,6 +13,7 @@
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
(func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(get_local $0)
|
||||
|
@ -14,6 +14,7 @@
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
(func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
|
@ -15,6 +15,7 @@
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\11\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00t\00y\00p\00e\00s\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
(func $function-types/makeAdder<i32>~anonymous|0 (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(i32.add
|
||||
|
@ -16,6 +16,7 @@
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\11\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00t\00y\00p\00e\00s\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
(func $function-types/makeAdder<i32>~anonymous|0 (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(return
|
||||
|
Loading…
x
Reference in New Issue
Block a user