Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions std/assembly/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BLOCK_MAXSIZE } from "./rt/common";
import { COMPARATOR, SORT } from "./util/sort";
import { joinBooleanArray, joinIntegerArray, joinFloatArray, joinStringArray, joinReferenceArray } from "./util/string";
import { idof, isArray as builtin_isArray } from "./builtins";
import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";
import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_ILLEGALGENTYPE, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";

/** Ensures that the given array has _at least_ the specified backing size. */
function ensureSize(array: usize, minSize: usize, alignLog2: u32): void {
Expand Down Expand Up @@ -501,7 +501,7 @@ export class Array<T> {

flat(): T {
if (!isArray<T>()) {
throw new TypeError("Cannot call flat() on Array<T> where T is not an Array.");
throw new TypeError(E_ILLEGALGENTYPE);
}
// Get the length and data start values
var length = this.length_;
Expand Down
4 changes: 4 additions & 0 deletions std/assembly/util/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const E_INDEXOUTOFRANGE: string = "Index out of range";
@lazy @inline
export const E_INVALIDLENGTH: string = "Invalid length";

// @ts-ignore: decorator
@lazy @inline
export const E_ILLEGALGENTYPE: string = "Illegal generic type";

// @ts-ignore: decorator
@lazy @inline
export const E_EMPTYARRAY: string = "Array is empty";
Expand Down
24 changes: 12 additions & 12 deletions tests/compiler/std/array.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
(data (i32.const 9952) " \00\00\00\01\00\00\00\00\00\00\00 \00\00\00\90%\00\00\d0%\00\00\00\00\00\00\f0%\00\000&\00\00P&\00\00p&\00\00\b0&")
(data (i32.const 10004) "\01")
(data (i32.const 10020) "\01")
(data (i32.const 10032) "n\00\00\00\01\00\00\00\01\00\00\00n\00\00\00C\00a\00n\00n\00o\00t\00 \00c\00a\00l\00l\00 \00f\00l\00a\00t\00(\00)\00 \00o\00n\00 \00A\00r\00r\00a\00y\00<\00T\00>\00 \00w\00h\00e\00r\00e\00 \00T\00 \00i\00s\00 \00n\00o\00t\00 \00a\00n\00 \00A\00r\00r\00a\00y\00.")
(data (i32.const 10032) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00I\00l\00l\00e\00g\00a\00l\00 \00g\00e\00n\00e\00r\00i\00c\00 \00t\00y\00p\00e")
(table $0 57 funcref)
(elem (i32.const 1) $start:std/array~anonymous|0 $start:std/array~anonymous|1 $start:std/array~anonymous|2 $start:std/array~anonymous|3 $start:std/array~anonymous|2 $start:std/array~anonymous|5 $start:std/array~anonymous|6 $start:std/array~anonymous|7 $start:std/array~anonymous|8 $start:std/array~anonymous|9 $start:std/array~anonymous|10 $start:std/array~anonymous|11 $start:std/array~anonymous|12 $start:std/array~anonymous|13 $start:std/array~anonymous|14 $start:std/array~anonymous|15 $start:std/array~anonymous|16 $start:std/array~anonymous|17 $start:std/array~anonymous|16 $start:std/array~anonymous|19 $start:std/array~anonymous|20 $start:std/array~anonymous|21 $start:std/array~anonymous|22 $start:std/array~anonymous|23 $start:std/array~anonymous|24 $start:std/array~anonymous|25 $start:std/array~anonymous|26 $start:std/array~anonymous|27 $start:std/array~anonymous|28 $start:std/array~anonymous|29 $start:std/array~anonymous|29 $start:std/array~anonymous|31 $start:std/array~anonymous|32 $start:std/array~anonymous|33 $start:std/array~anonymous|29 $start:std/array~anonymous|35 $start:std/array~anonymous|29 $start:std/array~anonymous|29 $start:std/array~anonymous|31 $start:std/array~anonymous|32 $start:std/array~anonymous|33 $start:std/array~anonymous|29 $start:std/array~anonymous|35 $~lib/util/sort/COMPARATOR<f32>~anonymous|0 $~lib/util/sort/COMPARATOR<f64>~anonymous|0 $~lib/util/sort/COMPARATOR<i32>~anonymous|0 $~lib/util/sort/COMPARATOR<u32>~anonymous|0 $~lib/util/sort/COMPARATOR<i32>~anonymous|0 $~lib/util/sort/COMPARATOR<i32>~anonymous|0 $start:std/array~anonymous|44 $~lib/util/sort/COMPARATOR<i32>~anonymous|0 $start:std/array~anonymous|44 $start:std/array~anonymous|47 $start:std/array~anonymous|48 $~lib/util/sort/COMPARATOR<~lib/string/String | null>~anonymous|0 $~lib/util/sort/COMPARATOR<~lib/string/String | null>~anonymous|0)
(global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0))
Expand Down Expand Up @@ -340,7 +340,7 @@
(export "__setArgumentsLength" (func $~setArgumentsLength))
(func $~lib/rt/pure/__release (param $0 i32)
local.get $0
i32.const 10160
i32.const 10088
i32.gt_u
if
local.get $0
Expand Down Expand Up @@ -929,11 +929,11 @@
if
unreachable
end
i32.const 10160
i32.const 10096
local.tee $0
i32.const 0
i32.store
i32.const 11728
i32.const 11664
i32.const 0
i32.store
loop $for-loop|0
Expand All @@ -944,7 +944,7 @@
local.get $1
i32.const 2
i32.shl
i32.const 10160
i32.const 10096
i32.add
i32.const 0
i32.store offset=4
Expand All @@ -962,7 +962,7 @@
i32.add
i32.const 2
i32.shl
i32.const 10160
i32.const 10096
i32.add
i32.const 0
i32.store offset=96
Expand All @@ -980,13 +980,13 @@
br $for-loop|0
end
end
i32.const 10160
i32.const 11744
i32.const 10096
i32.const 11680
memory.size
i32.const 16
i32.shl
call $~lib/rt/tlsf/addMemory
i32.const 10160
i32.const 10096
global.set $~lib/rt/tlsf/ROOT
end
local.get $0
Expand Down Expand Up @@ -1544,7 +1544,7 @@
(local $1 i32)
(local $2 i32)
local.get $0
i32.const 10160
i32.const 10088
i32.gt_u
if
local.get $0
Expand Down Expand Up @@ -2361,7 +2361,7 @@
local.get $2
call $~lib/memory/memory.copy
local.get $1
i32.const 10160
i32.const 10088
i32.ge_u
if
local.get $1
Expand Down Expand Up @@ -19709,7 +19709,7 @@
)
(func $~lib/rt/pure/__visit (param $0 i32)
local.get $0
i32.const 10160
i32.const 10088
i32.lt_u
if
return
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/std/array.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
(data (i32.const 10384) " \00\00\00\01\00\00\00\00\00\00\00 \00\00\00@\'\00\00\80\'\00\00\00\00\00\00\a0\'\00\00\e0\'\00\00\00(\00\00 (\00\00`(\00\00")
(data (i32.const 10432) "\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00")
(data (i32.const 10448) "\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00")
(data (i32.const 10464) "n\00\00\00\01\00\00\00\01\00\00\00n\00\00\00C\00a\00n\00n\00o\00t\00 \00c\00a\00l\00l\00 \00f\00l\00a\00t\00(\00)\00 \00o\00n\00 \00A\00r\00r\00a\00y\00<\00T\00>\00 \00w\00h\00e\00r\00e\00 \00T\00 \00i\00s\00 \00n\00o\00t\00 \00a\00n\00 \00A\00r\00r\00a\00y\00.\00")
(data (i32.const 10464) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00I\00l\00l\00e\00g\00a\00l\00 \00g\00e\00n\00e\00r\00i\00c\00 \00t\00y\00p\00e\00")
(table $0 57 funcref)
(elem (i32.const 1) $start:std/array~anonymous|0 $start:std/array~anonymous|1 $start:std/array~anonymous|2 $start:std/array~anonymous|3 $start:std/array~anonymous|4 $start:std/array~anonymous|5 $start:std/array~anonymous|6 $start:std/array~anonymous|7 $start:std/array~anonymous|8 $start:std/array~anonymous|9 $start:std/array~anonymous|10 $start:std/array~anonymous|11 $start:std/array~anonymous|12 $start:std/array~anonymous|13 $start:std/array~anonymous|14 $start:std/array~anonymous|15 $start:std/array~anonymous|16 $start:std/array~anonymous|17 $start:std/array~anonymous|18 $start:std/array~anonymous|19 $start:std/array~anonymous|20 $start:std/array~anonymous|21 $start:std/array~anonymous|22 $start:std/array~anonymous|23 $start:std/array~anonymous|24 $start:std/array~anonymous|25 $start:std/array~anonymous|26 $start:std/array~anonymous|27 $start:std/array~anonymous|28 $start:std/array~anonymous|29 $start:std/array~anonymous|30 $start:std/array~anonymous|31 $start:std/array~anonymous|32 $start:std/array~anonymous|33 $start:std/array~anonymous|34 $start:std/array~anonymous|35 $start:std/array~anonymous|36 $start:std/array~anonymous|37 $start:std/array~anonymous|38 $start:std/array~anonymous|39 $start:std/array~anonymous|40 $start:std/array~anonymous|41 $start:std/array~anonymous|42 $~lib/util/sort/COMPARATOR<f32>~anonymous|0 $~lib/util/sort/COMPARATOR<f64>~anonymous|0 $~lib/util/sort/COMPARATOR<i32>~anonymous|0 $~lib/util/sort/COMPARATOR<u32>~anonymous|0 $~lib/util/sort/COMPARATOR<i32>~anonymous|1 $start:std/array~anonymous|43 $start:std/array~anonymous|44 $start:std/array~anonymous|45 $start:std/array~anonymous|46 $start:std/array~anonymous|47 $start:std/array~anonymous|48 $~lib/util/sort/COMPARATOR<~lib/string/String | null>~anonymous|0 $~lib/util/sort/COMPARATOR<~lib/string/String>~anonymous|0)
(global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0))
Expand Down Expand Up @@ -263,7 +263,7 @@
(global $~lib/builtins/u32.MAX_VALUE i32 (i32.const -1))
(global $~lib/builtins/i64.MAX_VALUE i64 (i64.const 9223372036854775807))
(global $~started (mut i32) (i32.const 0))
(global $~lib/heap/__heap_base i32 (i32.const 10592))
(global $~lib/heap/__heap_base i32 (i32.const 10520))
(global $std/array/ArrayU32 i32 (i32.const 26))
(global $std/array/ArrayU8 i32 (i32.const 27))
(global $std/array/ArrayStr i32 (i32.const 28))
Expand Down