Skip to content

Add heap type utility definitions #2549

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 1 commit into from
Nov 4, 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
10 changes: 10 additions & 0 deletions src/glue/binaryen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ export declare function _BinaryenHeapTypeNofunc(): HeapTypeRef;

export declare function _BinaryenHeapTypeIsBottom(heapType: HeapTypeRef): bool;
export declare function _BinaryenHeapTypeGetBottom(heapType: HeapTypeRef): HeapTypeRef;
export declare function _BinaryenHeapTypeIsSubType(left: HeapTypeRef, right: HeapTypeRef): bool;
export declare function _BinaryenStructTypeGetNumFields(heapType: HeapTypeRef): Index;
export declare function _BinaryenStructTypeGetFieldType(heapType: HeapTypeRef, index: Index): TypeRef;
export declare function _BinaryenStructTypeGetFieldPackedType(heapType: HeapTypeRef, index: Index): PackedType;
export declare function _BinaryenStructTypeIsFieldMutable(heapType: HeapTypeRef, index: Index): bool;
export declare function _BinaryenArrayTypeGetElementType(heapType: HeapTypeRef): TypeRef;
export declare function _BinaryenArrayTypeGetElementPackedType(heapType: HeapTypeRef): PackedType;
export declare function _BinaryenArrayTypeIsElementMutable(heapType: HeapTypeRef): bool;
export declare function _BinaryenSignatureTypeGetParams(heapType: HeapTypeRef): TypeRef;
export declare function _BinaryenSignatureTypeGetResults(heapType: HeapTypeRef): TypeRef;

export declare function _BinaryenModuleCreate(): ModuleRef;
export declare function _BinaryenModuleDispose(module: ModuleRef): void;
Expand Down
10 changes: 10 additions & 0 deletions src/glue/binaryen.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ export const {

_BinaryenHeapTypeIsBottom,
_BinaryenHeapTypeGetBottom,
_BinaryenHeapTypeIsSubType,
_BinaryenStructTypeGetNumFields,
_BinaryenStructTypeGetFieldType,
_BinaryenStructTypeGetFieldPackedType,
_BinaryenStructTypeIsFieldMutable,
_BinaryenArrayTypeGetElementType,
_BinaryenArrayTypeGetElementPackedType,
_BinaryenArrayTypeIsElementMutable,
_BinaryenSignatureTypeGetParams,
_BinaryenSignatureTypeGetResults,

_BinaryenModuleCreate,
_BinaryenModuleDispose,
Expand Down
4 changes: 4 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export namespace HeapTypeRef {
export function getBottom(ht: HeapTypeRef): HeapTypeRef {
return binaryen._BinaryenHeapTypeGetBottom(ht);
}

export function isSubtype(ht: HeapTypeRef, superHt: HeapTypeRef): bool {
return binaryen._BinaryenHeapTypeIsSubType(ht, superHt);
}
}

/** Packed array element respectively struct field types. */
Expand Down