mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-20 18:26:40 +00:00
Initial support for default imports/exports, see #98
Does not implement combinations like 'import theDefault, *' yet
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime none",
|
||||
"--runtime half",
|
||||
"--use ASC_RTRACE=1"
|
||||
]
|
||||
}
|
||||
|
5
tests/compiler/export-default.json
Normal file
5
tests/compiler/export-default.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"asc_flags": [
|
||||
"--runtime none"
|
||||
]
|
||||
}
|
10
tests/compiler/export-default.optimized.wat
Normal file
10
tests/compiler/export-default.optimized.wat
Normal file
@ -0,0 +1,10 @@
|
||||
(module
|
||||
(type $FUNCSIG$v (func))
|
||||
(memory $0 0)
|
||||
(export "memory" (memory $0))
|
||||
(export "theDefault" (func $export-default/theDefault))
|
||||
(export "default" (func $export-default/theDefault))
|
||||
(func $export-default/theDefault (; 0 ;) (type $FUNCSIG$v)
|
||||
nop
|
||||
)
|
||||
)
|
1
tests/compiler/export-default.ts
Normal file
1
tests/compiler/export-default.ts
Normal file
@ -0,0 +1 @@
|
||||
export default function theDefault(): void {}
|
14
tests/compiler/export-default.untouched.wat
Normal file
14
tests/compiler/export-default.untouched.wat
Normal file
@ -0,0 +1,14 @@
|
||||
(module
|
||||
(type $FUNCSIG$v (func))
|
||||
(memory $0 0)
|
||||
(table $0 1 funcref)
|
||||
(elem (i32.const 0) $null)
|
||||
(export "memory" (memory $0))
|
||||
(export "theDefault" (func $export-default/theDefault))
|
||||
(export "default" (func $export-default/theDefault))
|
||||
(func $export-default/theDefault (; 0 ;) (type $FUNCSIG$v)
|
||||
nop
|
||||
)
|
||||
(func $null (; 1 ;) (type $FUNCSIG$v)
|
||||
)
|
||||
)
|
@ -13,6 +13,7 @@
|
||||
(export "b" (global $export/b))
|
||||
(export "renamed_c" (global $export/c))
|
||||
(export "ns.two" (func $export/ns.one))
|
||||
(export "default.two" (func $export/ns.one))
|
||||
(func $export/add (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
|
@ -28,3 +28,5 @@ export namespace ns {
|
||||
function one(): void {}
|
||||
export function two(): void {}
|
||||
}
|
||||
|
||||
export default ns;
|
||||
|
@ -15,6 +15,7 @@
|
||||
(export "b" (global $export/b))
|
||||
(export "renamed_c" (global $export/c))
|
||||
(export "ns.two" (func $export/ns.two))
|
||||
(export "default.two" (func $export/ns.two))
|
||||
(func $export/add (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
|
@ -21,3 +21,11 @@ other.sub(other.b, other.renamed_c) +
|
||||
other.renamed_mul(other.renamed_c, other.a);
|
||||
|
||||
other.ns.two();
|
||||
|
||||
import theDefault from "./export";
|
||||
|
||||
theDefault.two();
|
||||
|
||||
import theOtherDefault from "./export-default";
|
||||
|
||||
theOtherDefault();
|
||||
|
@ -27,37 +27,42 @@
|
||||
(func $export/ns.two (; 3 ;) (type $FUNCSIG$v)
|
||||
nop
|
||||
)
|
||||
(func $start:import (; 4 ;) (type $FUNCSIG$v)
|
||||
global.get $export/a
|
||||
global.get $export/b
|
||||
call $export/add
|
||||
global.get $export/b
|
||||
global.get $export/c
|
||||
call $export/sub
|
||||
i32.add
|
||||
global.get $export/c
|
||||
global.get $export/a
|
||||
call $export/mul
|
||||
i32.add
|
||||
drop
|
||||
call $export/ns.two
|
||||
global.get $export/a
|
||||
global.get $export/b
|
||||
call $export/add
|
||||
global.get $export/b
|
||||
global.get $export/c
|
||||
call $export/sub
|
||||
i32.add
|
||||
global.get $export/c
|
||||
global.get $export/a
|
||||
call $export/mul
|
||||
i32.add
|
||||
drop
|
||||
call $export/ns.two
|
||||
(func $export-default/theDefault (; 4 ;) (type $FUNCSIG$v)
|
||||
nop
|
||||
)
|
||||
(func $start (; 5 ;) (type $FUNCSIG$v)
|
||||
(func $start:import (; 5 ;) (type $FUNCSIG$v)
|
||||
global.get $export/a
|
||||
global.get $export/b
|
||||
call $export/add
|
||||
global.get $export/b
|
||||
global.get $export/c
|
||||
call $export/sub
|
||||
i32.add
|
||||
global.get $export/c
|
||||
global.get $export/a
|
||||
call $export/mul
|
||||
i32.add
|
||||
drop
|
||||
call $export/ns.two
|
||||
global.get $export/a
|
||||
global.get $export/b
|
||||
call $export/add
|
||||
global.get $export/b
|
||||
global.get $export/c
|
||||
call $export/sub
|
||||
i32.add
|
||||
global.get $export/c
|
||||
global.get $export/a
|
||||
call $export/mul
|
||||
i32.add
|
||||
drop
|
||||
call $export/ns.two
|
||||
call $export/ns.two
|
||||
call $export-default/theDefault
|
||||
)
|
||||
(func $start (; 6 ;) (type $FUNCSIG$v)
|
||||
call $start:import
|
||||
)
|
||||
(func $null (; 6 ;) (type $FUNCSIG$v)
|
||||
(func $null (; 7 ;) (type $FUNCSIG$v)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user