summaryrefslogtreecommitdiff
path: root/src/wast-parser.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/wast-parser.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/wast-parser.cc')
-rw-r--r--src/wast-parser.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index 3075ee91..6c9ca6ef 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -276,12 +276,11 @@ Result CheckTypeIndex(const Location& loc,
Errors* errors) {
// Types must match exactly; no subtyping should be allowed.
if (actual != expected) {
- errors->emplace_back(
- ErrorLevel::Error, loc,
- StringPrintf("type mismatch for %s %" PRIindex
- " of %s. got %s, expected %s",
- index_kind, index, desc, GetTypeName(actual),
- GetTypeName(expected)));
+ errors->emplace_back(ErrorLevel::Error, loc,
+ StringPrintf("type mismatch for %s %" PRIindex
+ " of %s. got %s, expected %s",
+ index_kind, index, desc, actual.GetName(),
+ expected.GetName()));
return Result::Error;
}
return Result::Ok;
@@ -788,7 +787,7 @@ Result WastParser::ParseValueType(Type* out_type) {
}
if (!is_enabled) {
- Error(token.loc, "value type not allowed: %s", GetTypeName(type));
+ Error(token.loc, "value type not allowed: %s", type.GetName());
return Result::Error;
}
@@ -813,7 +812,7 @@ Result WastParser::ParseRefType(Type* out_type) {
Token token = Consume();
Type type = token.type();
if (type == Type::Anyref && !options_->features.reference_types_enabled()) {
- Error(token.loc, "value type not allowed: %s", GetTypeName(type));
+ Error(token.loc, "value type not allowed: %s", type.GetName());
return Result::Error;
}