-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asm2wasm debuginfo #895
asm2wasm debuginfo #895
Changes from 1 commit
e5fe58e
4c1e369
7d800b2
3e75a78
f372841
85070ec
e7775bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,13 @@ struct AstStackHelper { | |
|
||
std::vector<Ref> AstStackHelper::astStack; | ||
|
||
static bool startsWith(const char* string, const char *prefix) { | ||
while (1) { | ||
if (*prefix == 0) return true; | ||
if (*string++ != *prefix++) return false; | ||
} | ||
}; | ||
|
||
// | ||
// Asm2WasmPreProcessor - does some initial parsing/processing | ||
// of asm.js code. | ||
|
@@ -238,18 +245,11 @@ struct Asm2WasmPreProcessor { | |
std::string DEBUGINFO_INTRINSIC = EMSCRIPTEN_DEBUGINFO.str; | ||
auto DEBUGINFO_INTRINSIC_SIZE = DEBUGINFO_INTRINSIC.size(); | ||
bool seenUseAsm = false; | ||
auto startsWith = [&](const char *s) { | ||
auto* check = input; | ||
while (1) { | ||
if (*s == 0) return true; | ||
if (*check++ != *s++) return false; | ||
} | ||
}; | ||
while (input[0]) { | ||
if (out + ADD_FACTOR >= end) { | ||
Fatal() << "error in handling debug info"; | ||
} | ||
if (startsWith("//@line")) { | ||
if (startsWith(input, "//@line")) { | ||
char* linePos = input + 8; | ||
char* lineEnd = strchr(input + 8, ' '); | ||
char* filePos = strchr(lineEnd, '"') + 1; | ||
|
@@ -276,7 +276,7 @@ struct Asm2WasmPreProcessor { | |
out += line.size(); | ||
*out++ = ')'; | ||
*out++ = ';'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing to do here just a thought/comment/observation: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, might be a better way. The code is not expected to change much if at all, though, so I think it's maintainable as it is. If it were evolving code definitely it would need to be refactored. |
||
} else if (!seenUseAsm && (startsWith("asm'") || startsWith("asm\""))) { | ||
} else if (!seenUseAsm && (startsWith(input, "asm'") || startsWith(input, "asm\""))) { | ||
// end of "use asm" or "almost asm" | ||
seenUseAsm = true; | ||
memcpy(out, input, 5); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth pulling the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh, it's actually the semicolon at the end, |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also probably return false if
*string == 0
for completeness, e.g.startsWith("foo", "foobar")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, fixing.