diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 56 | ||||
-rw-r--r-- | src/binaryen-c.h | 17 |
2 files changed, 73 insertions, 0 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 06c71f5a5..5fd5be5e5 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -336,6 +336,62 @@ BinaryenHeapType BinaryenHeapTypeGetBottom(BinaryenHeapType heapType) { bool BinaryenHeapTypeIsSubType(BinaryenHeapType left, BinaryenHeapType right) { return HeapType::isSubType(HeapType(left), HeapType(right)); } +BinaryenIndex BinaryenStructTypeGetNumFields(BinaryenHeapType heapType) { + auto ht = HeapType(heapType); + assert(ht.isStruct()); + return ht.getStruct().fields.size(); +} +BinaryenType BinaryenStructTypeGetFieldType(BinaryenHeapType heapType, + BinaryenIndex index) { + auto ht = HeapType(heapType); + assert(ht.isStruct()); + auto& fields = ht.getStruct().fields; + assert(index < fields.size()); + return fields[index].type.getID(); +} +BinaryenPackedType +BinaryenStructTypeGetFieldPackedType(BinaryenHeapType heapType, + BinaryenIndex index) { + auto ht = HeapType(heapType); + assert(ht.isStruct()); + auto& fields = ht.getStruct().fields; + assert(index < fields.size()); + return fields[index].packedType; +} +bool BinaryenStructTypeIsFieldMutable(BinaryenHeapType heapType, + BinaryenIndex index) { + auto ht = HeapType(heapType); + assert(ht.isStruct()); + auto& fields = ht.getStruct().fields; + assert(index < fields.size()); + return fields[index].mutable_; +} +BinaryenType BinaryenArrayTypeGetElementType(BinaryenHeapType heapType) { + auto ht = HeapType(heapType); + assert(ht.isArray()); + return ht.getArray().element.type.getID(); +} +BinaryenPackedType +BinaryenArrayTypeGetElementPackedType(BinaryenHeapType heapType) { + auto ht = HeapType(heapType); + assert(ht.isArray()); + return ht.getArray().element.packedType; +} +bool BinaryenArrayTypeIsElementMutable(BinaryenHeapType heapType) { + auto ht = HeapType(heapType); + assert(ht.isArray()); + return ht.getArray().element.mutable_; +} +BinaryenType BinaryenSignatureTypeGetParams(BinaryenHeapType heapType) { + auto ht = HeapType(heapType); + assert(ht.isSignature()); + return ht.getSignature().params.getID(); +} +BinaryenType BinaryenSignatureTypeGetResults(BinaryenHeapType heapType) { + auto ht = HeapType(heapType); + assert(ht.isSignature()); + return ht.getSignature().results.getID(); +} BinaryenHeapType BinaryenTypeGetHeapType(BinaryenType type) { return Type(type).getHeapType().getID(); diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 480016a80..f5347a65b 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -165,6 +165,23 @@ BINARYEN_API BinaryenHeapType BinaryenHeapTypeGetBottom(BinaryenHeapType heapType); BINARYEN_API bool BinaryenHeapTypeIsSubType(BinaryenHeapType left, BinaryenHeapType right); +BINARYEN_API BinaryenIndex +BinaryenStructTypeGetNumFields(BinaryenHeapType heapType); +BINARYEN_API BinaryenType +BinaryenStructTypeGetFieldType(BinaryenHeapType heapType, BinaryenIndex index); +BINARYEN_API BinaryenPackedType BinaryenStructTypeGetFieldPackedType( + BinaryenHeapType heapType, BinaryenIndex index); +BINARYEN_API bool BinaryenStructTypeIsFieldMutable(BinaryenHeapType heapType, + BinaryenIndex index); +BINARYEN_API BinaryenType +BinaryenArrayTypeGetElementType(BinaryenHeapType heapType); +BINARYEN_API BinaryenPackedType +BinaryenArrayTypeGetElementPackedType(BinaryenHeapType heapType); +BINARYEN_API bool BinaryenArrayTypeIsElementMutable(BinaryenHeapType heapType); +BINARYEN_API BinaryenType +BinaryenSignatureTypeGetParams(BinaryenHeapType heapType); +BINARYEN_API BinaryenType +BinaryenSignatureTypeGetResults(BinaryenHeapType heapType); BINARYEN_API BinaryenHeapType BinaryenTypeGetHeapType(BinaryenType type); BINARYEN_API bool BinaryenTypeIsNullable(BinaryenType type); |