summaryrefslogtreecommitdiff
path: root/src/type-checker.cc
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2020-02-28 21:16:33 -0800
committerGitHub <noreply@github.com>2020-02-28 21:16:33 -0800
commitf8e09f6ccfa25ca96be1a255b72e3240f29b4700 (patch)
tree0a2c21cc23fc1e23c9a6cd21d204a43d070044d6 /src/type-checker.cc
parent7914f5f0182b5282d9de8399ba3ff264b5b5dea5 (diff)
downloadwabt-f8e09f6ccfa25ca96be1a255b72e3240f29b4700.tar.gz
wabt-f8e09f6ccfa25ca96be1a255b72e3240f29b4700.tar.bz2
wabt-f8e09f6ccfa25ca96be1a255b72e3240f29b4700.zip
Convert Type from an enum into a class (#1350)
This is similar to the way Opcode is structured, which allows us to hang member functions off of the enumeration. The primary motivator for this change is the GC proposal (and the function-references proposal) where a Type can be parameterized: (type $T (struct ...)) (func (local (ref $T) ... ) In this case the type is ref, with a parameter of the type index. Making Type a class will make it easier to store this additional information.
Diffstat (limited to 'src/type-checker.cc')
-rw-r--r--src/type-checker.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/type-checker.cc b/src/type-checker.cc
index 11c36dcd..b6c02be4 100644
--- a/src/type-checker.cc
+++ b/src/type-checker.cc
@@ -30,7 +30,7 @@ std::string TypesToString(const TypeVector& types,
}
for (size_t i = 0; i < types.size(); ++i) {
- result += GetTypeName(types[i]);
+ result += types[i].GetName();
if (i < types.size() - 1) {
result += ", ";
}
@@ -169,13 +169,13 @@ static bool IsSubtype(Type sub, Type super) {
if (super == sub) {
return true;
}
- if (IsRefType(super) != IsRefType(sub)) {
+ if (super.IsRef() != sub.IsRef()) {
return false;
}
if (super == Type::Anyref) {
- return IsRefType(sub);
+ return sub.IsRef();
}
- if (IsNullableRefType(super)) {
+ if (super.IsNullableRef()) {
return sub == Type::Nullref;
}
return false;
@@ -731,7 +731,7 @@ Result TypeChecker::OnSelect(Type expected) {
result |= PeekType(1, &type1);
result |= PeekType(2, &type2);
if (expected == Type::Any) {
- if (IsRefType(type1) || IsRefType(type2)) {
+ if (type1.IsRef() || type2.IsRef()) {
result = Result::Error;
} else {
result |= CheckType(type1, type2);