Skip to content

Commit f67a843

Browse files
authored
refactor: Reorder ASC_TARGET enum for clarity (#1318)
BREAKING CHANGE: The values of `ASC_TARGET` have been flipped, with JS (portable) now being `0`, WASM32 being `1` and `WASM64` being `2`.
1 parent a98c1dc commit f67a843

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ module.exports = {
6969
// Quite common in scenarios where an iteration starts at `current = this`.
7070
"@typescript-eslint/no-this-alias": "off",
7171

72-
// Disabled here, but enabled again for JavaScript files
72+
// Disabled here, but enabled again for JavaScript files.
7373
"no-unused-vars": "off",
7474

75-
// Disabled here, but enabled again for TypeScript files
75+
// Disabled here, but enabled again for TypeScript files.
7676
"@typescript-eslint/no-unused-vars": "off"
7777
},
7878
overrides: [

std/assembly/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ declare type anyref = object;
4040

4141
// Compiler hints
4242

43-
/** Compiler target. 0 = WASM32, 1 = WASM64, 2 = JS. */
43+
/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */
4444
declare const ASC_TARGET: i32;
4545
/** Provided noAssert option. */
4646
declare const ASC_NO_ASSERT: bool;

std/assembly/shared/target.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
/** Compilation target. */
44
export enum Target {
5+
/** Portable. */
6+
JS = 0,
57
/** WebAssembly with 32-bit pointers. */
6-
WASM32 = 0,
8+
WASM32 = 1,
79
/** WebAssembly with 64-bit pointers. Experimental and not supported by any runtime yet. */
8-
WASM64 = 1,
9-
/** Portable. */
10-
JS = 2
10+
WASM64 = 2,
1111
}

std/portable/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ declare type valueof<T extends unknown[]> = T[0];
3333

3434
// Compiler hints
3535

36-
/** Compiler target. 0 = WASM32, 1 = WASM64, 2 = JS. */
36+
/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */
3737
declare const ASC_TARGET: i32;
3838
/** Provided noAssert option. */
3939
declare const ASC_NO_ASSERT: bool;

std/portable/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var globalScope = typeof window !== "undefined" && window || typeof global !== "undefined" && global || self;
44

5-
globalScope.ASC_TARGET = 2; // Target.JS
5+
globalScope.ASC_TARGET = 0; // Target.JS
66
globalScope.ASC_NO_ASSERT = false;
77
globalScope.ASC_MEMORY_BASE = 0;
88
globalScope.ASC_OPTIMIZE_LEVEL = 3;

tests/compiler/asc-constants.untouched.wat

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(type $none_=>_none (func))
33
(memory $0 0)
44
(table $0 1 funcref)
5-
(global $~lib/ASC_TARGET i32 (i32.const 0))
5+
(global $~lib/ASC_TARGET i32 (i32.const 1))
66
(global $~lib/ASC_NO_ASSERT i32 (i32.const 0))
77
(global $~lib/ASC_MEMORY_BASE i32 (i32.const 0))
88
(global $~lib/ASC_OPTIMIZE_LEVEL i32 (i32.const 0))
@@ -20,7 +20,7 @@
2020
(export "memory" (memory $0))
2121
(start $~start)
2222
(func $start:asc-constants
23-
i32.const 0
23+
i32.const 1
2424
drop
2525
i32.const 0
2626
drop

tests/compiler/wasi/snapshot_preview1.untouched.wat

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
(type $none_=>_none (func))
33
(memory $0 0)
44
(table $0 1 funcref)
5-
(global $~lib/shared/target/Target.WASM32 i32 (i32.const 0))
6-
(global $~lib/shared/target/Target.WASM64 i32 (i32.const 1))
7-
(global $~lib/shared/target/Target.JS i32 (i32.const 2))
8-
(global $~lib/ASC_TARGET i32 (i32.const 0))
5+
(global $~lib/shared/target/Target.JS i32 (i32.const 0))
6+
(global $~lib/shared/target/Target.WASM32 i32 (i32.const 1))
7+
(global $~lib/shared/target/Target.WASM64 i32 (i32.const 2))
8+
(global $~lib/ASC_TARGET i32 (i32.const 1))
99
(global $wasi/snapshot_preview1/sig (mut i32) (i32.const 1))
1010
(export "memory" (memory $0))
1111
(start $~start)
@@ -118,7 +118,7 @@
118118
i32.const 0
119119
i32.eq
120120
drop
121-
i32.const 0
121+
i32.const 1
122122
global.get $~lib/shared/target/Target.WASM32
123123
i32.eq
124124
drop
@@ -182,7 +182,7 @@
182182
i32.const 0
183183
i32.eq
184184
drop
185-
i32.const 0
185+
i32.const 1
186186
global.get $~lib/shared/target/Target.WASM32
187187
i32.eq
188188
drop

0 commit comments

Comments
 (0)