mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 02:31:41 +00:00
Make the transition to ArrayBuffer backed Arrays (#70)
* Traverse base classes when resolving overloads * Implement preliminary TypedArray accessors * Extract decorator flags from common flags to make space * Add '**' overload * Implement basic explicit inlining * Support inlining of instance methods * Reduce number of required locals when inlining * Implement inlining of operator overloads * Fix issues when inlining generic functions
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
(module
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(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 $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s")
|
||||
(data (i32.const 40) "\04\00\00\00n\00u\00l\00l")
|
||||
(data (i32.const 4) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s")
|
||||
(data (i32.const 40) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s")
|
||||
(data (i32.const 72) "\04\00\00\00n\00u\00l\00l")
|
||||
(export "i32ArrayArrayElementAccess" (func $std/array-access/i32ArrayArrayElementAccess))
|
||||
(export "stringArrayPropertyAccess" (func $std/array-access/stringArrayPropertyAccess))
|
||||
(export "stringArrayMethodCall" (func $std/array-access/stringArrayMethodCall))
|
||||
@ -15,20 +16,34 @@
|
||||
(export "stringArrayArrayMethodCall" (func $std/array-access/stringArrayArrayMethodCall))
|
||||
(export "memory" (memory $0))
|
||||
(func $~lib/array/Array<Array<i32>>#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(tee_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 37)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
@ -124,7 +139,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 40)
|
||||
(i32.const 234)
|
||||
(i32.const 4)
|
||||
)
|
||||
@ -136,7 +151,7 @@
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 40)
|
||||
(i32.const 72)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -234,7 +249,7 @@
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 4)
|
||||
(i32.const 36)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
@ -261,7 +276,7 @@
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 4)
|
||||
(i32.const 36)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
|
@ -2,16 +2,21 @@
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $i (func (result i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(import "env" "abort" (func $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))
|
||||
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
|
||||
(global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 52))
|
||||
(global $HEAP_BASE i32 (i32.const 84))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\00\00\00\00")
|
||||
(data (i32.const 8) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00")
|
||||
(data (i32.const 40) "\04\00\00\00n\00u\00l\00l\00")
|
||||
(data (i32.const 4) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00")
|
||||
(data (i32.const 36) "\00\00\00\00")
|
||||
(data (i32.const 40) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00")
|
||||
(data (i32.const 72) "\04\00\00\00n\00u\00l\00l\00")
|
||||
(export "i32ArrayArrayElementAccess" (func $std/array-access/i32ArrayArrayElementAccess))
|
||||
(export "stringArrayPropertyAccess" (func $std/array-access/stringArrayPropertyAccess))
|
||||
(export "stringArrayMethodCall" (func $std/array-access/stringArrayMethodCall))
|
||||
@ -19,48 +24,110 @@
|
||||
(export "stringArrayArrayMethodCall" (func $std/array-access/stringArrayArrayMethodCall))
|
||||
(export "memory" (memory $0))
|
||||
(func $~lib/array/Array<Array<i32>>#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 37)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(return
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<Array<i32>>|inlined.0 (result i32)
|
||||
(set_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $1)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<Array<i32>>|inlined.0
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<i32>#__get (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 37)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(return
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.0 (result i32)
|
||||
(set_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $1)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<i32>|inlined.0
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -78,24 +145,55 @@
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<String>#__get (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 37)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(return
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<String>|inlined.0 (result i32)
|
||||
(set_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $1)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<String>|inlined.0
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -194,7 +292,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 40)
|
||||
(i32.const 234)
|
||||
(i32.const 4)
|
||||
)
|
||||
@ -207,7 +305,7 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.const 40)
|
||||
(i32.const 72)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
@ -319,31 +417,62 @@
|
||||
(get_local $0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 4)
|
||||
(i32.const 36)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/array/Array<Array<String>>#__get (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shr_u
|
||||
(i32.load
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 64)
|
||||
(i32.const 37)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(return
|
||||
(i32.load
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.mul
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
(block $~lib/internal/arraybuffer/loadUnsafe<Array<String>>|inlined.0 (result i32)
|
||||
(set_local $4
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $1)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafe<Array<String>>|inlined.0
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -376,7 +505,7 @@
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 4)
|
||||
(i32.const 36)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,128 +1,61 @@
|
||||
import "allocator/arena";
|
||||
import { Array } from "array";
|
||||
import { defaultComparator } from "internal/array";
|
||||
|
||||
// Default comparator
|
||||
function createDefaultComparator<T>(): (a: T, b: T) => i32 {
|
||||
return (a: T, b: T): i32 => (
|
||||
<i32>(a > b) - <i32>(a < b)
|
||||
);
|
||||
// Obtains the internal capacity of an array from its backing buffer.
|
||||
function internalCapacity<T>(array: Array<T>): i32 {
|
||||
// the memory region used by the backing buffer might still be larger in that the ArrayBuffer
|
||||
// pre-allocates a power of 2 sized buffer itself and reuses it as long as it isn't exceeded.
|
||||
var buffer: ArrayBuffer = array.buffer_;
|
||||
return buffer.byteLength >> alignof<T>();
|
||||
}
|
||||
|
||||
// Check is array sorted
|
||||
function isSorted<T>(data: Array<T>, comparator: (a: T, b: T) => i32 = createDefaultComparator<T>()): bool {
|
||||
for (let i: i32 = 1, len: i32 = data.length; i < len; i++) {
|
||||
if (comparator(data[i - 1], data[i]) > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var arr = new Array<i32>();
|
||||
|
||||
// Check is equality for arrays
|
||||
function isArraysEqual<T>(a: Array<T>, b: Array<T>, maxLen: i32 = 0): bool {
|
||||
var len = maxLen;
|
||||
if (!maxLen) {
|
||||
if (a.length != b.length) {
|
||||
return false;
|
||||
}
|
||||
len = <i32>a.length;
|
||||
}
|
||||
for (let i: i32 = 0; i < len; i++) {
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function createReverseOrderedArray(size: i32): Array<i32> {
|
||||
var arr = new Array<i32>(size);
|
||||
for (let i: i32 = 0; i < arr.length; i++) {
|
||||
arr[i] = <i32>arr.length - 1 - i;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
NativeMath.seedRandom(reinterpret<u64>(JSMath.random()));
|
||||
|
||||
function createRandomOrderedArray(size: i32): Array<i32> {
|
||||
var arr = new Array<i32>(size);
|
||||
for (let i: i32 = 0; i < arr.length; i++) {
|
||||
arr[i] = <i32>(NativeMath.random() * arr.length);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/*
|
||||
function createReverseOrderedNestedArray(size: i32): Array<Array<i32>> {
|
||||
var arr = new Array<Array<i32>>(size);
|
||||
for (let i: i32 = 0; i < arr.length; i++) {
|
||||
arr[i] = new Array<i32>(1);
|
||||
arr[i][0] = arr.length - 1 - i;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
class Proxy<T> {
|
||||
constructor(public x: T) {}
|
||||
}
|
||||
|
||||
function createReverseOrderedElementsArray(size: i32): Proxy<i32>[] {
|
||||
var arr = new Array<Proxy<i32>>(size);
|
||||
for (let i: i32 = 0; i < arr.length; i++) {
|
||||
arr[i] = new Proxy<i32>(arr.length - 1 - i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
*/
|
||||
|
||||
function assertSorted<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): void {
|
||||
assert(isSorted<T>(arr.sort<T>(comparator), comparator));
|
||||
}
|
||||
|
||||
function assertSortedDefault<T>(arr: Array<T>): void {
|
||||
assertSorted<T>(arr, createDefaultComparator<T>());
|
||||
}
|
||||
|
||||
var arr = changetype<i32[]>(allocate_memory(sizeof<usize>() + 2 * sizeof<i32>()));
|
||||
// Array#push/pop //////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
assert(arr.length == 0);
|
||||
assert(arr.__capacity == 0);
|
||||
assert(internalCapacity<i32>(arr) == 0);
|
||||
|
||||
arr.push(42);
|
||||
|
||||
assert(arr[0] == 42);
|
||||
assert(arr.length == 1);
|
||||
assert(arr.__capacity == 1);
|
||||
assert(internalCapacity<i32>(arr) == 1);
|
||||
|
||||
var i = arr.pop();
|
||||
|
||||
assert(i == 42);
|
||||
assert(arr.length == 0);
|
||||
assert(arr.__capacity == 1);
|
||||
assert(internalCapacity<i32>(arr) == 1);
|
||||
|
||||
arr.push(43);
|
||||
|
||||
assert(arr.length == 1);
|
||||
assert(arr.__capacity == 1);
|
||||
assert(internalCapacity<i32>(arr) == 1);
|
||||
assert(arr[0] == 43);
|
||||
|
||||
arr.push(44);
|
||||
|
||||
assert(arr.length == 2);
|
||||
assert(arr.__capacity == 2);
|
||||
assert(internalCapacity<i32>(arr) == 2);
|
||||
assert(arr[0] == 43);
|
||||
assert(arr[1] == 44);
|
||||
|
||||
arr.push(45);
|
||||
|
||||
assert(arr.length == 3);
|
||||
assert(arr.__capacity == 4);
|
||||
assert(internalCapacity<i32>(arr) == 3);
|
||||
assert(arr[0] == 43);
|
||||
assert(arr[1] == 44);
|
||||
assert(arr[2] == 45);
|
||||
|
||||
// Array#unshift ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
arr.unshift(42);
|
||||
|
||||
assert(arr.length == 4);
|
||||
assert(arr.__capacity == 4);
|
||||
assert(internalCapacity<i32>(arr) == 4);
|
||||
assert(arr[0] == 42);
|
||||
assert(arr[1] == 43);
|
||||
assert(arr[2] == 44);
|
||||
@ -131,18 +64,20 @@ assert(arr[3] == 45);
|
||||
arr.unshift(41);
|
||||
|
||||
assert(arr.length == 5);
|
||||
assert(arr.__capacity == 8);
|
||||
assert(internalCapacity<i32>(arr) == 5);
|
||||
assert(arr[0] == 41);
|
||||
assert(arr[1] == 42);
|
||||
assert(arr[2] == 43);
|
||||
assert(arr[3] == 44);
|
||||
assert(arr[4] == 45);
|
||||
|
||||
// Array#shift /////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
i = arr.shift();
|
||||
|
||||
assert(i == 41);
|
||||
assert(arr.length == 4);
|
||||
assert(arr.__capacity == 8);
|
||||
assert(internalCapacity<i32>(arr) == 5);
|
||||
assert(arr[0] == 42);
|
||||
assert(arr[1] == 43);
|
||||
assert(arr[2] == 44);
|
||||
@ -152,15 +87,17 @@ i = arr.pop();
|
||||
|
||||
assert(i == 45);
|
||||
assert(arr.length == 3);
|
||||
assert(arr.__capacity == 8);
|
||||
assert(internalCapacity<i32>(arr) == 5);
|
||||
assert(arr[0] == 42);
|
||||
assert(arr[1] == 43);
|
||||
assert(arr[2] == 44);
|
||||
|
||||
// Array#reverse ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
arr.reverse();
|
||||
|
||||
assert(arr.length == 3);
|
||||
assert(arr.__capacity == 8);
|
||||
assert(internalCapacity<i32>(arr) == 5);
|
||||
assert(arr[0] == 44);
|
||||
assert(arr[1] == 43);
|
||||
assert(arr[2] == 42);
|
||||
@ -168,6 +105,8 @@ assert(arr[2] == 42);
|
||||
arr.push(43);
|
||||
arr.push(44);
|
||||
|
||||
// Array#indexOf ///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
i = arr.indexOf(44);
|
||||
|
||||
assert(i == 0);
|
||||
@ -208,6 +147,8 @@ i = arr.indexOf(43, 2);
|
||||
|
||||
assert(i == 3);
|
||||
|
||||
// Array#includes //////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var includes = arr.includes(44);
|
||||
|
||||
assert(includes == true);
|
||||
@ -251,16 +192,17 @@ assert(includes == true);
|
||||
arr.splice(1, 1);
|
||||
|
||||
assert(arr.length == 4);
|
||||
assert(arr.__capacity == 8);
|
||||
assert(internalCapacity<i32>(arr) == 5);
|
||||
assert(arr[0] == 44);
|
||||
assert(arr[1] == 42);
|
||||
|
||||
// Array#findIndex /////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
arr[0] = 0;
|
||||
arr[1] = 1;
|
||||
arr[2] = 2;
|
||||
arr[3] = 3;
|
||||
/*=============================== findIndex ==========================*/
|
||||
|
||||
i = arr.findIndex((value: i32, index: i32, array: Array<i32>): bool => value == 0);
|
||||
assert(i == 0);
|
||||
|
||||
@ -272,7 +214,7 @@ assert(i == -1);
|
||||
|
||||
// Test side effect push
|
||||
i = arr.findIndex((value: i32, index: i32, array: Array<i32>): bool => {
|
||||
array.push(100); //push side effect should not affect this method by spec
|
||||
array.push(100); // push side effect should not affect this method by spec
|
||||
return value == 100;
|
||||
});
|
||||
// array should be changed, but this method result should be calculated for old array length
|
||||
@ -288,7 +230,7 @@ arr.pop();
|
||||
|
||||
// Test side effect pop
|
||||
i = arr.findIndex((value: i32, index: i32, array: Array<i32>): bool => {
|
||||
array.pop(); //poped items shouldn't be looked up, and we shouldn't go out of bounds
|
||||
array.pop(); // poped items shouldn't be looked up, and we shouldn't go out of bounds
|
||||
return value == 100;
|
||||
});
|
||||
// only 2 first items was looked up, since last 2 was removed by .pop()
|
||||
@ -297,7 +239,9 @@ assert(arr.length == 2);
|
||||
|
||||
arr.push(2);
|
||||
arr.push(3);
|
||||
/*=============================== every ==========================*/
|
||||
|
||||
// Array#every /////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var every = arr.every((value: i32, index: i32, array: Array<i32>): bool => value >= 0);
|
||||
assert(every == true);
|
||||
|
||||
@ -306,7 +250,7 @@ assert(every == false);
|
||||
|
||||
// Test side effect push
|
||||
every = arr.every((value: i32, index: i32, array: Array<i32>): bool => {
|
||||
array.push(100); //push side effect should not affect this method by spec
|
||||
array.push(100); // push side effect should not affect this method by spec
|
||||
return value < 10;
|
||||
});
|
||||
// array should be changed, but this method result should be calculated for old array length
|
||||
@ -331,7 +275,9 @@ assert(arr.length == 2);
|
||||
|
||||
arr.push(2);
|
||||
arr.push(3);
|
||||
/*=============================== some ==========================*/
|
||||
|
||||
// Array#some //////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var some = arr.some((value: i32, index: i32, array: Array<i32>): bool => value >= 3);
|
||||
assert(some == true);
|
||||
|
||||
@ -340,7 +286,7 @@ assert(some == false);
|
||||
|
||||
// Test side effect push
|
||||
some = arr.some((value: i32, index: i32, array: Array<i32>): bool => {
|
||||
array.push(100); //push side effect should not affect this method by spec
|
||||
array.push(100); // push side effect should not affect this method by spec
|
||||
return value > 10;
|
||||
});
|
||||
// array should be changed, but this method result should be calculated for old array length
|
||||
@ -356,7 +302,7 @@ arr.pop();
|
||||
|
||||
// Test side effect pop
|
||||
some = arr.some((value: i32, index: i32, array: Array<i32>): bool => {
|
||||
array.pop(); //poped items shouldn't be looked up, and we shouldn't go out of bounds
|
||||
array.pop(); // poped items shouldn't be looked up, and we shouldn't go out of bounds
|
||||
return value > 3;
|
||||
});
|
||||
// only 2 first items was looked up, since last 2 was removed by .pop()
|
||||
@ -365,7 +311,8 @@ assert(arr.length == 2);
|
||||
|
||||
arr.push(2);
|
||||
arr.push(3);
|
||||
/*=============================== reduce ==========================*/
|
||||
|
||||
// Array#reduce ////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
i = arr.reduce<i32>(((prev: i32, current: i32, index: i32, array: Array<i32>): i32 => prev + current), 0);
|
||||
assert(i == 6);
|
||||
@ -382,7 +329,7 @@ assert(boolVal == false);
|
||||
|
||||
// Test side effect push
|
||||
i = arr.reduce<i32>(((prev: i32, current: i32, index: i32, array: Array<i32>): i32 => {
|
||||
array.push(1); //push side effect should not affect this method by spec
|
||||
array.push(1); // push side effect should not affect this method by spec
|
||||
return prev + current;
|
||||
}), 0);
|
||||
// array should be changed, but this method result should be calculated for old array length
|
||||
@ -405,46 +352,115 @@ i = arr.reduce<i32>(((prev: i32, current: i32, index: i32, array: Array<i32>): i
|
||||
assert(i == 1);
|
||||
assert(arr.length == 2);
|
||||
|
||||
/*=============================== sort ==========================*/
|
||||
// Array#sort //////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var revesed0: Array<i32> = [];
|
||||
var revesed1: Array<i32> = [1];
|
||||
var revesed2: Array<i32> = [2, 1];
|
||||
var revesed4: Array<i32> = [3, 2, 1, 0];
|
||||
// Checks if an array is properly sorted
|
||||
function isSorted<T>(data: Array<T>, comparator: (a: T, b: T) => i32 = defaultComparator<T>()): bool {
|
||||
for (let i: i32 = 1, len: i32 = data.length; i < len; i++) {
|
||||
if (comparator(data[i - 1], data[i]) > 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Checks if two arrays are equal
|
||||
function isArraysEqual<T>(a: Array<T>, b: Array<T>, len: i32 = 0): bool {
|
||||
if (!len) {
|
||||
if (a.length != b.length) return false;
|
||||
len = a.length;
|
||||
}
|
||||
for (let i = 0; i < len; i++) {
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function createReverseOrderedArray(size: i32): Array<i32> {
|
||||
var arr = new Array<i32>(size);
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
arr[i] = arr.length - 1 - i;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
NativeMath.seedRandom(reinterpret<u64>(JSMath.random()));
|
||||
|
||||
function createRandomOrderedArray(size: i32): Array<i32> {
|
||||
var arr = new Array<i32>(size);
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
arr[i] = <i32>(NativeMath.random() * arr.length);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/*
|
||||
function createReverseOrderedNestedArray(size: i32): Array<Array<i32>> {
|
||||
var arr = new Array<Array<i32>>(size);
|
||||
for (let i: i32 = 0; i < arr.length; i++) {
|
||||
arr[i] = new Array<i32>(1);
|
||||
arr[i][0] = arr.length - 1 - i;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
class Proxy<T> {
|
||||
constructor(public x: T) {}
|
||||
}
|
||||
|
||||
function createReverseOrderedElementsArray(size: i32): Proxy<i32>[] {
|
||||
var arr = new Array<Proxy<i32>>(size);
|
||||
for (let i: i32 = 0; i < arr.length; i++) {
|
||||
arr[i] = new Proxy<i32>(arr.length - 1 - i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
*/
|
||||
|
||||
function assertSorted<T>(arr: Array<T>, comparator: (a: T, b: T) => i32): void {
|
||||
assert(isSorted<T>(arr.sort(comparator), comparator));
|
||||
}
|
||||
|
||||
function assertSortedDefault<T>(arr: Array<T>): void {
|
||||
assertSorted<T>(arr, defaultComparator<T>());
|
||||
}
|
||||
|
||||
var reversed0: Array<i32> = [];
|
||||
var reversed1: Array<i32> = [1];
|
||||
var reversed2: Array<i32> = [2, 1];
|
||||
var reversed4: Array<i32> = [3, 2, 1, 0];
|
||||
|
||||
var expected4: Array<i32> = [0, 1, 2, 3];
|
||||
|
||||
var revesed64 = createReverseOrderedArray(64);
|
||||
var revesed128 = createReverseOrderedArray(128);
|
||||
var revesed1024 = createReverseOrderedArray(1024);
|
||||
var revesed10000 = createReverseOrderedArray(10000);
|
||||
var reversed64 = createReverseOrderedArray(64);
|
||||
var reversed128 = createReverseOrderedArray(128);
|
||||
var reversed1024 = createReverseOrderedArray(1024);
|
||||
var reversed10000 = createReverseOrderedArray(10000);
|
||||
|
||||
var randomized512 = createRandomOrderedArray(512);
|
||||
|
||||
// Test sorting with with default comparator
|
||||
|
||||
assertSortedDefault<i32>(revesed0);
|
||||
assertSortedDefault<i32>(reversed0);
|
||||
|
||||
assertSortedDefault<i32>(revesed1);
|
||||
assert(isArraysEqual<i32>(revesed1, <i32[]>[1]));
|
||||
assertSortedDefault<i32>(reversed1);
|
||||
assert(isArraysEqual<i32>(reversed1, <i32[]>[1]));
|
||||
|
||||
assertSortedDefault<i32>(revesed2);
|
||||
assert(isArraysEqual<i32>(revesed2, <i32[]>[1, 2]));
|
||||
assertSortedDefault<i32>(reversed2);
|
||||
assert(isArraysEqual<i32>(reversed2, <i32[]>[1, 2]));
|
||||
|
||||
assertSortedDefault<i32>(revesed4);
|
||||
assert(isArraysEqual<i32>(revesed4, expected4));
|
||||
assertSortedDefault<i32>(reversed4);
|
||||
assert(isArraysEqual<i32>(reversed4, expected4));
|
||||
|
||||
assertSortedDefault<i32>(revesed64);
|
||||
assert(isArraysEqual<i32>(revesed64, expected4, 4));
|
||||
assertSortedDefault<i32>(reversed64);
|
||||
assert(isArraysEqual<i32>(reversed64, expected4, 4));
|
||||
|
||||
assertSortedDefault<i32>(revesed128);
|
||||
assert(isArraysEqual<i32>(revesed128, expected4, 4));
|
||||
assertSortedDefault<i32>(reversed128);
|
||||
assert(isArraysEqual<i32>(reversed128, expected4, 4));
|
||||
|
||||
assertSortedDefault<i32>(revesed1024);
|
||||
assert(isArraysEqual<i32>(revesed1024, expected4, 4));
|
||||
assertSortedDefault<i32>(reversed1024);
|
||||
assert(isArraysEqual<i32>(reversed1024, expected4, 4));
|
||||
|
||||
assertSortedDefault<i32>(revesed10000);
|
||||
assert(isArraysEqual<i32>(revesed10000, expected4, 4));
|
||||
assertSortedDefault<i32>(reversed10000);
|
||||
assert(isArraysEqual<i32>(reversed10000, expected4, 4));
|
||||
|
||||
assertSortedDefault<i32>(randomized512);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
(module
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
@ -11,10 +11,11 @@
|
||||
(global $std/arraybuffer/buffer (mut i32) (i32.const 0))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $std/arraybuffer/sliced (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 104))
|
||||
(global $HEAP_BASE i32 (i32.const 148))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(data (i32.const 64) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(data (i32.const 4) "\13\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(data (i32.const 48) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(data (i32.const 108) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
@ -130,7 +131,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 48)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -489,7 +490,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 13)
|
||||
(i32.const 40)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
@ -2537,7 +2546,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 5)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2566,7 +2575,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 9)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2581,7 +2590,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 10)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2610,7 +2619,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 14)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2639,7 +2648,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 18)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2663,7 +2672,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 22)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2687,7 +2696,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 26)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2711,7 +2720,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 30)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2735,7 +2744,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 34)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2761,7 +2770,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 38)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2775,7 +2784,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 39)
|
||||
(i32.const 0)
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
@ -18,10 +18,11 @@
|
||||
(global $std/arraybuffer/buffer (mut i32) (i32.const 0))
|
||||
(global $argumentCount (mut i32) (i32.const 0))
|
||||
(global $std/arraybuffer/sliced (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 104))
|
||||
(global $HEAP_BASE i32 (i32.const 148))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(data (i32.const 64) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(data (i32.const 4) "\13\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(data (i32.const 48) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(data (i32.const 108) "\12\00\00\00s\00t\00d\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
@ -165,7 +166,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 48)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -543,7 +544,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 13)
|
||||
(i32.const 40)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(call $~lib/internal/arraybuffer/allocUnsafe
|
||||
@ -2872,7 +2881,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 5)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2903,7 +2912,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 9)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2920,7 +2929,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 10)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2951,7 +2960,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 14)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -2982,7 +2991,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 18)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3008,7 +3017,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 22)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3034,7 +3043,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 26)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3060,7 +3069,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 30)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3086,7 +3095,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 34)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3117,7 +3126,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 38)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -3134,7 +3143,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 64)
|
||||
(i32.const 108)
|
||||
(i32.const 39)
|
||||
(i32.const 0)
|
||||
)
|
||||
|
@ -12161,7 +12161,15 @@
|
||||
(i32.eqz
|
||||
(get_global $~lib/math/random_seeded)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 32)
|
||||
(i32.const 1000)
|
||||
(i32.const 24)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(get_global $~lib/math/random_state0)
|
||||
|
@ -14381,7 +14381,15 @@
|
||||
(i32.eqz
|
||||
(get_global $~lib/math/random_seeded)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 32)
|
||||
(i32.const 1000)
|
||||
(i32.const 24)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(get_global $~lib/math/random_state0)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,11 @@ class Tester {
|
||||
return new Tester(a.x % b.x, a.y % b.y);
|
||||
}
|
||||
|
||||
@operator('**')
|
||||
static pow(a: Tester, b: Tester): Tester {
|
||||
return new Tester(<i32>(a.x ** b.x), <i32>(a.y ** b.y));
|
||||
}
|
||||
|
||||
@operator('|')
|
||||
static or(a: Tester, b: Tester): Tester {
|
||||
return new Tester(a.x | b.x, a.y | b.y);
|
||||
@ -99,12 +104,18 @@ var d2 = new Tester(3, 10);
|
||||
var d = d1 / d2;
|
||||
assert(d.x == 2 && d.y == 5);
|
||||
|
||||
// check fractional
|
||||
// check remainder
|
||||
var f1 = new Tester(10, 10);
|
||||
var f2 = new Tester(6, 10);
|
||||
var f = f1 % f2;
|
||||
assert(f.x == 4 && f.y == 0);
|
||||
|
||||
// check power
|
||||
var p1 = new Tester(2, 3);
|
||||
var p2 = new Tester(4, 5);
|
||||
var p = p1 ** p2;
|
||||
assert(p.x == 16 && p.y == 243);
|
||||
|
||||
// check bitwise and
|
||||
var n1 = new Tester(0xFF, 0x0F);
|
||||
var n2 = new Tester(0x0F, 0xFF);
|
||||
@ -166,3 +177,31 @@ var leq1 = new Tester(4, 3);
|
||||
var leq2 = new Tester(4, 3);
|
||||
var leq = leq1 <= leq2;
|
||||
assert(leq == true);
|
||||
|
||||
// check inlined static
|
||||
class TesterInlineStatic {
|
||||
constructor(public x: i32, public y: i32) {
|
||||
}
|
||||
@inline @operator('+')
|
||||
static add(a: TesterInlineStatic, b: TesterInlineStatic): TesterInlineStatic {
|
||||
return new TesterInlineStatic(a.x + b.x, a.y + b.y);
|
||||
}
|
||||
}
|
||||
var ais1 = new TesterInlineStatic(1, 2);
|
||||
var ais2 = new TesterInlineStatic(2, 3);
|
||||
var ais = ais1 + ais2;
|
||||
assert(ais.x == 3 && ais.y == 5);
|
||||
|
||||
// check inlined instance
|
||||
class TesterInlineInstance {
|
||||
constructor(public x: i32, public y: i32) {
|
||||
}
|
||||
@inline @operator('+')
|
||||
add(b: TesterInlineInstance): TesterInlineInstance {
|
||||
return new TesterInlineInstance(this.x + b.x, this.y + b.y);
|
||||
}
|
||||
}
|
||||
var aii1 = new TesterInlineInstance(1, 2);
|
||||
var aii2 = new TesterInlineInstance(2, 3);
|
||||
var aii = aii1 + aii2;
|
||||
assert(aii.x == 3 && aii.y == 5);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -3725,7 +3725,15 @@
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 391)
|
||||
(i32.const 6)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
|
@ -4290,7 +4290,15 @@
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 72)
|
||||
(i32.const 391)
|
||||
(i32.const 6)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.and
|
||||
|
@ -4,14 +4,17 @@
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 104))
|
||||
(global $std/typedarray/arr (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 164))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\11\00\00\00s\00t\00d\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s")
|
||||
(data (i32.const 44) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(data (i32.const 44) "\1b\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s")
|
||||
(data (i32.const 104) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
@ -127,7 +130,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 104)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -486,7 +489,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
@ -537,8 +548,13 @@
|
||||
(get_local $0)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i8>#get:length (; 6 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i16>#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
@ -548,7 +564,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 536870908)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
@ -605,8 +629,13 @@
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i16>#get:length (; 8 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -618,7 +647,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 268435454)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
@ -675,8 +712,13 @@
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#get:length (; 10 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -688,7 +730,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 134217727)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(call $~lib/memory/set_memory
|
||||
(i32.add
|
||||
@ -745,8 +795,13 @@
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i64>#get:length (; 12 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -1308,7 +1363,217 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 14 ;) (type $v)
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#__set (; 14 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.shr_u
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(tee_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 47)
|
||||
(i32.const 42)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#__get (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(i32.shr_u
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(tee_local $2
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 39)
|
||||
(i32.const 42)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/typedarray/Int32Array#subarray (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(set_local $3
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $4
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(tee_local $5
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(if (result i32)
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(tee_local $0
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(select
|
||||
(tee_local $2
|
||||
(get_local $1)
|
||||
)
|
||||
(tee_local $0
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(if (result i32)
|
||||
(i32.lt_s
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
)
|
||||
(select
|
||||
(tee_local $2
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(tee_local $0
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(select
|
||||
(tee_local $2
|
||||
(select
|
||||
(tee_local $2
|
||||
(get_local $3)
|
||||
)
|
||||
(tee_local $0
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(tee_local $0
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $2)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(tee_local $2
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.load
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(func $start (; 17 ;) (type $v)
|
||||
(set_global $~lib/allocator/arena/startOffset
|
||||
(i32.and
|
||||
(i32.add
|
||||
@ -1327,6 +1592,205 @@
|
||||
(call $std/typedarray/testInstantiate
|
||||
(i32.const 5)
|
||||
)
|
||||
(set_global $std/typedarray/arr
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__set
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__set
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__set
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 74)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.load offset=4
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 75)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 12)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 76)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 77)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 78)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 79)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/typedarray/arr
|
||||
(call $~lib/typedarray/Int32Array#subarray
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 82)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=4
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 4)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 83)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(i32.load offset=8
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 8)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 84)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 85)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $~lib/internal/typedarray/TypedArray<i64>#constructor
|
||||
(i32.const 0)
|
||||
|
@ -67,6 +67,23 @@ function testInstantiate(len: i32): void {
|
||||
testInstantiate(0);
|
||||
testInstantiate(5);
|
||||
|
||||
var arr = new Int32Array(3);
|
||||
arr[0] = 1;
|
||||
arr[1] = 2;
|
||||
arr[2] = 3;
|
||||
assert(arr.length == 3);
|
||||
assert(arr.byteOffset == 0);
|
||||
assert(arr.byteLength == 3 * sizeof<i32>());
|
||||
assert(arr[0] == 1);
|
||||
assert(arr[1] == 2);
|
||||
assert(arr[2] == 3);
|
||||
|
||||
arr = arr.subarray(1, 2);
|
||||
assert(arr.length == 1);
|
||||
assert(arr.byteOffset == 1 * sizeof<i32>());
|
||||
assert(arr.byteLength == 2 * sizeof<i32>());
|
||||
assert(arr[0] == 2);
|
||||
|
||||
import { MAX_BLENGTH } from "internal/arraybuffer";
|
||||
|
||||
const MAX_F64LENGTH = <u32>MAX_BLENGTH >> alignof<f64>();
|
||||
|
@ -5,6 +5,7 @@
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $ii (func (param i32) (result i32)))
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $v (func))
|
||||
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
|
||||
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
|
||||
@ -15,11 +16,13 @@
|
||||
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
|
||||
(global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8))
|
||||
(global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816))
|
||||
(global $std/typedarray/arr (mut i32) (i32.const 0))
|
||||
(global $std/typedarray/MAX_F64LENGTH i32 (i32.const 134217727))
|
||||
(global $HEAP_BASE i32 (i32.const 104))
|
||||
(global $HEAP_BASE i32 (i32.const 164))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\11\00\00\00s\00t\00d\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s\00")
|
||||
(data (i32.const 44) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(data (i32.const 44) "\1b\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s\00")
|
||||
(data (i32.const 104) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32)
|
||||
@ -163,7 +166,7 @@
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 104)
|
||||
(i32.const 22)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -545,7 +548,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -611,8 +622,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<i8>#get:length (; 6 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -629,7 +645,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 1073741816)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -695,8 +719,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<u8>#get:length (; 8 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -713,7 +742,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 536870908)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -779,8 +816,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<i16>#get:length (; 10 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -797,7 +839,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 536870908)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -863,8 +913,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<u16>#get:length (; 12 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -881,7 +936,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 268435454)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -947,8 +1010,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#get:length (; 14 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -965,7 +1033,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 268435454)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -1031,8 +1107,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<u32>#get:length (; 16 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -1049,7 +1130,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 134217727)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -1115,8 +1204,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<i64>#get:length (; 18 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -1133,7 +1227,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 134217727)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -1199,8 +1301,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<u64>#get:length (; 20 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -1217,7 +1324,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 268435454)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -1283,8 +1398,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<f32>#get:length (; 22 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -1301,7 +1421,15 @@
|
||||
(get_local $1)
|
||||
(i32.const 134217727)
|
||||
)
|
||||
(unreachable)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 22)
|
||||
(i32.const 34)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.shl
|
||||
@ -1367,8 +1495,13 @@
|
||||
(func $~lib/internal/typedarray/TypedArray<f64>#get:length (; 24 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(return
|
||||
(i32.shr_s
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
@ -2046,7 +2179,281 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 26 ;) (type $v)
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#__set (; 26 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(set_local $3
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.shr_u
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(get_local $4)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 47)
|
||||
(i32.const 42)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(block $~lib/internal/arraybuffer/storeUnsafeWithOffset<i32>|inlined.0
|
||||
(set_local $5
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $6
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $7
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $8
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $8)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $6)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/internal/typedarray/TypedArray<i32>#__get (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(set_local $2
|
||||
(i32.load offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.shr_u
|
||||
(i32.sub
|
||||
(i32.load offset=8
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(get_local $1)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 44)
|
||||
(i32.const 39)
|
||||
(i32.const 42)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(block $~lib/internal/arraybuffer/loadUnsafeWithOffset<i32>|inlined.0 (result i32)
|
||||
(set_local $4
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $6
|
||||
(get_local $2)
|
||||
)
|
||||
(br $~lib/internal/arraybuffer/loadUnsafeWithOffset<i32>|inlined.0
|
||||
(i32.load offset=8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/typedarray/Int32Array#subarray (; 28 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(return
|
||||
(block $~lib/internal/typedarray/TypedArray<i32>#subarray|inlined.0 (result i32)
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $4
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $5
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $6
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $4)
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $4
|
||||
(select
|
||||
(tee_local $7
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(tee_local $8
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $7)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(select
|
||||
(tee_local $7
|
||||
(get_local $4)
|
||||
)
|
||||
(tee_local $8
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $7)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $5)
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $5
|
||||
(select
|
||||
(tee_local $7
|
||||
(i32.add
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(tee_local $8
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $7)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(select
|
||||
(tee_local $7
|
||||
(select
|
||||
(tee_local $7
|
||||
(get_local $5)
|
||||
)
|
||||
(tee_local $8
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $7)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(tee_local $8
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $7)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(i32.const 12)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $7)
|
||||
(i32.load
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store offset=4
|
||||
(get_local $7)
|
||||
(i32.shl
|
||||
(get_local $4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.store offset=8
|
||||
(get_local $7)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $~lib/internal/typedarray/TypedArray<i32>#subarray|inlined.0
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 29 ;) (type $v)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
@ -2238,6 +2645,237 @@
|
||||
(call $std/typedarray/testInstantiate
|
||||
(i32.const 5)
|
||||
)
|
||||
(set_global $std/typedarray/arr
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#constructor
|
||||
(i32.const 0)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__set
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 0)
|
||||
(i32.const 1)
|
||||
)
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__set
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__set
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 2)
|
||||
(i32.const 3)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 74)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 75)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load offset=8
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.const 3)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 76)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 77)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 78)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 79)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(set_global $std/typedarray/arr
|
||||
(call $~lib/typedarray/Int32Array#subarray
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#get:length
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 82)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load offset=4
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.const 1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 83)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(i32.load offset=8
|
||||
(get_global $std/typedarray/arr)
|
||||
)
|
||||
(i32.mul
|
||||
(i32.const 2)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 84)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $~lib/internal/typedarray/TypedArray<i32>#__get
|
||||
(get_global $std/typedarray/arr)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(call $abort
|
||||
(i32.const 0)
|
||||
(i32.const 4)
|
||||
(i32.const 85)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(call $~lib/internal/typedarray/TypedArray<f64>#constructor
|
||||
(i32.const 0)
|
||||
|
Reference in New Issue
Block a user