Skip to content

Commit c287dce

Browse files
committed
Prepare for dataref becoming structref
1 parent 6b9f71e commit c287dce

File tree

11 files changed

+54
-53
lines changed

11 files changed

+54
-53
lines changed

src/builtins.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3466,7 +3466,7 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
34663466
case TypeKind.Externref:
34673467
case TypeKind.Anyref:
34683468
case TypeKind.Eqref:
3469-
case TypeKind.Dataref:
3469+
case TypeKind.Structref:
34703470
case TypeKind.Arrayref:
34713471
case TypeKind.I31ref:
34723472
case TypeKind.Stringref:
@@ -3547,7 +3547,7 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
35473547
case TypeKind.Externref:
35483548
case TypeKind.Anyref:
35493549
case TypeKind.Eqref:
3550-
case TypeKind.Dataref:
3550+
case TypeKind.Structref:
35513551
case TypeKind.Arrayref:
35523552
case TypeKind.I31ref:
35533553
case TypeKind.Stringref:

src/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export namespace CommonNames {
131131
export const anyref = "anyref";
132132
export const eqref = "eqref";
133133
export const i31ref = "i31ref";
134-
export const dataref = "dataref";
134+
export const structref = "structref";
135135
export const arrayref = "arrayref";
136136
export const stringref = "stringref";
137137
export const stringview_wtf8 = "stringview_wtf8";
@@ -212,7 +212,7 @@ export namespace CommonNames {
212212
export const Anyref = "Anyref";
213213
export const Eqref = "Eqref";
214214
export const I31ref = "I31ref";
215-
export const Dataref = "Dataref";
215+
export const Structref = "Structref";
216216
export const Arrayref = "Arrayref";
217217
export const String = "String";
218218
export const RegExp = "RegExp";

src/compiler.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4831,9 +4831,9 @@ export class Compiler extends DiagnosticEmitter {
48314831
);
48324832
}
48334833
case TypeKind.Eqref:
4834-
case TypeKind.I31ref:
4835-
case TypeKind.Dataref:
4836-
case TypeKind.Arrayref: return module.ref_eq(leftExpr, rightExpr);
4834+
case TypeKind.Structref:
4835+
case TypeKind.Arrayref:
4836+
case TypeKind.I31ref: return module.ref_eq(leftExpr, rightExpr);
48374837
case TypeKind.Stringref: return module.string_eq(leftExpr, rightExpr);
48384838
case TypeKind.StringviewWTF8:
48394839
case TypeKind.StringviewWTF16:
@@ -4881,9 +4881,9 @@ export class Compiler extends DiagnosticEmitter {
48814881
);
48824882
}
48834883
case TypeKind.Eqref:
4884-
case TypeKind.I31ref:
4885-
case TypeKind.Dataref:
4886-
case TypeKind.Arrayref: {
4884+
case TypeKind.Structref:
4885+
case TypeKind.Arrayref:
4886+
case TypeKind.I31ref: {
48874887
return module.unary(UnaryOp.EqzI32,
48884888
module.ref_eq(leftExpr, rightExpr)
48894889
);
@@ -9784,9 +9784,9 @@ export class Compiler extends DiagnosticEmitter {
97849784
return this.checkFeatureEnabled(Feature.ReferenceTypes, reportNode);
97859785
case TypeKind.Anyref:
97869786
case TypeKind.Eqref:
9787-
case TypeKind.I31ref:
9788-
case TypeKind.Dataref:
9789-
case TypeKind.Arrayref: {
9787+
case TypeKind.Structref:
9788+
case TypeKind.Arrayref:
9789+
case TypeKind.I31ref: {
97909790
return this.checkFeatureEnabled(Feature.ReferenceTypes, reportNode)
97919791
&& this.checkFeatureEnabled(Feature.GC, reportNode);
97929792
}
@@ -9902,7 +9902,7 @@ export class Compiler extends DiagnosticEmitter {
99029902
case TypeKind.Externref:
99039903
case TypeKind.Anyref:
99049904
case TypeKind.Eqref:
9905-
case TypeKind.Dataref:
9905+
case TypeKind.Structref:
99069906
case TypeKind.Arrayref:
99079907
case TypeKind.Stringref:
99089908
case TypeKind.StringviewWTF8:
@@ -10061,8 +10061,9 @@ export class Compiler extends DiagnosticEmitter {
1006110061
case TypeKind.Externref:
1006210062
case TypeKind.Anyref:
1006310063
case TypeKind.Eqref:
10064+
case TypeKind.Structref:
10065+
case TypeKind.Arrayref:
1006410066
case TypeKind.I31ref:
10065-
case TypeKind.Dataref:
1006610067
case TypeKind.Stringref:
1006710068
case TypeKind.StringviewWTF8:
1006810069
case TypeKind.StringviewWTF16:

src/module.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ export namespace TypeRef {
7575
export const Anyref = binaryen._BinaryenTypeAnyref();
7676
export const Eqref = binaryen._BinaryenTypeEqref();
7777
export const I31ref = binaryen._BinaryenTypeI31ref();
78-
export const Dataref = binaryen._BinaryenTypeDataref();
78+
export const Structref = binaryen._BinaryenTypeDataref(); // TODO: about to become struct
7979
export const Arrayref = binaryen._BinaryenTypeArrayref();
8080
export const Stringref = binaryen._BinaryenTypeStringref();
8181
export const StringviewWTF8 = binaryen._BinaryenTypeStringviewWTF8();
8282
export const StringviewWTF16 = binaryen._BinaryenTypeStringviewWTF16();
8383
export const StringviewIter = binaryen._BinaryenTypeStringviewIter();
84-
export const Noneref = binaryen._BinaryenTypeNullref();
85-
export const Nofuncref = binaryen._BinaryenTypeNullFuncref();
86-
export const Noexternref = binaryen._BinaryenTypeNullExternref();
84+
export const Nullref = binaryen._BinaryenTypeNullref();
85+
export const Nullfuncref = binaryen._BinaryenTypeNullFuncref();
86+
export const Nullexternref = binaryen._BinaryenTypeNullExternref();
8787
}
8888

8989
/** Reference to a Binaryen heap type. */
@@ -3742,15 +3742,15 @@ function tryEnsureBasicType(type: Type): TypeRef {
37423742
case TypeKind.Eqref: {
37433743
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.Eq, type.is(TypeFlags.Nullable));
37443744
}
3745-
case TypeKind.I31ref: {
3746-
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.I31, type.is(TypeFlags.Nullable));
3747-
}
3748-
case TypeKind.Dataref: {
3745+
case TypeKind.Structref: {
37493746
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.Data, type.is(TypeFlags.Nullable));
37503747
}
37513748
case TypeKind.Arrayref: {
37523749
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.Array, type.is(TypeFlags.Nullable));
37533750
}
3751+
case TypeKind.I31ref: {
3752+
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.I31, type.is(TypeFlags.Nullable));
3753+
}
37543754
case TypeKind.Stringref: {
37553755
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.String, type.is(TypeFlags.Nullable));
37563756
}

src/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ export class Program extends DiagnosticEmitter {
10321032
this.registerNativeType(CommonNames.anyref, Type.anyref);
10331033
this.registerNativeType(CommonNames.eqref, Type.eqref);
10341034
this.registerNativeType(CommonNames.i31ref, Type.i31ref);
1035-
this.registerNativeType(CommonNames.dataref, Type.dataref);
1035+
this.registerNativeType(CommonNames.structref, Type.structref);
10361036
this.registerNativeType(CommonNames.arrayref, Type.arrayref);
10371037
this.registerNativeType(CommonNames.stringref, Type.stringref);
10381038
this.registerNativeType(CommonNames.stringview_wtf8, Type.stringview_wtf8);
@@ -1306,7 +1306,7 @@ export class Program extends DiagnosticEmitter {
13061306
this.registerWrapperClass(Type.anyref, CommonNames.Anyref);
13071307
this.registerWrapperClass(Type.eqref, CommonNames.Eqref);
13081308
this.registerWrapperClass(Type.i31ref, CommonNames.I31ref);
1309-
this.registerWrapperClass(Type.dataref, CommonNames.Dataref);
1309+
this.registerWrapperClass(Type.structref, CommonNames.Structref);
13101310
this.registerWrapperClass(Type.arrayref, CommonNames.Arrayref);
13111311
}
13121312
}

src/types.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ export const enum TypeKind {
7575
Anyref,
7676
/** Equatable reference. */
7777
Eqref,
78-
/** 31-bit integer reference. */
79-
I31ref,
80-
/** Data reference. */
81-
Dataref,
78+
/** Struct reference. */
79+
Structref,
8280
/** Array reference. */
8381
Arrayref,
82+
/** 31-bit integer reference. */
83+
I31ref,
8484
/** String reference. */
8585
Stringref,
8686
/** WTF8 string view. */
@@ -579,9 +579,9 @@ export class Type {
579579
case TypeKind.Externref: return CommonNames.externref;
580580
case TypeKind.Anyref: return CommonNames.anyref;
581581
case TypeKind.Eqref: return CommonNames.eqref;
582-
case TypeKind.I31ref: return CommonNames.i31ref;
583-
case TypeKind.Dataref: return CommonNames.dataref;
582+
case TypeKind.Structref: return CommonNames.structref;
584583
case TypeKind.Arrayref: return CommonNames.arrayref;
584+
case TypeKind.I31ref: return CommonNames.i31ref;
585585
case TypeKind.Stringref: return CommonNames.stringref;
586586
case TypeKind.StringviewWTF8: return CommonNames.stringview_wtf8;
587587
case TypeKind.StringviewWTF16: return CommonNames.stringview_wtf16;
@@ -625,7 +625,7 @@ export class Type {
625625
case TypeKind.I31ref: {
626626
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.I31, this.is(TypeFlags.Nullable));
627627
}
628-
case TypeKind.Dataref: {
628+
case TypeKind.Structref: {
629629
return binaryen._BinaryenTypeFromHeapType(HeapTypeRef.Data, this.is(TypeFlags.Nullable));
630630
}
631631
case TypeKind.Arrayref: {
@@ -805,22 +805,22 @@ export class Type {
805805
TypeFlags.Reference, 0
806806
);
807807

808-
/** 31-bit integer reference. */
809-
static readonly i31ref: Type = new Type(TypeKind.I31ref,
808+
/** Struct reference. */
809+
static readonly structref: Type = new Type(TypeKind.Structref,
810810
TypeFlags.External |
811811
TypeFlags.Nullable |
812812
TypeFlags.Reference, 0
813813
);
814814

815-
/** Data reference. */
816-
static readonly dataref: Type = new Type(TypeKind.Dataref,
815+
/** Array reference. */
816+
static readonly arrayref: Type = new Type(TypeKind.Arrayref,
817817
TypeFlags.External |
818818
TypeFlags.Nullable |
819819
TypeFlags.Reference, 0
820820
);
821821

822-
/** Array reference. */
823-
static readonly arrayref: Type = new Type(TypeKind.Arrayref,
822+
/** 31-bit integer reference. */
823+
static readonly i31ref: Type = new Type(TypeKind.I31ref,
824824
TypeFlags.External |
825825
TypeFlags.Nullable |
826826
TypeFlags.Reference, 0

std/assembly/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ declare type externref = object | null;
4343
declare type anyref = object | null;
4444
/** Equatable reference. */
4545
declare type eqref = object | null;
46-
/** 31-bit integer reference. */
47-
declare type i31ref = object | null;
48-
/** Data reference. */
49-
declare type dataref = object | null;
46+
/** Struct reference. */
47+
declare type structref = object | null;
5048
/** Array reference. */
5149
declare type arrayref = object | null;
50+
/** 31-bit integer reference. */
51+
declare type i31ref = object | null;
5252
/** String reference. */
5353
declare type stringref = object | null;
5454
/** WTF-8 string view. */

std/assembly/reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export abstract class I31ref extends Ref {
2323
}
2424

2525
@final @unmanaged
26-
export abstract class Dataref extends Ref {
26+
export abstract class Structref extends Ref {
2727
}
2828

2929
@final @unmanaged

tests/compiler/features/gc.debug.wat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
(global $features/gc/globalExtern externref (ref.null noextern))
77
(global $features/gc/globalAny anyref (ref.null none))
88
(global $features/gc/globalEq eqref (ref.null none))
9-
(global $features/gc/globalI31 i31ref (ref.null none))
10-
(global $features/gc/globalData dataref (ref.null none))
9+
(global $features/gc/globalStruct dataref (ref.null none))
1110
(global $features/gc/globalArray arrayref (ref.null none))
11+
(global $features/gc/globalI31 i31ref (ref.null none))
1212
(global $~lib/memory/__data_end i32 (i32.const 60))
1313
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 32828))
1414
(global $~lib/memory/__heap_base i32 (i32.const 32828))
@@ -21,9 +21,9 @@
2121
(export "globalExtern" (global $features/gc/globalExtern))
2222
(export "globalAny" (global $features/gc/globalAny))
2323
(export "globalEq" (global $features/gc/globalEq))
24-
(export "globalI31" (global $features/gc/globalI31))
25-
(export "globalData" (global $features/gc/globalData))
24+
(export "globalStruct" (global $features/gc/globalStruct))
2625
(export "globalArray" (global $features/gc/globalArray))
26+
(export "globalI31" (global $features/gc/globalI31))
2727
(export "memory" (memory $0))
2828
(export "_start" (func $~start))
2929
(func $features/gc/test_i31 (type $none_=>_none)

tests/compiler/features/gc.release.wat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
(global $features/gc/globalExtern externref (ref.null noextern))
55
(global $features/gc/globalAny anyref (ref.null none))
66
(global $features/gc/globalEq eqref (ref.null none))
7-
(global $features/gc/globalI31 i31ref (ref.null none))
8-
(global $features/gc/globalData dataref (ref.null none))
7+
(global $features/gc/globalStruct dataref (ref.null none))
98
(global $features/gc/globalArray arrayref (ref.null none))
9+
(global $features/gc/globalI31 i31ref (ref.null none))
1010
(memory $0 1)
1111
(data (i32.const 1036) ",")
1212
(data (i32.const 1048) "\01\00\00\00\1c\00\00\00f\00e\00a\00t\00u\00r\00e\00s\00/\00g\00c\00.\00t\00s")
1313
(export "globalFunc" (global $features/gc/globalFunc))
1414
(export "globalExtern" (global $features/gc/globalExtern))
1515
(export "globalAny" (global $features/gc/globalAny))
1616
(export "globalEq" (global $features/gc/globalEq))
17-
(export "globalI31" (global $features/gc/globalI31))
18-
(export "globalData" (global $features/gc/globalData))
17+
(export "globalStruct" (global $features/gc/globalStruct))
1918
(export "globalArray" (global $features/gc/globalArray))
19+
(export "globalI31" (global $features/gc/globalI31))
2020
(export "memory" (memory $0))
2121
(export "_start" (func $~start))
2222
(func $~start (type $none_=>_none)

0 commit comments

Comments
 (0)