diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/s2wasm.h | 14 | ||||
-rw-r--r-- | src/wasm-linker.cpp | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index 082cbed1a..67ec557ef 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -285,8 +285,9 @@ class S2WasmBuilder { Name getAssign() { skipWhitespace(); if (*s != '$') return Name(); - std::string str; const char *before = s; + s++; + std::string str; while (*s && *s != '=' && *s != '\n' && *s != ',') { str += *s; s++; @@ -486,7 +487,7 @@ class S2WasmBuilder { unsigned nextId = 0; auto getNextId = [&nextId]() { - return cashew::IString(('$' + std::to_string(nextId++)).c_str(), false); + return cashew::IString(std::to_string(nextId++).c_str(), false); }; wasm::Builder builder(*wasm); std::vector<NameType> params; @@ -564,11 +565,14 @@ class S2WasmBuilder { if (match("$pop")) { skipToSep(); inputs[i] = nullptr; - } else { + } else if (*s == '$') { + s++; auto curr = allocator->alloc<GetLocal>(); curr->index = func->getLocalIndex(getStrToSep()); curr->type = func->getLocalType(curr->index); inputs[i] = curr; + } else { + abort_on("bad input register"); } if (*s == ')') s++; // tolerate 0(argument) syntax, where we started at the 'a' if (*s == ':') { // tolerate :attribute=value syntax (see getAttributes) @@ -586,9 +590,9 @@ class S2WasmBuilder { return getInputs(1)[0]; }; auto setOutput = [&](Expression* curr, Name assign) { - if (assign.isNull() || assign.str[1] == 'd') { // discard + if (assign.isNull() || assign.str[0] == 'd') { // drop addToBlock(curr); - } else if (assign.str[1] == 'p') { // push + } else if (assign.str[0] == 'p') { // push push(curr); } else { // set to a local auto set = allocator->alloc<SetLocal>(); diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index 7f8aee887..bf65ef615 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -355,7 +355,7 @@ void Linker::makeDynCallThunks() { std::vector<NameType> params; params.emplace_back("fptr", i32); // function pointer param int p = 0; - for (const auto& ty : funcType->params) params.emplace_back("$" + std::to_string(p++), ty); + for (const auto& ty : funcType->params) params.emplace_back(std::to_string(p++), ty); Function* f = wasmBuilder.makeFunction(std::string("dynCall_") + sig, std::move(params), funcType->result, {}); Expression* fptr = wasmBuilder.makeGetLocal(0, i32); std::vector<Expression*> args; |