summaryrefslogtreecommitdiff
path: root/src/emscripten-optimizer
diff options
context:
space:
mode:
authorJacob Gravelle <jgravelle@google.com>2018-02-26 15:17:23 -0800
committerGitHub <noreply@github.com>2018-02-26 15:17:23 -0800
commitde999c4673688e1b6f29a9a3023e1295fca33446 (patch)
tree2ab27a1dbe0f0e49176f7a6edbf0ccf12a9d7957 /src/emscripten-optimizer
parent8bbf9b759b92f5d5248ee66096f07835caf6062a (diff)
downloadbinaryen-de999c4673688e1b6f29a9a3023e1295fca33446.tar.gz
binaryen-de999c4673688e1b6f29a9a3023e1295fca33446.tar.bz2
binaryen-de999c4673688e1b6f29a9a3023e1295fca33446.zip
EM_JS binaryen support (#1410)
* Emit EM_JS metadata * Include s2wasm-style em_js support * Change em_js metadata to be keyed on name * Add testcase for em_js, don't always emit emJsFuncs metadata * Better error handling for unexpectedly-formatted __em_js__ functions
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r--src/emscripten-optimizer/istring.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/emscripten-optimizer/istring.h b/src/emscripten-optimizer/istring.h
index 74b2c1e4b..8c77c4499 100644
--- a/src/emscripten-optimizer/istring.h
+++ b/src/emscripten-optimizer/istring.h
@@ -137,14 +137,18 @@ struct IString {
bool is() const { return str != nullptr; }
bool isNull() const { return str == nullptr; }
- bool startsWith(const char *prefix) const {
+ const char* stripPrefix(const char *prefix) const {
const char *ptr = str;
while (true) {
- if (*prefix == 0) return true;
- if (*ptr == 0) return false;
- if (*ptr++ != *prefix++) return false;
+ if (*prefix == 0) return ptr;
+ if (*ptr == 0) return nullptr;
+ if (*ptr++ != *prefix++) return nullptr;
}
}
+
+ bool startsWith(const char *prefix) const {
+ return stripPrefix(prefix) != nullptr;
+ }
};
} // namespace cashew