Add initial std Symbol; Fix some type inference issues

This commit is contained in:
dcodeIO
2018-06-21 19:42:18 +02:00
parent 1626e50b0f
commit c74eed2bd8
15 changed files with 4257 additions and 47 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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)

File diff suppressed because it is too large Load Diff

View 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);

File diff suppressed because it is too large Load Diff