diff options
author | Alexander Meißner <AlexanderMeissner@gmx.net> | 2017-10-16 19:09:42 +0200 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2017-10-16 10:09:42 -0700 |
commit | faaa20b4950351528fd00888040fdd2b14a5a084 (patch) | |
tree | 32d94e71192e43db8abfabe542857c48a4c36d86 /src | |
parent | a8da89653981bb37565981afc69104f918fea64a (diff) | |
download | binaryen-faaa20b4950351528fd00888040fdd2b14a5a084.tar.gz binaryen-faaa20b4950351528fd00888040fdd2b14a5a084.tar.bz2 binaryen-faaa20b4950351528fd00888040fdd2b14a5a084.zip |
Fixed parseFile() skipping every other line (#1223)
* Fixed parseFile() skipping every other line
Was caused by "s = strchr(s, '\n')"
Also replaced recordFile() by parseFile() as they do exactly the same
* Added parseFile() to process() in s2wasm.h
Diffstat (limited to 'src')
-rw-r--r-- | src/s2wasm.h | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index 0fc0201cd..dd507143b 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -510,6 +510,7 @@ class S2WasmBuilder { else if (match("data")) {} else if (match("ident")) skipToEOL(); else if (match("section")) parseToplevelSection(); + else if (match("file")) parseFile(); else if (match("align") || match("p2align")) skipToEOL(); else if (match("import_global")) { skipToEOL(); @@ -597,26 +598,16 @@ class S2WasmBuilder { } void parseFile() { + if (debug) dump("file"); + size_t fileId = 0; if (*s != '"') { - // TODO: optimize, see recordFile below - size_t fileId = getInt(); + fileId = getInt(); skipWhitespace(); - auto quoted = getQuoted(); - uint32_t index = wasm->debugInfoFileNames.size(); - fileIndexMap[fileId] = index; - wasm->debugInfoFileNames.push_back(std::string(quoted.begin(), quoted.end())); - s = strchr(s, '\n'); - return; - } - // '.file' without first index argument points to bc-file - s++; - std::string filename; - while (*s != '"') { - filename += *s; - s++; } - s++; - WASM_UNUSED(filename); // TODO: use the filename + auto filename = getQuoted(); + uint32_t index = wasm->debugInfoFileNames.size(); + wasm->debugInfoFileNames.push_back(std::string(filename.begin(), filename.end())); + fileIndexMap[fileId] = index; } void parseGlobl() { @@ -670,16 +661,6 @@ class S2WasmBuilder { Function::DebugLocation debugLocation = { 0, 0, 0 }; bool useDebugLocation = false; - auto recordFile = [&]() { - if (debug) dump("file"); - size_t fileId = getInt(); - skipWhitespace(); - auto quoted = getQuoted(); - uint32_t index = wasm->debugInfoFileNames.size(); - fileIndexMap[fileId] = index; - wasm->debugInfoFileNames.push_back(std::string(quoted.begin(), quoted.end())); - s = strchr(s, '\n'); - }; auto recordLoc = [&]() { if (debug) dump("loc"); size_t fileId = getInt(); @@ -743,7 +724,7 @@ class S2WasmBuilder { if (!match(",")) break; } } else if (match(".file")) { - recordFile(); + parseFile(); skipWhitespace(); } else if (match(".loc")) { recordLoc(); @@ -1293,7 +1274,7 @@ class S2WasmBuilder { s = strchr(s, '\n'); break; // the function is done } else if (match(".file")) { - recordFile(); + parseFile(); } else if (match(".loc")) { recordLoc(); } else if (peek(".L") && strchr(s, ':') < strchr(s, '\n')) { |