mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-05-29 15:41:26 +00:00
Merge branch 'master' into runtime
This commit is contained in:
commit
6bf8276746
1
std/assembly/bindings/wasi.ts
Normal file
1
std/assembly/bindings/wasi.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./wasi_unstable";
|
1449
std/assembly/bindings/wasi_unstable.ts
Normal file
1449
std/assembly/bindings/wasi_unstable.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,7 @@ import { ArrayBufferView } from "./arraybuffer";
|
|||||||
store<u16>(out, <u16>code);
|
store<u16>(out, <u16>code);
|
||||||
} else {
|
} else {
|
||||||
code -= 0x10000;
|
code -= 0x10000;
|
||||||
let hi: u32 = (code >>> 10) + 0xD800;
|
let hi: u32 = (code >>> 10) + 0xD800;
|
||||||
let lo: u32 = (code & 0x3FF) + 0xDC00;
|
let lo: u32 = (code & 0x3FF) + 0xDC00;
|
||||||
store<u32>(out, (hi << 16) | lo);
|
store<u32>(out, (hi << 16) | lo);
|
||||||
}
|
}
|
||||||
@ -95,7 +95,13 @@ import { ArrayBufferView } from "./arraybuffer";
|
|||||||
return !compareImpl(left, 0, right, 0, leftLength);
|
return !compareImpl(left, 0, right, 0, leftLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@operator("!=") private static __ne(left: String | null, right: String | null): bool {
|
@operator.prefix("!")
|
||||||
|
private static __not(str: String): bool {
|
||||||
|
return str === null || !str.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@operator("!=")
|
||||||
|
private static __ne(left: String, right: String): bool {
|
||||||
return !this.__eq(left, right);
|
return !this.__eq(left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,9 +344,9 @@ import { ArrayBufferView } from "./arraybuffer";
|
|||||||
}
|
}
|
||||||
|
|
||||||
slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String {
|
slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String {
|
||||||
var len = this.length;
|
var len = this.length;
|
||||||
var begin = beginIndex < 0 ? max(beginIndex + len, 0) : min(beginIndex, len);
|
var begin = beginIndex < 0 ? max(beginIndex + len, 0) : min(beginIndex, len);
|
||||||
var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len);
|
var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len);
|
||||||
len = end - begin;
|
len = end - begin;
|
||||||
if (len <= 0) return changetype<String>("");
|
if (len <= 0) return changetype<String>("");
|
||||||
var out = runtime.allocate(len << 1);
|
var out = runtime.allocate(len << 1);
|
||||||
@ -454,7 +460,7 @@ import { ArrayBufferView } from "./arraybuffer";
|
|||||||
cp = (
|
cp = (
|
||||||
(cp & 7) << 18 |
|
(cp & 7) << 18 |
|
||||||
(load<u8>(ptr + ptrPos++) & 63) << 12 |
|
(load<u8>(ptr + ptrPos++) & 63) << 12 |
|
||||||
(load<u8>(ptr + ptrPos++) & 63) << 6 |
|
(load<u8>(ptr + ptrPos++) & 63) << 6 |
|
||||||
load<u8>(ptr + ptrPos++) & 63
|
load<u8>(ptr + ptrPos++) & 63
|
||||||
) - 0x10000;
|
) - 0x10000;
|
||||||
store<u16>(buf + bufPos, 0xD800 + (cp >> 10));
|
store<u16>(buf + bufPos, 0xD800 + (cp >> 10));
|
||||||
@ -465,7 +471,7 @@ import { ArrayBufferView } from "./arraybuffer";
|
|||||||
assert(ptrPos + 2 <= len);
|
assert(ptrPos + 2 <= len);
|
||||||
store<u16>(buf + bufPos,
|
store<u16>(buf + bufPos,
|
||||||
(cp & 15) << 12 |
|
(cp & 15) << 12 |
|
||||||
(load<u8>(ptr + ptrPos++) & 63) << 6 |
|
(load<u8>(ptr + ptrPos++) & 63) << 6 |
|
||||||
load<u8>(ptr + ptrPos++) & 63
|
load<u8>(ptr + ptrPos++) & 63
|
||||||
);
|
);
|
||||||
bufPos += 2;
|
bufPos += 2;
|
||||||
@ -490,8 +496,8 @@ import { ArrayBufferView } from "./arraybuffer";
|
|||||||
++off; ++pos;
|
++off; ++pos;
|
||||||
} else if (c1 < 2048) {
|
} else if (c1 < 2048) {
|
||||||
let ptr = buf + off;
|
let ptr = buf + off;
|
||||||
store<u8>(ptr, c1 >> 6 | 192);
|
store<u8>(ptr, c1 >> 6 | 192);
|
||||||
store<u8>(ptr, c1 & 63 | 128, 1);
|
store<u8>(ptr, c1 & 63 | 128, 1);
|
||||||
off += 2; ++pos;
|
off += 2; ++pos;
|
||||||
} else {
|
} else {
|
||||||
let ptr = buf + off;
|
let ptr = buf + off;
|
||||||
@ -501,15 +507,15 @@ import { ArrayBufferView } from "./arraybuffer";
|
|||||||
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
||||||
store<u8>(ptr, c1 >> 18 | 240);
|
store<u8>(ptr, c1 >> 18 | 240);
|
||||||
store<u8>(ptr, c1 >> 12 & 63 | 128, 1);
|
store<u8>(ptr, c1 >> 12 & 63 | 128, 1);
|
||||||
store<u8>(ptr, c1 >> 6 & 63 | 128, 2);
|
store<u8>(ptr, c1 >> 6 & 63 | 128, 2);
|
||||||
store<u8>(ptr, c1 & 63 | 128, 3);
|
store<u8>(ptr, c1 & 63 | 128, 3);
|
||||||
off += 4; pos += 2;
|
off += 4; pos += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
store<u8>(ptr, c1 >> 12 | 224);
|
store<u8>(ptr, c1 >> 12 | 224);
|
||||||
store<u8>(ptr, c1 >> 6 & 63 | 128, 1);
|
store<u8>(ptr, c1 >> 6 & 63 | 128, 1);
|
||||||
store<u8>(ptr, c1 & 63 | 128, 2);
|
store<u8>(ptr, c1 & 63 | 128, 2);
|
||||||
off += 3; ++pos;
|
off += 3; ++pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2358,7 +2358,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 1648
|
i32.const 1648
|
||||||
i32.const 191
|
i32.const 197
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
@ -3416,7 +3416,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 1648
|
i32.const 1648
|
||||||
i32.const 191
|
i32.const 197
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
@ -142,7 +142,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 64
|
i32.const 64
|
||||||
i32.const 166
|
i32.const 172
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
@ -218,7 +218,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 64
|
i32.const 64
|
||||||
i32.const 166
|
i32.const 172
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
@ -6294,7 +6294,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 4376
|
i32.const 4376
|
||||||
i32.const 191
|
i32.const 197
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
@ -9713,7 +9713,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 4376
|
i32.const 4376
|
||||||
i32.const 191
|
i32.const 197
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
@ -1551,7 +1551,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 449
|
i32.const 455
|
||||||
i32.const 8
|
i32.const 8
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
@ -1598,7 +1598,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 453
|
i32.const 459
|
||||||
i32.const 8
|
i32.const 8
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
@ -1677,7 +1677,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 465
|
i32.const 471
|
||||||
i32.const 8
|
i32.const 8
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
@ -1732,7 +1732,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 474
|
i32.const 480
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
@ -2033,7 +2033,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 449
|
i32.const 455
|
||||||
i32.const 8
|
i32.const 8
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
@ -2087,7 +2087,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 453
|
i32.const 459
|
||||||
i32.const 8
|
i32.const 8
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
@ -2182,7 +2182,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 465
|
i32.const 471
|
||||||
i32.const 8
|
i32.const 8
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
@ -2245,7 +2245,7 @@
|
|||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.const 96
|
i32.const 96
|
||||||
i32.const 474
|
i32.const 480
|
||||||
i32.const 4
|
i32.const 4
|
||||||
call $~lib/env/abort
|
call $~lib/env/abort
|
||||||
unreachable
|
unreachable
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,10 @@ assert(changetype<usize>(str) == changetype<usize>("hi, I'm a string"));
|
|||||||
assert(str.length == 16);
|
assert(str.length == 16);
|
||||||
assert(str.charCodeAt(0) == 0x68);
|
assert(str.charCodeAt(0) == 0x68);
|
||||||
|
|
||||||
|
assert(!!"" == false);
|
||||||
|
assert(!!"\0" == true);
|
||||||
|
assert(!!"a" == true);
|
||||||
|
|
||||||
assert(String.fromCharCode(0) == "\0");
|
assert(String.fromCharCode(0) == "\0");
|
||||||
assert(String.fromCharCode(54) == "6");
|
assert(String.fromCharCode(54) == "6");
|
||||||
assert(String.fromCharCode(0x10000 + 54) == "6");
|
assert(String.fromCharCode(0x10000 + 54) == "6");
|
||||||
@ -223,8 +227,8 @@ assert(utoa64(u64.MAX_VALUE) == "18446744073709551615");
|
|||||||
|
|
||||||
assert(itoa64(0) == "0");
|
assert(itoa64(0) == "0");
|
||||||
assert(itoa64(-1234) == "-1234");
|
assert(itoa64(-1234) == "-1234");
|
||||||
assert(itoa64(0xffffffff) == "4294967295");
|
assert(itoa64(0xffffffff) == "4294967295");
|
||||||
assert(itoa64(-0xffffffff) == "-4294967295");
|
assert(itoa64(-0xffffffff) == "-4294967295");
|
||||||
assert(itoa64(68719476735) == "68719476735");
|
assert(itoa64(68719476735) == "68719476735");
|
||||||
assert(itoa64(-68719476735) == "-68719476735");
|
assert(itoa64(-68719476735) == "-68719476735");
|
||||||
assert(itoa64(-868719476735) == "-868719476735");
|
assert(itoa64(-868719476735) == "-868719476735");
|
||||||
@ -234,13 +238,13 @@ assert(itoa64(i64.MAX_VALUE) == "9223372036854775807");
|
|||||||
assert(itoa64(i64.MIN_VALUE) == "-9223372036854775808");
|
assert(itoa64(i64.MIN_VALUE) == "-9223372036854775808");
|
||||||
|
|
||||||
// special cases
|
// special cases
|
||||||
assert(dtoa(0.0) == "0.0");
|
assert(dtoa(0.0) == "0.0");
|
||||||
assert(dtoa(-0.0) == "0.0");
|
assert(dtoa(-0.0) == "0.0");
|
||||||
assert(dtoa(NaN) == "NaN");
|
assert(dtoa(NaN) == "NaN");
|
||||||
assert(dtoa(+Infinity) == "Infinity");
|
assert(dtoa(+Infinity) == "Infinity");
|
||||||
assert(dtoa(-Infinity) == "-Infinity");
|
assert(dtoa(-Infinity) == "-Infinity");
|
||||||
assert(dtoa(+f64.EPSILON) == "2.220446049250313e-16");
|
assert(dtoa(+f64.EPSILON) == "2.220446049250313e-16");
|
||||||
assert(dtoa(-f64.EPSILON) == "-2.220446049250313e-16");
|
assert(dtoa(-f64.EPSILON) == "-2.220446049250313e-16");
|
||||||
assert(dtoa(+f64.MAX_VALUE) == "1.7976931348623157e+308");
|
assert(dtoa(+f64.MAX_VALUE) == "1.7976931348623157e+308");
|
||||||
assert(dtoa(-f64.MAX_VALUE) == "-1.7976931348623157e+308");
|
assert(dtoa(-f64.MAX_VALUE) == "-1.7976931348623157e+308");
|
||||||
assert(dtoa(4.185580496821357e+298) == "4.185580496821357e+298");
|
assert(dtoa(4.185580496821357e+298) == "4.185580496821357e+298");
|
||||||
@ -257,44 +261,44 @@ assert(dtoa(5e-324) == "5e-324");
|
|||||||
// Actual: 1.2344999999999999e+21
|
// Actual: 1.2344999999999999e+21
|
||||||
// assert(dtoa(1.2345e+21) == "1.2345e+21");
|
// assert(dtoa(1.2345e+21) == "1.2345e+21");
|
||||||
|
|
||||||
assert(dtoa(1.0) == "1.0");
|
assert(dtoa(1.0) == "1.0");
|
||||||
assert(dtoa(0.1) == "0.1");
|
assert(dtoa(0.1) == "0.1");
|
||||||
assert(dtoa(-1.0) == "-1.0");
|
assert(dtoa(-1.0) == "-1.0");
|
||||||
assert(dtoa(-0.1) == "-0.1");
|
assert(dtoa(-0.1) == "-0.1");
|
||||||
|
|
||||||
assert(dtoa(1e+6) == "1000000.0");
|
assert(dtoa(1e+6) == "1000000.0");
|
||||||
assert(dtoa(1e-6) == "0.000001");
|
assert(dtoa(1e-6) == "0.000001");
|
||||||
assert(dtoa(-1e+6) == "-1000000.0");
|
assert(dtoa(-1e+6) == "-1000000.0");
|
||||||
assert(dtoa(-1e-6) == "-0.000001");
|
assert(dtoa(-1e-6) == "-0.000001");
|
||||||
assert(dtoa(1e+7) == "10000000.0");
|
assert(dtoa(1e+7) == "10000000.0");
|
||||||
assert(dtoa(1e-7) == "1e-7");
|
assert(dtoa(1e-7) == "1e-7");
|
||||||
|
|
||||||
assert(dtoa(1e+308) == "1e+308");
|
assert(dtoa(1e+308) == "1e+308");
|
||||||
assert(dtoa(-1e+308) == "-1e+308");
|
assert(dtoa(-1e+308) == "-1e+308");
|
||||||
assert(dtoa(1e+309) == "Infinity");
|
assert(dtoa(1e+309) == "Infinity");
|
||||||
assert(dtoa(-1e+309) == "-Infinity");
|
assert(dtoa(-1e+309) == "-Infinity");
|
||||||
assert(dtoa(1e-308) == "1e-308");
|
assert(dtoa(1e-308) == "1e-308");
|
||||||
assert(dtoa(-1e-308) == "-1e-308");
|
assert(dtoa(-1e-308) == "-1e-308");
|
||||||
assert(dtoa(1e-323) == "1e-323");
|
assert(dtoa(1e-323) == "1e-323");
|
||||||
assert(dtoa(-1e-323) == "-1e-323");
|
assert(dtoa(-1e-323) == "-1e-323");
|
||||||
assert(dtoa(1e-324) == "0.0");
|
assert(dtoa(1e-324) == "0.0");
|
||||||
|
|
||||||
assert(dtoa(4294967272) == "4294967272.0");
|
assert(dtoa(4294967272) == "4294967272.0");
|
||||||
assert(dtoa(1.23121456734562345678e-8) == "1.2312145673456234e-8");
|
assert(dtoa(1.23121456734562345678e-8) == "1.2312145673456234e-8");
|
||||||
// assert(dtoa(-0.0000010471975511965976) == "-0.0000010471975511965976"); // FIXME
|
// assert(dtoa(-0.0000010471975511965976) == "-0.0000010471975511965976"); // FIXME
|
||||||
assert(dtoa(555555555.55555555) == "555555555.5555556");
|
assert(dtoa(555555555.55555555) == "555555555.5555556");
|
||||||
assert(dtoa(0.9999999999999999) == "0.9999999999999999");
|
assert(dtoa(0.9999999999999999) == "0.9999999999999999");
|
||||||
assert(dtoa(0.99999999999999995) == "1.0");
|
assert(dtoa(0.99999999999999995) == "1.0");
|
||||||
assert(dtoa(1234e-2) == "12.34");
|
assert(dtoa(1234e-2) == "12.34");
|
||||||
// assert(dtoa(0.1 + 0.2) == "0.30000000000000004"); // FIXME
|
// assert(dtoa(0.1 + 0.2) == "0.30000000000000004"); // FIXME
|
||||||
assert(dtoa(1.0 / 3.0) == "0.3333333333333333");
|
assert(dtoa(1.0 / 3.0) == "0.3333333333333333");
|
||||||
assert(dtoa(1.234e+20) == "123400000000000000000.0");
|
assert(dtoa(1.234e+20) == "123400000000000000000.0");
|
||||||
assert(dtoa(1.234e+21) == "1.234e+21");
|
assert(dtoa(1.234e+21) == "1.234e+21");
|
||||||
assert(dtoa(2.71828) == "2.71828");
|
assert(dtoa(2.71828) == "2.71828");
|
||||||
assert(dtoa(2.71828e-2) == "0.0271828");
|
assert(dtoa(2.71828e-2) == "0.0271828");
|
||||||
assert(dtoa(2.71828e+2) == "271.828");
|
assert(dtoa(2.71828e+2) == "271.828");
|
||||||
assert(dtoa(1.1e+128) == "1.1e+128");
|
assert(dtoa(1.1e+128) == "1.1e+128");
|
||||||
assert(dtoa(1.1e-64) == "1.1e-64");
|
assert(dtoa(1.1e-64) == "1.1e-64");
|
||||||
assert(dtoa(0.000035689) == "0.000035689");
|
assert(dtoa(0.000035689) == "0.000035689");
|
||||||
|
|
||||||
// assert(dtoa(f32.MAX_VALUE) == "3.4028234663852886e+38"); // FIXME
|
// assert(dtoa(f32.MAX_VALUE) == "3.4028234663852886e+38"); // FIXME
|
||||||
|
File diff suppressed because it is too large
Load Diff
25
tests/compiler/wasi.optimized.wat
Normal file
25
tests/compiler/wasi.optimized.wat
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
(module
|
||||||
|
(type $FUNCSIG$vi (func (param i32)))
|
||||||
|
(type $FUNCSIG$v (func))
|
||||||
|
(memory $0 1)
|
||||||
|
(data (i32.const 8) "\01\00\00\00\0e")
|
||||||
|
(data (i32.const 24) "w\00a\00s\00i\00.\00t\00s")
|
||||||
|
(table $0 2 funcref)
|
||||||
|
(elem (i32.const 0) $null $~lib/string/String~traverse)
|
||||||
|
(global $wasi/sig (mut i32) (i32.const 1))
|
||||||
|
(global $~lib/capabilities i32 (i32.const 2))
|
||||||
|
(export "memory" (memory $0))
|
||||||
|
(export "table" (table $0))
|
||||||
|
(export ".capabilities" (global $~lib/capabilities))
|
||||||
|
(start $start)
|
||||||
|
(func $~lib/string/String~traverse (; 0 ;) (type $FUNCSIG$vi) (param $0 i32)
|
||||||
|
nop
|
||||||
|
)
|
||||||
|
(func $start (; 1 ;) (type $FUNCSIG$v)
|
||||||
|
i32.const 9
|
||||||
|
global.set $wasi/sig
|
||||||
|
)
|
||||||
|
(func $null (; 2 ;) (type $FUNCSIG$v)
|
||||||
|
nop
|
||||||
|
)
|
||||||
|
)
|
73
tests/compiler/wasi.ts
Normal file
73
tests/compiler/wasi.ts
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import { dirent, rwevent, fdstat, filestat, iovec, clocksubscription, fdsubscription, signal, dirprestat } from "bindings/wasi";
|
||||||
|
|
||||||
|
const WASM32 = 1;
|
||||||
|
const WASM64 = 2;
|
||||||
|
|
||||||
|
assert(offsetof<dirent>("next") == 0);
|
||||||
|
assert(offsetof<dirent>("ino") == 8);
|
||||||
|
assert(offsetof<dirent>("namlen") == 16);
|
||||||
|
assert(offsetof<dirent>("type") == 20);
|
||||||
|
assert(offsetof<dirent>() == 24);
|
||||||
|
|
||||||
|
assert(offsetof<rwevent>("userdata") == 0);
|
||||||
|
assert(offsetof<rwevent>("error") == 8);
|
||||||
|
assert(offsetof<rwevent>("type") == 10);
|
||||||
|
assert(offsetof<rwevent>("nbytes") == 16);
|
||||||
|
assert(offsetof<rwevent>("flags") == 24);
|
||||||
|
assert(offsetof<rwevent>() == 32);
|
||||||
|
|
||||||
|
assert(offsetof<fdstat>("filetype") == 0);
|
||||||
|
assert(offsetof<fdstat>("flags") == 2);
|
||||||
|
assert(offsetof<fdstat>("rights_base") == 8);
|
||||||
|
assert(offsetof<fdstat>("rights_inheriting") == 16);
|
||||||
|
assert(offsetof<fdstat>() == 24);
|
||||||
|
|
||||||
|
assert(offsetof<filestat>("dev") == 0);
|
||||||
|
assert(offsetof<filestat>("ino") == 8);
|
||||||
|
assert(offsetof<filestat>("filetype") == 16);
|
||||||
|
assert(offsetof<filestat>("nlink") == 20);
|
||||||
|
assert(offsetof<filestat>("size") == 24);
|
||||||
|
assert(offsetof<filestat>("atim") == 32);
|
||||||
|
assert(offsetof<filestat>("mtim") == 40);
|
||||||
|
assert(offsetof<filestat>("ctim") == 48);
|
||||||
|
assert(offsetof<filestat>() == 56);
|
||||||
|
|
||||||
|
assert(offsetof<iovec>("buf") == 0);
|
||||||
|
if (ASC_TARGET == WASM32) {
|
||||||
|
assert(offsetof<iovec>("buf_len") == 4);
|
||||||
|
assert(offsetof<iovec>() == 8);
|
||||||
|
} else if (ASC_TARGET == WASM64) {
|
||||||
|
assert(offsetof<iovec>("buf_len") == 8);
|
||||||
|
assert(offsetof<iovec>() == 16);
|
||||||
|
} else {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(offsetof<clocksubscription>("userdata") == 0);
|
||||||
|
assert(offsetof<clocksubscription>("type") == 8);
|
||||||
|
assert(offsetof<clocksubscription>("identifier") == 16);
|
||||||
|
assert(offsetof<clocksubscription>("clock_id") == 24);
|
||||||
|
assert(offsetof<clocksubscription>("timeout") == 32);
|
||||||
|
assert(offsetof<clocksubscription>("precision") == 40);
|
||||||
|
assert(offsetof<clocksubscription>("flags") == 48);
|
||||||
|
assert(offsetof<clocksubscription>() == 56);
|
||||||
|
|
||||||
|
assert(offsetof<fdsubscription>("userdata") == 0);
|
||||||
|
assert(offsetof<fdsubscription>("type") == 8);
|
||||||
|
assert(offsetof<fdsubscription>("fd") == 16);
|
||||||
|
assert(offsetof<fdsubscription>() == 20);
|
||||||
|
|
||||||
|
assert(offsetof<dirprestat>("type") == 0);
|
||||||
|
if (ASC_TARGET == WASM32) {
|
||||||
|
assert(offsetof<dirprestat>("name_len") == 4);
|
||||||
|
assert(offsetof<dirprestat>() == 8);
|
||||||
|
} else if (ASC_TARGET == WASM64) {
|
||||||
|
assert(offsetof<dirprestat>("name_len") == 8);
|
||||||
|
assert(offsetof<dirprestat>() == 16);
|
||||||
|
} else {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check assignability of mimicked typed enums
|
||||||
|
var sig: signal = signal.HUP;
|
||||||
|
sig = signal.KILL;
|
552
tests/compiler/wasi.untouched.wat
Normal file
552
tests/compiler/wasi.untouched.wat
Normal file
@ -0,0 +1,552 @@
|
|||||||
|
(module
|
||||||
|
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
|
||||||
|
(type $FUNCSIG$vi (func (param i32)))
|
||||||
|
(type $FUNCSIG$v (func))
|
||||||
|
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
|
||||||
|
(memory $0 1)
|
||||||
|
(data (i32.const 8) "\01\00\00\00\0e\00\00\00\00\00\00\00\00\00\00\00w\00a\00s\00i\00.\00t\00s\00")
|
||||||
|
(table $0 2 funcref)
|
||||||
|
(elem (i32.const 0) $null $~lib/string/String~traverse)
|
||||||
|
(global $wasi/WASM32 i32 (i32.const 1))
|
||||||
|
(global $wasi/WASM64 i32 (i32.const 2))
|
||||||
|
(global $~lib/ASC_TARGET i32 (i32.const 0))
|
||||||
|
(global $wasi/sig (mut i32) (i32.const 1))
|
||||||
|
(global $~lib/memory/HEAP_BASE i32 (i32.const 40))
|
||||||
|
(global $~lib/capabilities i32 (i32.const 2))
|
||||||
|
(export "memory" (memory $0))
|
||||||
|
(export "table" (table $0))
|
||||||
|
(export ".capabilities" (global $~lib/capabilities))
|
||||||
|
(start $start)
|
||||||
|
(func $~lib/string/String~traverse (; 1 ;) (type $FUNCSIG$vi) (param $0 i32)
|
||||||
|
(local $1 i32)
|
||||||
|
)
|
||||||
|
(func $start:wasi (; 2 ;) (type $FUNCSIG$v)
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 6
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 7
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 16
|
||||||
|
i32.const 16
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 8
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 20
|
||||||
|
i32.const 20
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 9
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 24
|
||||||
|
i32.const 24
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 10
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 12
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 13
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 10
|
||||||
|
i32.const 10
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 14
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 16
|
||||||
|
i32.const 16
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 15
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 24
|
||||||
|
i32.const 24
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 16
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 32
|
||||||
|
i32.const 32
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 17
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 19
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 2
|
||||||
|
i32.const 2
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 20
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 21
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 16
|
||||||
|
i32.const 16
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 22
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 24
|
||||||
|
i32.const 24
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 23
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 25
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 26
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 16
|
||||||
|
i32.const 16
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 27
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 20
|
||||||
|
i32.const 20
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 28
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 24
|
||||||
|
i32.const 24
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 29
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 32
|
||||||
|
i32.const 32
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 30
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 40
|
||||||
|
i32.const 40
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 31
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 48
|
||||||
|
i32.const 48
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 32
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 56
|
||||||
|
i32.const 56
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 33
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 35
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
block
|
||||||
|
i32.const 4
|
||||||
|
i32.const 4
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 37
|
||||||
|
i32.const 2
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 38
|
||||||
|
i32.const 2
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
end
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 46
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 47
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 16
|
||||||
|
i32.const 16
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 48
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 24
|
||||||
|
i32.const 24
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 49
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 32
|
||||||
|
i32.const 32
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 50
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 40
|
||||||
|
i32.const 40
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 51
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 48
|
||||||
|
i32.const 48
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 52
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 56
|
||||||
|
i32.const 56
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 53
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 55
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 56
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 16
|
||||||
|
i32.const 16
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 57
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 20
|
||||||
|
i32.const 20
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 58
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 0
|
||||||
|
i32.const 0
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 60
|
||||||
|
i32.const 0
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
block
|
||||||
|
i32.const 4
|
||||||
|
i32.const 4
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 62
|
||||||
|
i32.const 2
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
i32.const 8
|
||||||
|
i32.const 8
|
||||||
|
i32.eq
|
||||||
|
i32.eqz
|
||||||
|
if
|
||||||
|
i32.const 0
|
||||||
|
i32.const 24
|
||||||
|
i32.const 63
|
||||||
|
i32.const 2
|
||||||
|
call $~lib/env/abort
|
||||||
|
unreachable
|
||||||
|
end
|
||||||
|
end
|
||||||
|
i32.const 9
|
||||||
|
global.set $wasi/sig
|
||||||
|
)
|
||||||
|
(func $start (; 3 ;) (type $FUNCSIG$v)
|
||||||
|
call $start:wasi
|
||||||
|
)
|
||||||
|
(func $null (; 4 ;) (type $FUNCSIG$v)
|
||||||
|
)
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user