summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-08-09 15:04:25 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-09-07 09:54:58 -0700
commit8014a63b064a497ee4c18a70500f89fa51f75c79 (patch)
tree99259bd6b4ad8f9c601f0e5e9902f4c04b6d4460 /src
parentb19f9feb9f45774272fa0f26f7a561b3b1bd9e3a (diff)
downloadbinaryen-8014a63b064a497ee4c18a70500f89fa51f75c79.tar.gz
binaryen-8014a63b064a497ee4c18a70500f89fa51f75c79.tar.bz2
binaryen-8014a63b064a497ee4c18a70500f89fa51f75c79.zip
check store value type, and validation printing improvements
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp4
-rw-r--r--src/wasm-validator.h10
2 files changed, 10 insertions, 4 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 4f5701f10..c0d7ed345 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -730,6 +730,10 @@ Pass *createFullPrinterPass() {
// Print individual expressions
std::ostream& WasmPrinter::printExpression(Expression* expression, std::ostream& o, bool minify, bool full) {
+ if (!expression) {
+ o << "(null expression)";
+ return o;
+ }
PrintSExpression print(o);
print.setMinify(minify);
if (full) {
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index b4d604c2c..5e58ab408 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -203,7 +203,7 @@ public:
validateAlignment(curr->align);
shouldBeEqualOrFirstIsUnreachable(curr->ptr->type, i32, curr, "store pointer type must be i32");
shouldBeUnequal(curr->value->type, none, curr, "store value type must not be none");
- // TODO: enable a check that replaces this, for type being none shouldBeEqualOrFirstIsUnreachable(curr->value->type, curr->type, curr, "store value type must match");
+ shouldBeEqualOrFirstIsUnreachable(curr->value->type, curr->valueType, curr, "store value type must match");
}
void visitBinary(Binary *curr) {
if (curr->left->type != unreachable && curr->right->type != unreachable) {
@@ -330,7 +330,7 @@ public:
void visitGlobal(Global* curr) {
shouldBeTrue(curr->init->is<Const>(), curr->name, "global init must be valid");
- shouldBeEqual(curr->type, curr->init->type, curr, "global init must have correct type");
+ shouldBeEqual(curr->type, curr->init->type, nullptr, "global init must have correct type");
}
void visitFunction(Function *curr) {
@@ -422,7 +422,8 @@ private:
template<typename T, typename S>
bool shouldBeEqual(S left, S right, T curr, const char* text) {
if (left != right) {
- fail() << "" << left << " != " << right << ": " << text << ", on \n" << curr << std::endl;
+ fail() << "" << left << " != " << right << ": " << text << ", on \n";
+ WasmPrinter::printExpression(curr, std::cerr, false, true) << std::endl;
valid = false;
return false;
}
@@ -441,7 +442,8 @@ private:
template<typename T, typename S>
bool shouldBeEqualOrFirstIsUnreachable(S left, S right, T curr, const char* text) {
if (left != unreachable && left != right) {
- fail() << "" << left << " != " << right << ": " << text << ", on \n" << curr << std::endl;
+ fail() << "" << left << " != " << right << ": " << text << ", on \n";
+ WasmPrinter::printExpression(curr, std::cerr, false, true) << std::endl;
valid = false;
return false;
}