diff options
author | Alon Zakai <azakai@google.com> | 2021-04-08 18:06:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-08 18:06:15 -0700 |
commit | 8498027da4e078e6babe72f66829b479dd163510 (patch) | |
tree | 882048ce758b06d32c3875eb4d72d6574dfe1071 /src/binaryen-c.cpp | |
parent | 8e20e49a858f207e689589dfe9c056098c58eca2 (diff) | |
download | binaryen-8498027da4e078e6babe72f66829b479dd163510.tar.gz binaryen-8498027da4e078e6babe72f66829b479dd163510.tar.bz2 binaryen-8498027da4e078e6babe72f66829b479dd163510.zip |
RefFunc: Validate that the type is non-nullable, and avoid possible bugs in the builder (#3790)
The builder can receive a HeapType so that callers don't need to set non-nullability
themselves.
Not NFC as some of the callers were in fact still making it nullable.
Diffstat (limited to 'src/binaryen-c.cpp')
-rw-r--r-- | src/binaryen-c.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 907dbbb8b..49817974a 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -1283,9 +1283,10 @@ BinaryenExpressionRef BinaryenRefAs(BinaryenModuleRef module, BinaryenExpressionRef BinaryenRefFunc(BinaryenModuleRef module, const char* func, BinaryenType type) { + // TODO: consider changing the C API to receive a heap type Type type_(type); return static_cast<Expression*>( - Builder(*(Module*)module).makeRefFunc(func, type_)); + Builder(*(Module*)module).makeRefFunc(func, type_.getHeapType())); } BinaryenExpressionRef BinaryenRefEq(BinaryenModuleRef module, @@ -3485,9 +3486,8 @@ BinaryenAddActiveElementSegment(BinaryenModuleRef module, if (func == nullptr) { Fatal() << "invalid function '" << funcNames[i] << "'."; } - Type type(HeapType(func->sig), Nullable); segment->data.push_back( - Builder(*(Module*)module).makeRefFunc(funcNames[i], type)); + Builder(*(Module*)module).makeRefFunc(funcNames[i], func->sig)); } return ((Module*)module)->addElementSegment(std::move(segment)); } @@ -3503,9 +3503,8 @@ BinaryenAddPassiveElementSegment(BinaryenModuleRef module, if (func == nullptr) { Fatal() << "invalid function '" << funcNames[i] << "'."; } - Type type(HeapType(func->sig), Nullable); segment->data.push_back( - Builder(*(Module*)module).makeRefFunc(funcNames[i], type)); + Builder(*(Module*)module).makeRefFunc(funcNames[i], func->sig)); } return ((Module*)module)->addElementSegment(std::move(segment)); } |