Implement String#padStart/padEnd; Refactor internal string copy, compare and repeat (#171)

This commit is contained in:
Max Graey
2018-07-25 17:25:53 +03:00
committed by Daniel Wirtz
parent 298a8f1688
commit 671121bf70
15 changed files with 6385 additions and 3983 deletions

View File

@ -3,6 +3,7 @@
(type $iii (func (param i32 i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $iiiiii (func (param i32 i32 i32 i32 i32) (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
@ -130,47 +131,67 @@
)
)
)
(func $~lib/internal/string/compareUTF16 (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(set_local $3
(func $~lib/internal/string/compareUnsafe (; 6 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(set_local $5
(i32.const 0)
)
(set_local $6
(i32.add
(get_local $0)
(i32.shl
(get_local $1)
(i32.const 1)
)
)
)
(set_local $7
(i32.add
(get_local $2)
(i32.shl
(get_local $3)
(i32.const 1)
)
)
)
(block $break|0
(loop $continue|0
(if
(if (result i32)
(get_local $2)
(get_local $4)
(i32.eqz
(tee_local $3
(tee_local $5
(i32.sub
(i32.load16_u offset=4
(get_local $0)
(get_local $6)
)
(i32.load16_u offset=4
(get_local $1)
(get_local $7)
)
)
)
)
(get_local $2)
(get_local $4)
)
(block
(block
(set_local $2
(set_local $4
(i32.sub
(get_local $2)
(get_local $4)
(i32.const 1)
)
)
(set_local $0
(set_local $6
(i32.add
(get_local $0)
(get_local $6)
(i32.const 1)
)
)
(set_local $1
(set_local $7
(i32.add
(get_local $1)
(get_local $7)
(i32.const 1)
)
)
@ -180,7 +201,7 @@
)
)
)
(get_local $3)
(get_local $5)
)
(func $~lib/string/String#startsWith (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@ -201,7 +222,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 12)
(i32.const 291)
(i32.const 245)
(i32.const 4)
)
(unreachable)
@ -236,18 +257,18 @@
(get_local $3)
)
(tee_local $7
(get_local $4)
(get_local $5)
)
(i32.lt_s
(i32.gt_s
(get_local $6)
(get_local $7)
)
)
)
(tee_local $7
(get_local $5)
(get_local $4)
)
(i32.gt_s
(i32.lt_s
(get_local $6)
(get_local $7)
)
@ -272,15 +293,11 @@
)
)
(i32.eqz
(call $~lib/internal/string/compareUTF16
(i32.add
(get_local $0)
(i32.shl
(get_local $8)
(i32.const 1)
)
)
(call $~lib/internal/string/compareUnsafe
(get_local $0)
(get_local $8)
(get_local $1)
(i32.const 0)
(get_local $9)
)
)