mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-05-11 23:07:25 +00:00
Assert that comparator is not null in Array#sort (#155)
This commit is contained in:
parent
9e508de69a
commit
29081b6323
@ -302,6 +302,9 @@ export class Array<T> {
|
||||
}
|
||||
|
||||
sort(comparator: (a: T, b: T) => i32 = defaultComparator<T>()): this {
|
||||
// TODO remove this when flow will allow trackcing null
|
||||
assert(comparator); // The comparison function must be a function
|
||||
|
||||
var length = this.length_;
|
||||
if (length <= 1) return this;
|
||||
var buffer = this.buffer_;
|
||||
@ -316,7 +319,7 @@ export class Array<T> {
|
||||
}
|
||||
|
||||
if (isReference<T>()) {
|
||||
// TODO replace this to stable sort when it implemented
|
||||
// TODO replace this to faster stable sort (TimSort) when it implemented
|
||||
return changetype<this>(insertionSort<T>(this, comparator));
|
||||
} else {
|
||||
return changetype<this>(length < 256
|
||||
|
@ -4937,6 +4937,20 @@
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 306)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.le_s
|
||||
(tee_local $2
|
||||
@ -5254,6 +5268,20 @@
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 306)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.le_s
|
||||
(tee_local $2
|
||||
|
@ -6175,6 +6175,20 @@
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 306)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
@ -6899,6 +6913,20 @@
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 306)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
@ -7495,6 +7523,20 @@
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 306)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
@ -8150,6 +8192,20 @@
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 306)
|
||||
(i32.const 4)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user