Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b248254

Browse files
authored
Unify reference types (#2689)
1 parent 5e3be1e commit b248254

File tree

23 files changed

+367
-315
lines changed

23 files changed

+367
-315
lines changed

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
- uses: dcodeIO/setup-node-nvm@master
7575
with:
7676
node-mirror: https://nodejs.org/download/v8-canary/
77-
node-version: 19.0.0-v8-canary202209029fc5a9347b
77+
node-version: 21.0.0-v8-canary20230419061e93e884
7878
- name: Install dependencies
7979
run: npm ci --no-audit
8080
- name: Build

‎cli/index.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export async function main(argv, options) {
372372
let name = features[i].trim();
373373
let flag = assemblyscript[`FEATURE_${toUpperSnakeCase(name)}`];
374374
if (!flag) return prepareResult(Error(`Feature '${name}' is unknown.`));
375-
assemblyscript.disableFeature(compilerOptions, flag);
375+
assemblyscript.setFeature(compilerOptions, flag,false);
376376
}
377377
}
378378

@@ -383,7 +383,7 @@ export async function main(argv, options) {
383383
let name = features[i].trim();
384384
let flag = assemblyscript[`FEATURE_${toUpperSnakeCase(name)}`];
385385
if (!flag) return prepareResult(Error(`Feature '${name}' is unknown.`));
386-
assemblyscript.enableFeature(compilerOptions, flag);
386+
assemblyscript.setFeature(compilerOptions, flag,true);
387387
}
388388
}
389389

