summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-03 18:00:37 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-03 18:00:37 -0800
commit0756845309f2cf3e5cd817dd3d25e727c96499ce (patch)
tree5a3f250cd31a4ec7ac0c145c36553f9c13fa4349
parent687a7c439987b8cc5ee7d298f14b948a8c98350c (diff)
downloadbinaryen-0756845309f2cf3e5cd817dd3d25e727c96499ce.tar.gz
binaryen-0756845309f2cf3e5cd817dd3d25e727c96499ce.tar.bz2
binaryen-0756845309f2cf3e5cd817dd3d25e727c96499ce.zip
start module parsing
-rw-r--r--src/wasm-sexpr-parser.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/wasm-sexpr-parser.h b/src/wasm-sexpr-parser.h
index 6264f6af4..f96d7a53a 100644
--- a/src/wasm-sexpr-parser.h
+++ b/src/wasm-sexpr-parser.h
@@ -16,7 +16,8 @@ using namespace cashew;
IString MODULE("module"),
FUNC("func"),
PARAM("param"),
- RESULT("result");
+ RESULT("result"),
+ MEMORY("memory");
//
// An element in an S-Expression: a list or a string
@@ -157,9 +158,10 @@ public:
Element* root = parser.parseEverything();
if (debug) std::cout << *root << '\n';
assert(root);
- assert((*root)[0]->str() == MODULE);
- for (unsigned i = 1; i < root->size(); i++) {
- parseModuleElement(*(*root)[i]);
+ Element* module = (*root)[0];
+ assert((*module)[0]->str() == MODULE);
+ for (unsigned i = 1; i < module->size(); i++) {
+ parseModuleElement(*(*module)[i]);
}
}
@@ -168,6 +170,7 @@ private:
void parseModuleElement(Element& curr) {
IString id = curr[0]->str();
if (id == FUNC) return parseFunction(curr);
+ if (id == MEMORY) return parseMemory(curr);
std::cerr << "bad module element " << id.str << '\n';
abort();
}
@@ -374,6 +377,10 @@ private:
ret->type = currLocalTypes[ret->name];
return ret;
}
+
+ void parseMemory(Element& s) {
+ wasm.memorySize = atoi(s[1]->str().str);
+ }
};
} // namespace wasm