Skip to content

Refactor RefIsOp and RefAsOp enums #2470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 src/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3473,7 +3473,7 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
case TypeKind.ANYREF:
case TypeKind.EQREF:
case TypeKind.DATAREF:
case TypeKind.I31REF: return module.if(module.ref_is(RefIsOp.RefIsNull, arg0), abort);
case TypeKind.I31REF: return module.if(module.ref_is(RefIsOp.Null, arg0), abort);

}
} else {
Expand Down Expand Up @@ -3558,7 +3558,7 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef {
case TypeKind.I31REF: {
let temp = flow.getTempLocal(type);
let ret = module.if(
module.ref_is(RefIsOp.RefIsNull,
module.ref_is(RefIsOp.Null,
module.local_tee(temp.index, arg0, false) // ref
),
abort,
Expand Down
20 changes: 10 additions & 10 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,25 +1056,25 @@ export const enum SIMDTernaryOp {
/** Binaryen RefIs operation constants. */
export const enum RefIsOp {
/** ref.is_null */
RefIsNull = 0 /* _BinaryenRefIsNull */,
Null = 0 /* _BinaryenRefIsNull */,
/** ref.is_func */
RefIsFunc = 1 /* _BinaryenRefIsFunc */,
Func = 1 /* _BinaryenRefIsFunc */,
/** ref.is_data */
RefIsData = 2 /* _BinaryenRefIsData */,
Data = 2 /* _BinaryenRefIsData */,
/** ref.is_i31 */
RefIsI31 = 3 /* _BinaryenRefIsI31 */
I31 = 3 /* _BinaryenRefIsI31 */
}

/** Binaryen RefAs operation constants. */
export const enum RefAsOp {
/** ref.as_non_null */
RefAsNonNull = 0 /* _BinaryenRefAsNonNull */,
NonNull = 0 /* _BinaryenRefAsNonNull */,
/** ref.as_func */
RefAsFunc = 1 /* _BinaryenRefAsFunc */,
Func = 1 /* _BinaryenRefAsFunc */,
/** ref.as_data */
RefAsData = 2 /* _BinaryenRefAsData */,
Data = 2 /* _BinaryenRefAsData */,
/** ref.as_i31 */
RefAsI31 = 3 /* _BinaryenRefAsI31 */
I31 = 3 /* _BinaryenRefAsI31 */
}

/** Binaryen BrOn operation constants. */
Expand Down Expand Up @@ -1880,7 +1880,7 @@ export class Module {
expr: ExpressionRef
): ExpressionRef {
if (isNullableType(getExpressionType(expr))) {
return binaryen._BinaryenRefIs(this.ref, RefIsOp.RefIsNull, expr);
return binaryen._BinaryenRefIs(this.ref, RefIsOp.Null, expr);
} else {
return this.i32(0); // false literal
}
Expand All @@ -1897,7 +1897,7 @@ export class Module {
expr: ExpressionRef
): ExpressionRef {
if (isNullableType(getExpressionType(expr))) {
return binaryen._BinaryenRefAs(this.ref, RefAsOp.RefAsNonNull, expr);
return binaryen._BinaryenRefAs(this.ref, RefAsOp.NonNull, expr);
} else {
return expr;
}
Expand Down