mimic typed enums

This commit is contained in:
dcode
2019-03-28 01:32:15 +01:00
parent d0452ea419
commit aa6ed8eb0c
4 changed files with 317 additions and 305 deletions

View File

@ -3,10 +3,16 @@
(memory $0 1)
(data (i32.const 8) "\07\00\00\00w\00a\00s\00i\00.\00t\00s")
(table $0 1 funcref)
(elem (i32.const 0) $start)
(elem (i32.const 0) $null)
(global $wasi/sig (mut i32) (i32.const 1))
(export "memory" (memory $0))
(export "table" (table $0))
(start $start)
(func $start (; 0 ;) (type $FUNCSIG$v)
i32.const 9
global.set $wasi/sig
)
(func $null (; 1 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -1,4 +1,4 @@
import { dirent, rwevent, fdstat, filestat, iovec, clocksubscription, fdsubscription } from "bindings/wasi";
import { dirent, rwevent, fdstat, filestat, iovec, clocksubscription, fdsubscription, signal } from "bindings/wasi";
// TODO: WASM64
@ -48,3 +48,7 @@ assert(offsetof<fdsubscription>("userdata") == 0);
assert(offsetof<fdsubscription>("type") == 8);
assert(offsetof<fdsubscription>("fd") == 16);
assert(offsetof<fdsubscription>() == 20);
// check assignability of mimicked typed enums
var sig: signal = signal.HUP;
sig = signal.KILL;

View File

@ -6,6 +6,7 @@
(data (i32.const 8) "\07\00\00\00w\00a\00s\00i\00.\00t\00s\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $wasi/sig (mut i32) (i32.const 1))
(global $~lib/memory/HEAP_BASE i32 (i32.const 28))
(export "memory" (memory $0))
(export "table" (table $0))
@ -491,6 +492,8 @@
call $~lib/env/abort
unreachable
end
i32.const 9
global.set $wasi/sig
)
(func $start (; 2 ;) (type $FUNCSIG$v)
call $start:wasi