mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-20 02:11:31 +00:00
Add initial std Symbol; Fix some type inference issues
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
(global $std/pointer/two (mut i32) (i32.const 0))
|
||||
(global $std/pointer/add (mut i32) (i32.const 0))
|
||||
(global $std/pointer/sub (mut i32) (i32.const 0))
|
||||
(global $std/pointer/nextOne (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\0e\00\00\00s\00t\00d\00/\00p\00o\00i\00n\00t\00e\00r\00.\00t\00s")
|
||||
(export "_setargc" (func $~setargc))
|
||||
@ -214,6 +215,24 @@
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
(set_global $std/pointer/nextOne
|
||||
(get_global $std/pointer/one)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $std/pointer/nextOne)
|
||||
(get_global $std/pointer/one)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 70)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $std/pointer/Pointer<Entry>#get:offset
|
||||
@ -225,7 +244,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 70)
|
||||
(i32.const 71)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -242,7 +261,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 72)
|
||||
(i32.const 73)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -271,7 +290,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 75)
|
||||
(i32.const 76)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -290,7 +309,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 76)
|
||||
(i32.const 77)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -309,7 +328,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 77)
|
||||
(i32.const 78)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -66,7 +66,8 @@ var sub = two - one;
|
||||
assert(sub.offset == 16);
|
||||
|
||||
assert(one.offset == 8);
|
||||
++one; // FIXME: assigning to a var yields an 'auto to void' error
|
||||
var nextOne = ++one;
|
||||
assert(nextOne === one);
|
||||
assert(one.offset == 16);
|
||||
|
||||
assert(two.offset == 24);
|
||||
|
@ -10,6 +10,7 @@
|
||||
(global $std/pointer/two (mut i32) (i32.const 0))
|
||||
(global $std/pointer/add (mut i32) (i32.const 0))
|
||||
(global $std/pointer/sub (mut i32) (i32.const 0))
|
||||
(global $std/pointer/nextOne (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 40))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\0e\00\00\00s\00t\00d\00/\00p\00o\00i\00n\00t\00e\00r\00.\00t\00s\00")
|
||||
@ -254,17 +255,39 @@
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/pointer/one
|
||||
(block $std/pointer/Pointer<Entry>#inc|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/pointer/one)
|
||||
)
|
||||
(br $std/pointer/Pointer<Entry>#inc|inlined.0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
(set_global $std/pointer/nextOne
|
||||
(block (result i32)
|
||||
(set_global $std/pointer/one
|
||||
(block $std/pointer/Pointer<Entry>#inc|inlined.0 (result i32)
|
||||
(set_local $0
|
||||
(get_global $std/pointer/one)
|
||||
)
|
||||
(br $std/pointer/Pointer<Entry>#inc|inlined.0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_global $std/pointer/one)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(get_global $std/pointer/nextOne)
|
||||
(get_global $std/pointer/one)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 70)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -280,7 +303,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 70)
|
||||
(i32.const 71)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -299,7 +322,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 72)
|
||||
(i32.const 73)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -344,7 +367,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 75)
|
||||
(i32.const 76)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -365,7 +388,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 76)
|
||||
(i32.const 77)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
@ -386,7 +409,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 77)
|
||||
(i32.const 78)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
|
1856
tests/compiler/std/symbol.optimized.wat
Normal file
1856
tests/compiler/std/symbol.optimized.wat
Normal file
File diff suppressed because it is too large
Load Diff
23
tests/compiler/std/symbol.ts
Normal file
23
tests/compiler/std/symbol.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import "allocator/arena";
|
||||
|
||||
var sym1 = new Symbol("123");
|
||||
var sym2 = new Symbol("123");
|
||||
|
||||
assert(sym1 !== sym2);
|
||||
|
||||
var sym3 = Symbol.for("123");
|
||||
var sym4 = Symbol.for("123");
|
||||
|
||||
assert(sym3 === sym4);
|
||||
|
||||
var key1 = Symbol.keyFor(sym1);
|
||||
var key2 = Symbol.keyFor(sym2);
|
||||
|
||||
assert(key1 === null);
|
||||
assert(key2 === null);
|
||||
|
||||
var key3 = Symbol.keyFor(sym3);
|
||||
var key4 = Symbol.keyFor(sym4);
|
||||
|
||||
assert(key3 == "123");
|
||||
assert(key3 == key4);
|
2225
tests/compiler/std/symbol.untouched.wat
Normal file
2225
tests/compiler/std/symbol.untouched.wat
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user