From bcc76146fed433cbc8ba01a9f568d979c145110b Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 30 Dec 2019 17:55:20 -0800 Subject: Add support for reference types proposal (#2451) This adds support for the reference type proposal. This includes support for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`) and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and new typed `select`. This also adds subtype relationship support between reference types. This does not include table instructions yet. This also does not include wasm2js support. Fixes #2444 and fixes #2447. --- src/binaryen-c.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/binaryen-c.h') diff --git a/src/binaryen-c.h b/src/binaryen-c.h index f169ff367..36d82ecb0 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -98,7 +98,9 @@ BINARYEN_API BinaryenType BinaryenTypeInt64(void); BINARYEN_API BinaryenType BinaryenTypeFloat32(void); BINARYEN_API BinaryenType BinaryenTypeFloat64(void); BINARYEN_API BinaryenType BinaryenTypeVec128(void); +BINARYEN_API BinaryenType BinaryenTypeFuncref(void); BINARYEN_API BinaryenType BinaryenTypeAnyref(void); +BINARYEN_API BinaryenType BinaryenTypeNullref(void); BINARYEN_API BinaryenType BinaryenTypeExnref(void); BINARYEN_API BinaryenType BinaryenTypeUnreachable(void); // Not a real type. Used as the last parameter to BinaryenBlock to let @@ -158,6 +160,9 @@ BINARYEN_API BinaryenExpressionId BinaryenMemoryInitId(void); BINARYEN_API BinaryenExpressionId BinaryenDataDropId(void); BINARYEN_API BinaryenExpressionId BinaryenMemoryCopyId(void); BINARYEN_API BinaryenExpressionId BinaryenMemoryFillId(void); +BINARYEN_API BinaryenExpressionId BinaryenRefNullId(void); +BINARYEN_API BinaryenExpressionId BinaryenRefIsNullId(void); +BINARYEN_API BinaryenExpressionId BinaryenRefFuncId(void); BINARYEN_API BinaryenExpressionId BinaryenTryId(void); BINARYEN_API BinaryenExpressionId BinaryenThrowId(void); BINARYEN_API BinaryenExpressionId BinaryenRethrowId(void); @@ -222,6 +227,7 @@ struct BinaryenLiteral { float f32; double f64; uint8_t v128[16]; + const char* func; }; }; @@ -692,7 +698,8 @@ BINARYEN_API BinaryenExpressionRef BinaryenSelect(BinaryenModuleRef module, BinaryenExpressionRef condition, BinaryenExpressionRef ifTrue, - BinaryenExpressionRef ifFalse); + BinaryenExpressionRef ifFalse, + BinaryenType type); BINARYEN_API BinaryenExpressionRef BinaryenDrop(BinaryenModuleRef module, BinaryenExpressionRef value); // Return: value can be NULL @@ -797,6 +804,11 @@ BinaryenMemoryFill(BinaryenModuleRef module, BinaryenExpressionRef dest, BinaryenExpressionRef value, BinaryenExpressionRef size); +BINARYEN_API BinaryenExpressionRef BinaryenRefNull(BinaryenModuleRef module); +BINARYEN_API BinaryenExpressionRef +BinaryenRefIsNull(BinaryenModuleRef module, BinaryenExpressionRef value); +BINARYEN_API BinaryenExpressionRef BinaryenRefFunc(BinaryenModuleRef module, + const char* func); BINARYEN_API BinaryenExpressionRef BinaryenTry(BinaryenModuleRef module, BinaryenExpressionRef body, BinaryenExpressionRef catchBody); @@ -1035,6 +1047,11 @@ BinaryenMemoryFillGetValue(BinaryenExpressionRef expr); BINARYEN_API BinaryenExpressionRef BinaryenMemoryFillGetSize(BinaryenExpressionRef expr); +BINARYEN_API BinaryenExpressionRef +BinaryenRefIsNullGetValue(BinaryenExpressionRef expr); + +BINARYEN_API const char* BinaryenRefFuncGetFunc(BinaryenExpressionRef expr); + BINARYEN_API BinaryenExpressionRef BinaryenTryGetBody(BinaryenExpressionRef expr); BINARYEN_API BinaryenExpressionRef -- cgit v1.2.3