mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 23:12:19 +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.setNoAssert(compilerOptions, !!args.noAssert);
|
||||||
assemblyscript.setNoMemory(compilerOptions, !!args.noMemory);
|
assemblyscript.setNoMemory(compilerOptions, !!args.noMemory);
|
||||||
assemblyscript.setImportMemory(compilerOptions, !!args.importMemory);
|
assemblyscript.setImportMemory(compilerOptions, !!args.importMemory);
|
||||||
|
assemblyscript.setImportTable(compilerOptions, !!args.importTable);
|
||||||
assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);
|
assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);
|
||||||
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
|
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
|
||||||
|
|
||||||
|
@ -107,6 +107,10 @@
|
|||||||
"desc": "Sets the start offset of compiler-generated static memory.",
|
"desc": "Sets the start offset of compiler-generated static memory.",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"importTable": {
|
||||||
|
"desc": "Imports the function table instance provided by the embedder.",
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
"noLib": {
|
"noLib": {
|
||||||
"desc": "Does not include the shipped standard library.",
|
"desc": "Does not include the shipped standard library.",
|
||||||
"type": "boolean"
|
"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;
|
noMemory: bool = false;
|
||||||
/** If true, imports the memory provided by the embedder. */
|
/** If true, imports the memory provided by the embedder. */
|
||||||
importMemory: bool = false;
|
importMemory: bool = false;
|
||||||
|
/** If true, imports the function table provided by the embedder. */
|
||||||
|
importTable: bool = false;
|
||||||
/** Static memory start offset. */
|
/** Static memory start offset. */
|
||||||
memoryBase: u32 = 0;
|
memoryBase: u32 = 0;
|
||||||
/** If true, generates information necessary for source maps. */
|
/** If true, generates information necessary for source maps. */
|
||||||
@ -327,6 +329,13 @@ export class Compiler extends DiagnosticEmitter {
|
|||||||
entries[i] = functionTable[i].ref;
|
entries[i] = functionTable[i].ref;
|
||||||
}
|
}
|
||||||
module.setFunctionTable(entries);
|
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;
|
return module;
|
||||||
|
@ -110,6 +110,11 @@ export function setImportMemory(options: Options, importMemory: bool): void {
|
|||||||
options.importMemory = importMemory;
|
options.importMemory = importMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Sets the `importTable` option. */
|
||||||
|
export function setImportTable(options: Options, importTable: bool): void {
|
||||||
|
options.importTable = importTable;
|
||||||
|
}
|
||||||
|
|
||||||
/** Sets the `sourceMap` option. */
|
/** Sets the `sourceMap` option. */
|
||||||
export function setSourceMap(options: Options, sourceMap: bool): void {
|
export function setSourceMap(options: Options, sourceMap: bool): void {
|
||||||
options.sourceMap = sourceMap;
|
options.sourceMap = sourceMap;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
(memory $0 1)
|
(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")
|
(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 "memory" (memory $0))
|
||||||
|
(export "table" (table $0))
|
||||||
(start $start)
|
(start $start)
|
||||||
(func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
(func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(get_local $0)
|
(get_local $0)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
(memory $0 1)
|
(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")
|
(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 "memory" (memory $0))
|
||||||
|
(export "table" (table $0))
|
||||||
(start $start)
|
(start $start)
|
||||||
(func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
(func $start~anonymous|0 (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||||
(return
|
(return
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
(memory $0 1)
|
(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")
|
(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 "memory" (memory $0))
|
||||||
|
(export "table" (table $0))
|
||||||
(start $start)
|
(start $start)
|
||||||
(func $function-types/makeAdder<i32>~anonymous|0 (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
(func $function-types/makeAdder<i32>~anonymous|0 (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||||
(i32.add
|
(i32.add
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
(memory $0 1)
|
(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")
|
(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 "memory" (memory $0))
|
||||||
|
(export "table" (table $0))
|
||||||
(start $start)
|
(start $start)
|
||||||
(func $function-types/makeAdder<i32>~anonymous|0 (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
(func $function-types/makeAdder<i32>~anonymous|0 (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||||
(return
|
(return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user