summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 7ff946200..573df9dfa 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -833,64 +833,64 @@ Type SExpressionWasmBuilder::stringToType(const char* str,
bool prefix) {
if (str[0] == 'i') {
if (str[1] == '3' && str[2] == '2' && (prefix || str[3] == 0)) {
- return i32;
+ return Type::i32;
}
if (str[1] == '6' && str[2] == '4' && (prefix || str[3] == 0)) {
- return i64;
+ return Type::i64;
}
}
if (str[0] == 'f') {
if (str[1] == '3' && str[2] == '2' && (prefix || str[3] == 0)) {
- return f32;
+ return Type::f32;
}
if (str[1] == '6' && str[2] == '4' && (prefix || str[3] == 0)) {
- return f64;
+ return Type::f64;
}
}
if (str[0] == 'v') {
if (str[1] == '1' && str[2] == '2' && str[3] == '8' &&
(prefix || str[4] == 0)) {
- return v128;
+ return Type::v128;
}
}
if (strncmp(str, "funcref", 7) == 0 && (prefix || str[7] == 0)) {
- return funcref;
+ return Type::funcref;
}
if (strncmp(str, "anyref", 6) == 0 && (prefix || str[6] == 0)) {
- return anyref;
+ return Type::anyref;
}
if (strncmp(str, "nullref", 7) == 0 && (prefix || str[7] == 0)) {
- return nullref;
+ return Type::nullref;
}
if (strncmp(str, "exnref", 6) == 0 && (prefix || str[6] == 0)) {
- return exnref;
+ return Type::exnref;
}
if (allowError) {
- return none;
+ return Type::none;
}
throw ParseException(std::string("invalid wasm type: ") + str);
}
Type SExpressionWasmBuilder::stringToLaneType(const char* str) {
if (strcmp(str, "i8x16") == 0) {
- return i32;
+ return Type::i32;
}
if (strcmp(str, "i16x8") == 0) {
- return i32;
+ return Type::i32;
}
if (strcmp(str, "i32x4") == 0) {
- return i32;
+ return Type::i32;
}
if (strcmp(str, "i64x2") == 0) {
- return i64;
+ return Type::i64;
}
if (strcmp(str, "f32x4") == 0) {
- return f32;
+ return Type::f32;
}
if (strcmp(str, "f64x2") == 0) {
- return f64;
+ return Type::f64;
}
- return none;
+ return Type::none;
}
Function::DebugLocation
@@ -1067,7 +1067,7 @@ Expression* SExpressionWasmBuilder::makeBlock(Element& s) {
if (i < s.size() && s[i]->isStr()) {
// could be a name or a type
if (s[i]->dollared() ||
- stringToType(s[i]->str(), true /* allowError */) == none) {
+ stringToType(s[i]->str(), true /* allowError */) == Type::none) {
sName = s[i++]->str();
} else {
sName = "block";
@@ -1152,7 +1152,7 @@ static Literal makeLanes(Element& s, MixedArena& allocator, Type lane_t) {
}
Expression* SExpressionWasmBuilder::makeConst(Element& s, Type type) {
- if (type != v128) {
+ if (type != Type::v128) {
auto ret = parseConst(s[1]->str(), type, allocator);
if (!ret) {
throw ParseException("bad const", s[1]->line, s[1]->col);
@@ -1165,7 +1165,7 @@ Expression* SExpressionWasmBuilder::makeConst(Element& s, Type type) {
size_t lanes = s.size() - 2;
switch (lanes) {
case 2: {
- if (lane_t != i64 && lane_t != f64) {
+ if (lane_t != Type::i64 && lane_t != Type::f64) {
throw ParseException(
"Unexpected v128 literal lane type", s[1]->line, s[1]->col);
}
@@ -1173,7 +1173,7 @@ Expression* SExpressionWasmBuilder::makeConst(Element& s, Type type) {
break;
}
case 4: {
- if (lane_t != i32 && lane_t != f32) {
+ if (lane_t != Type::i32 && lane_t != Type::f32) {
throw ParseException(
"Unexpected v128 literal lane type", s[1]->line, s[1]->col);
}
@@ -1181,7 +1181,7 @@ Expression* SExpressionWasmBuilder::makeConst(Element& s, Type type) {
break;
}
case 8: {
- if (lane_t != i32) {
+ if (lane_t != Type::i32) {
throw ParseException(
"Unexpected v128 literal lane type", s[1]->line, s[1]->col);
}
@@ -1189,7 +1189,7 @@ Expression* SExpressionWasmBuilder::makeConst(Element& s, Type type) {
break;
}
case 16: {
- if (lane_t != i32) {
+ if (lane_t != Type::i32) {
throw ParseException(
"Unexpected v128 literal lane type", s[1]->line, s[1]->col);
}
@@ -1626,7 +1626,7 @@ SExpressionWasmBuilder::makeMaybeBlock(Element& s, size_t i, Type type) {
Type SExpressionWasmBuilder::parseOptionalResultType(Element& s, Index& i) {
if (s.size() == i) {
- return none;
+ return Type::none;
}
// TODO(sbc): Remove support for old result syntax (bare streing) once the
@@ -1638,7 +1638,7 @@ Type SExpressionWasmBuilder::parseOptionalResultType(Element& s, Index& i) {
Element& params = *s[i];
IString id = params[0]->str();
if (id != RESULT) {
- return none;
+ return Type::none;
}
i++;
@@ -2003,7 +2003,7 @@ void SExpressionWasmBuilder::parseMemory(Element& s, bool preParseImport) {
}
const char* input = curr[j]->c_str();
auto* offset = allocator.alloc<Const>();
- offset->type = i32;
+ offset->type = Type::i32;
offset->value = Literal(int32_t(offsetValue));
if (auto size = strlen(input)) {
std::vector<char> data;
@@ -2245,7 +2245,7 @@ void SExpressionWasmBuilder::parseGlobal(Element& s, bool preParseImport) {
globalCounter++;
globalNames.push_back(global->name);
bool mutable_ = false;
- Type type = none;
+ Type type = Type::none;
bool exported = false;
Name importModule, importBase;
while (i < s.size() && s[i]->isList()) {
@@ -2276,7 +2276,7 @@ void SExpressionWasmBuilder::parseGlobal(Element& s, bool preParseImport) {
if (exported && mutable_) {
throw ParseException("cannot export a mutable global", s.line, s.col);
}
- if (type == none) {
+ if (type == Type::none) {
type = stringToType(s[i++]->str());
}
if (importModule.is()) {