More std array

This commit is contained in:
dcodeIO
2018-01-14 21:17:43 +01:00
parent 827bb4afe8
commit 49d29fc9f2
13 changed files with 1149 additions and 313 deletions

View File

@ -4,6 +4,7 @@
(type $iv (func (param i32)))
(type $iiv (func (param i32 i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $v (func))
(global $std:heap/HEAP_OFFSET (mut i32) (i32.const 0))
(global $std/array/arr (mut i32) (i32.const 0))
@ -101,7 +102,12 @@
)
(get_local $1)
)
(func $std:heap/copy_memory (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $std:array/Array#get:length (; 1 ;) (type $ii) (param $0 i32) (result i32)
(i32.load offset=8
(get_local $0)
)
)
(func $std:heap/copy_memory (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(loop $continue|0
@ -1677,7 +1683,7 @@
)
)
)
(func $std:heap/move_memory (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $std:heap/move_memory (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(if
(i32.eq
@ -1967,10 +1973,10 @@
)
)
)
(func $std:heap/free_memory (; 3 ;) (type $iv) (param $0 i32)
(func $std:heap/free_memory (; 4 ;) (type $iv) (param $0 i32)
(nop)
)
(func $std:array/Array#__grow (; 4 ;) (type $iiv) (param $0 i32) (param $1 i32)
(func $std:array/Array#__grow (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32)
(local $2 i32)
(if
(i32.le_s
@ -2022,11 +2028,10 @@
(get_local $1)
)
)
(func $std:array/Array#push (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $std:array/Array#push (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(if
(i32.ge_u
(i32.eq
(i32.load offset=8
(get_local $0)
)
@ -2036,27 +2041,17 @@
)
(call $std:array/Array#__grow
(get_local $0)
(select
(tee_local $2
(i32.add
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
(if (result i32)
(i32.load offset=4
(get_local $0)
)
(i32.shl
(i32.load offset=4
(get_local $0)
)
(i32.const 1)
)
(tee_local $3
(i32.shl
(i32.load offset=4
(get_local $0)
)
(i32.const 1)
)
)
(i32.gt_s
(get_local $2)
(get_local $3)
)
(i32.const 1)
)
)
)
@ -2087,7 +2082,7 @@
)
(get_local $2)
)
(func $std:array/Array#__get (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $std:array/Array#__get (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(if
(i32.ge_u
(get_local $1)
@ -2109,66 +2104,52 @@
)
)
)
(func $std:array/Array#pop (; 7 ;) (type $ii) (param $0 i32) (result i32)
(func $std:array/Array#pop (; 8 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(if
(i32.and
(if (result i32)
(tee_local $1
(i32.lt_s
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
)
)
(get_local $1)
(i32.gt_u
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
)
(i32.const 1)
)
(unreachable)
)
(i32.store offset=8
(get_local $0)
(i32.sub
(i32.lt_s
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
)
(unreachable)
)
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(i32.load offset=8
(block (result i32)
(i32.store offset=8
(get_local $0)
(tee_local $1
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
)
)
)
(i32.mul
(get_local $1)
(i32.const 4)
)
(i32.const 4)
)
)
)
)
(func $std:array/Array#unshift (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $std:array/Array#unshift (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(if
(i32.ge_u
(i32.eq
(i32.load offset=8
(get_local $0)
)
(tee_local $4
(tee_local $2
(i32.load offset=4
(get_local $0)
)
@ -2177,26 +2158,14 @@
(block
(if
(i32.le_s
(tee_local $2
(select
(tee_local $2
(i32.add
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
)
)
(tee_local $3
(i32.mul
(get_local $4)
(i32.const 2)
)
)
(i32.gt_s
(tee_local $3
(if (result i32)
(get_local $2)
(i32.shl
(get_local $2)
(get_local $3)
(i32.const 1)
)
(i32.const 1)
)
)
(i32.load offset=4
@ -2205,10 +2174,10 @@
)
(unreachable)
)
(set_local $3
(set_local $4
(call $std:heap/allocate_memory
(i32.mul
(get_local $2)
(get_local $3)
(i32.const 4)
)
)
@ -2220,14 +2189,14 @@
(block
(call $std:heap/move_memory
(i32.add
(get_local $3)
(get_local $4)
(i32.const 4)
)
(i32.load
(get_local $0)
)
(i32.mul
(get_local $4)
(get_local $2)
(i32.const 4)
)
)
@ -2240,11 +2209,11 @@
)
(i32.store
(get_local $0)
(get_local $3)
(get_local $4)
)
(i32.store offset=4
(get_local $0)
(get_local $2)
(get_local $3)
)
)
(call $std:heap/move_memory
@ -2258,7 +2227,7 @@
(get_local $0)
)
(i32.mul
(get_local $4)
(get_local $2)
(i32.const 4)
)
)
@ -2271,7 +2240,7 @@
)
(i32.store offset=8
(get_local $0)
(tee_local $2
(tee_local $0
(i32.add
(i32.load offset=8
(get_local $0)
@ -2280,9 +2249,9 @@
)
)
)
(get_local $2)
(get_local $0)
)
(func $std:heap/set_memory (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $std:heap/set_memory (; 10 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i64)
(local $4 i32)
(if
@ -2615,28 +2584,12 @@
)
)
)
(func $std:array/Array#shift (; 10 ;) (type $ii) (param $0 i32) (result i32)
(func $std:array/Array#shift (; 11 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(if
(i32.and
(if (result i32)
(tee_local $1
(i32.lt_s
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
)
)
(get_local $1)
(i32.gt_u
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.lt_s
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
)
@ -2698,7 +2651,250 @@
)
(get_local $1)
)
(func $start (; 11 ;) (type $v)
(func $std:array/Array#reverse (; 12 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(set_local $1
(i32.const 0)
)
(set_local $2
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.const 1)
)
)
(loop $continue|0
(if
(i32.lt_u
(get_local $1)
(get_local $2)
)
(block
(set_local $3
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $1)
(i32.const 4)
)
)
)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $1)
(i32.const 4)
)
)
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $2)
(i32.const 4)
)
)
)
)
(i32.store
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $2)
(i32.const 4)
)
)
(get_local $3)
)
(set_local $1
(i32.add
(get_local $1)
(i32.const 1)
)
)
(set_local $2
(i32.sub
(get_local $2)
(i32.const 1)
)
)
(br $continue|0)
)
)
)
(get_local $0)
)
(func $std:array/Array#indexOf (; 13 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(if
(i32.lt_s
(get_local $2)
(i32.const 0)
)
(set_local $2
(i32.add
(i32.load offset=8
(get_local $0)
)
(get_local $2)
)
)
)
(loop $continue|0
(if
(i32.lt_u
(get_local $2)
(i32.load offset=8
(get_local $0)
)
)
(block
(if
(i32.eq
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $2)
(i32.const 4)
)
)
)
(get_local $1)
)
(return
(get_local $2)
)
)
(set_local $2
(i32.add
(get_local $2)
(i32.const 1)
)
)
(br $continue|0)
)
)
)
(i32.const -1)
)
(func $std:array/Array#splice (; 14 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(if
(i32.lt_s
(get_local $2)
(i32.const 1)
)
(return)
)
(if
(i32.lt_s
(get_local $1)
(i32.const 0)
)
(if
(i32.lt_s
(tee_local $1
(i32.add
(i32.load offset=8
(get_local $0)
)
(get_local $1)
)
)
(i32.const 0)
)
(set_local $1
(i32.const 0)
)
(if
(i32.ge_s
(get_local $1)
(i32.load offset=8
(get_local $0)
)
)
(return)
)
)
(if
(i32.ge_s
(get_local $1)
(i32.load offset=8
(get_local $0)
)
)
(return)
)
)
(call $std:heap/move_memory
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $1)
(i32.const 4)
)
)
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(i32.add
(get_local $1)
(tee_local $2
(select
(get_local $2)
(tee_local $1
(i32.sub
(i32.load offset=8
(get_local $0)
)
(get_local $1)
)
)
(i32.lt_s
(get_local $2)
(get_local $1)
)
)
)
)
(i32.const 4)
)
)
(i32.mul
(get_local $2)
(i32.const 4)
)
)
(i32.store offset=8
(get_local $0)
(i32.sub
(i32.load offset=8
(get_local $0)
)
(get_local $2)
)
)
)
(func $start (; 15 ;) (type $v)
(set_global $std:heap/HEAP_OFFSET
(get_global $HEAP_BASE)
)
@ -2708,7 +2904,7 @@
)
)
(if
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(unreachable)
@ -2737,7 +2933,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 1)
@ -2766,7 +2962,7 @@
(unreachable)
)
(if
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(unreachable)
@ -2788,7 +2984,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 1)
@ -2822,7 +3018,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 2)
@ -2866,7 +3062,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 3)
@ -2920,7 +3116,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 4)
@ -2984,7 +3180,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 5)
@ -3064,7 +3260,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 4)
@ -3134,7 +3330,7 @@
)
(if
(i32.ne
(i32.load offset=8
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 3)
@ -3180,5 +3376,140 @@
)
(unreachable)
)
(drop
(call $std:array/Array#reverse
(get_global $std/array/arr)
)
)
(if
(i32.ne
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 3)
)
(unreachable)
)
(if
(i32.ne
(i32.load offset=4
(get_global $std/array/arr)
)
(i32.const 8)
)
(unreachable)
)
(if
(i32.ne
(call $std:array/Array#__get
(get_global $std/array/arr)
(i32.const 0)
)
(i32.const 44)
)
(unreachable)
)
(if
(i32.ne
(call $std:array/Array#__get
(get_global $std/array/arr)
(i32.const 1)
)
(i32.const 43)
)
(unreachable)
)
(if
(i32.ne
(call $std:array/Array#__get
(get_global $std/array/arr)
(i32.const 2)
)
(i32.const 42)
)
(unreachable)
)
(set_global $std/array/i
(call $std:array/Array#indexOf
(get_global $std/array/arr)
(i32.const 44)
(i32.const 0)
)
)
(if
(get_global $std/array/i)
(unreachable)
)
(set_global $std/array/i
(call $std:array/Array#indexOf
(get_global $std/array/arr)
(i32.const 42)
(i32.const 0)
)
)
(if
(i32.ne
(get_global $std/array/i)
(i32.const 2)
)
(unreachable)
)
(set_global $std/array/i
(call $std:array/Array#indexOf
(get_global $std/array/arr)
(i32.const 45)
(i32.const 0)
)
)
(if
(i32.ne
(get_global $std/array/i)
(i32.const -1)
)
(unreachable)
)
(call $std:array/Array#splice
(get_global $std/array/arr)
(i32.const 1)
(i32.const 1)
)
(if
(i32.ne
(call $std:array/Array#get:length
(get_global $std/array/arr)
)
(i32.const 2)
)
(unreachable)
)
(if
(i32.ne
(i32.load offset=4
(get_global $std/array/arr)
)
(i32.const 8)
)
(unreachable)
)
(if
(i32.ne
(call $std:array/Array#__get
(get_global $std/array/arr)
(i32.const 0)
)
(i32.const 44)
)
(unreachable)
)
(if
(i32.ne
(call $std:array/Array#__get
(get_global $std/array/arr)
(i32.const 1)
)
(i32.const 42)
)
(unreachable)
)
)
)