summaryrefslogtreecommitdiff
path: root/src/type-checker.cc
diff options
context:
space:
mode:
authorYury Delendik <ydelendik@mozilla.com>2019-09-12 07:35:32 -0500
committerGitHub <noreply@github.com>2019-09-12 07:35:32 -0500
commit99bb044a796b3c4bd3c292c11092de0e21d59ea9 (patch)
treed7ef95ff8f91856753ed944401dfaffc375670cb /src/type-checker.cc
parent3e938b7a10cc6738037dce5f18675cc5d267992d (diff)
downloadwabt-99bb044a796b3c4bd3c292c11092de0e21d59ea9.tar.gz
wabt-99bb044a796b3c4bd3c292c11092de0e21d59ea9.tar.bz2
wabt-99bb044a796b3c4bd3c292c11092de0e21d59ea9.zip
Add ref.* to the (invoke) (#1156)
Diffstat (limited to 'src/type-checker.cc')
-rw-r--r--src/type-checker.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/type-checker.cc b/src/type-checker.cc
index bc09c186..a5af56a9 100644
--- a/src/type-checker.cc
+++ b/src/type-checker.cc
@@ -169,9 +169,16 @@ Result TypeChecker::CheckTypeStackEnd(const char* desc) {
}
Result TypeChecker::CheckType(Type actual, Type expected) {
- return (expected == actual || expected == Type::Any || actual == Type::Any)
- ? Result::Ok
- : Result::Error;
+ if (expected == actual || expected == Type::Any || actual == Type::Any) {
+ return Result::Ok;
+ }
+ if (expected == Type::Anyref && (actual == Type::Funcref || actual == Type::Nullref)) {
+ return Result::Ok;
+ }
+ if ((expected == Type::Funcref || expected == Type::Anyref) && actual == Type::Nullref) {
+ return Result::Ok;
+ }
+ return Result::Error;
}
Result TypeChecker::CheckTypes(const TypeVector& actual,
@@ -631,7 +638,7 @@ Result TypeChecker::OnTableInit(uint32_t segment) {
Result TypeChecker::OnTableGet(Index segment) {
Result result = PopAndCheck1Type(Type::I32, "table.get");
- PushType(Type::Anyref); // TODO: should be the table's type
+ PushType(Type::Nullref); // TODO: should be the table's type
return result;
}
@@ -652,7 +659,7 @@ Result TypeChecker::OnTableSize(Index segment) {
}
Result TypeChecker::OnRefNullExpr() {
- PushType(Type::Anyref);
+ PushType(Type::Nullref);
return Result::Ok;
}