‎src/builtins.ts‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,7 +3523,7 @@ function builtin_i31_new(ctx: BuiltinFunctionContext): ExpressionRef {
35233523
) return module.unreachable();
35243524
let operands = ctx.operands;
35253525
let arg0 = compiler.compileExpression(operands[0], Type.i32, Constraints.ConvImplicit);
3526-
compiler.currentType = Type.i31ref;
3526+
compiler.currentType = Type.i31;
35273527
return module.i31_new(arg0);
35283528
}
35293529
builtinFunctions.set(BuiltinNames.i31_new, builtin_i31_new);
@@ -3536,7 +3536,7 @@ function builtin_i31_get(ctx: BuiltinFunctionContext): ExpressionRef {
35363536
checkArgsRequired(ctx, 1)
35373537
) return module.unreachable();
35383538
let operands = ctx.operands;
3539-
let arg0 = compiler.compileExpression(operands[0], Type.i31ref, Constraints.ConvImplicit);
3539+
let arg0 = compiler.compileExpression(operands[0], Type.i31.asNullable(), Constraints.ConvImplicit);
35403540
if (ctx.contextualType.is(TypeFlags.Unsigned)) {
35413541
compiler.currentType = Type.u32;
35423542
return module.i31_get(arg0, false);
@@ -3653,14 +3653,14 @@ function builtin_assert(ctx: BuiltinFunctionContext): ExpressionRef {
36533653
// TODO: also check for NaN in float assertions, as in `Boolean(NaN) -> false`?
36543654
case TypeKind.F32: return module.if(module.binary(BinaryOp.EqF32, arg0, module.f32(0)), abort);
36553655
case TypeKind.F64: return module.if(module.binary(BinaryOp.EqF64, arg0, module.f64(0)), abort);
3656-
case TypeKind.Funcref:
3657-
case TypeKind.Externref:
3658-
case TypeKind.Anyref:
3659-
case TypeKind.Eqref:
3660-
case TypeKind.Structref:
3661-
case TypeKind.Arrayref:
3662-
case TypeKind.I31ref:
3663-
case TypeKind.Stringref:
3656+
case TypeKind.Func:
3657+
case TypeKind.Extern:
3658+
case TypeKind.Any:
3659+
case TypeKind.Eq:
3660+
case TypeKind.Struct:
3661+
case TypeKind.Array:
3662+
case TypeKind.I31:
3663+
case TypeKind.String:
36643664
case TypeKind.StringviewWTF8:
36653665
case TypeKind.StringviewWTF16:
36663666
case TypeKind.StringviewIter: return module.if(module.ref_is_null(arg0), abort);
@@ -3734,14 +3734,14 @@ function builtin_assert(ctx: BuiltinFunctionContext): ExpressionRef {
37343734
);
37353735
return ret;
37363736
}
3737-
case TypeKind.Funcref:
3738-
case TypeKind.Externref:
3739-
case TypeKind.Anyref:
3740-
case TypeKind.Eqref:
3741-
case TypeKind.Structref:
3742-
case TypeKind.Arrayref:
3743-
case TypeKind.I31ref:
3744-
case TypeKind.Stringref:
3737+
case TypeKind.Func:
3738+
case TypeKind.Extern:
3739+
case TypeKind.Any:
3740+
case TypeKind.Eq:
3741+
case TypeKind.Struct:
3742+
case TypeKind.Array:
3743+
case TypeKind.I31:
3744+
case TypeKind.String:
37453745
case TypeKind.StringviewWTF8:
37463746
case TypeKind.StringviewWTF16:
37473747
case TypeKind.StringviewIter: {

‎src/common.ts‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ export const enum CommonFlags {
8181
// Other
8282

8383
/** Is quoted. */
84-
Quoted = 1 << 30
84+
Quoted = 1 << 30,
85+
/** Is internally nullable. */
86+
InternallyNullable = 1 << 31
8587
}
8688

8789
/** Path delimiter inserted between file system levels. */
@@ -126,17 +128,17 @@ export namespace CommonNames {
126128
export const f32 = "f32";
127129
export const f64 = "f64";
128130
export const v128 = "v128";
129-
export const funcref = "funcref";
130-
export const externref = "externref";
131-
export const anyref = "anyref";
132-
export const eqref = "eqref";
133-
export const structref = "structref";
134-
export const arrayref = "arrayref";
135-
export const i31ref = "i31ref";
136-
export const stringref = "stringref";
137-
export const stringview_wtf8 = "stringview_wtf8";
138-
export const stringview_wtf16 = "stringview_wtf16";
139-
export const stringview_iter = "stringview_iter";
131+
export const ref_func = "ref_func";
132+
export const ref_extern = "ref_extern";
133+
export const ref_any = "ref_any";
134+
export const ref_eq = "ref_eq";
135+
export const ref_struct = "ref_struct";
136+
export const ref_array = "ref_array";
137+
export const ref_i31 = "ref_i31";
138+
export const ref_string = "ref_string";
139+
export const ref_stringview_wtf8 = "ref_stringview_wtf8";
140+
export const ref_stringview_wtf16 = "ref_stringview_wtf16";
141+
export const ref_stringview_iter = "ref_stringview_iter";
140142
export const i8x16 = "i8x16";
141143
export const u8x16 = "u8x16";
142144
export const i16x8 = "i16x8";
@@ -207,13 +209,14 @@ export namespace CommonNames {
207209
export const F32 = "F32";
208210
export const F64 = "F64";
209211
export const V128 = "V128";
210-
export const Funcref = "Funcref";
211-
export const Externref = "Externref";
212-
export const Anyref = "Anyref";
213-
export const Eqref = "Eqref";
214-
export const Structref = "Structref";
215-
export const Arrayref = "Arrayref";
216-
export const I31ref = "I31ref";
212+
export const RefFunc = "RefFunc";
213+
export const RefExtern = "RefExtern";
214+
export const RefAny = "RefAny";
215+
export const RefEq = "RefEq";
216+
export const RefStruct = "RefStruct";
217+
export const RefArray = "RefArray";
218+
export const RefI31 = "RefI31";
219+
export const RefString = "RefString";
217220
export const String = "String";
218221
export const RegExp = "RegExp";
219222
export const Object = "Object";

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /