aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-10-10 19:58:29 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-10-10 19:58:29 -0700
commitd07a37e39426f7051fcca1aab13beba2d7ec0956 (patch)
treedf63381df12aee31523a6e97a737ecc3001dbddf
parent37347e52fc6b7110783efba5fad19c195dd375ec (diff)
EMSCRIPTEN_COMMENT for source comments
-rw-r--r--src/jsifier.js6
-rw-r--r--system/include/emscripten.h20
-rw-r--r--tests/runner.py8
3 files changed, 31 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index cd59d43c..9c34ddf1 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -838,6 +838,12 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
return makeSetValue(params[0].ident, 0, data, 'void*');
} else if (ident == '_llvm_va_end') {
return ';';
+ } else if (ident == '_EMSCRIPTEN_COMMENT') {
+ var param = finalizeParam(params[0]);
+ if (param.indexOf('CHECK_OVERFLOW') >= 0) {
+ param = param.split('(')[1].split(',')[0];
+ }
+ return '// ' + GLOBAL_VARIABLES[param].value.text.replace('\\00', '') + ' ';
}
var func = Functions.currFunctions[ident] || Functions.currExternalFunctions[ident];
diff --git a/system/include/emscripten.h b/system/include/emscripten.h
index 5f3689c9..4d321b2c 100644
--- a/system/include/emscripten.h
+++ b/system/include/emscripten.h
@@ -7,7 +7,23 @@
* http://emscripten.org
*/
-// Interface to the underlying JS engine. This function will
-// eval() the given script.
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Interface to the underlying JS engine. This function will
+ * eval() the given script.
+ */
extern void emscripten_run_script(const char *script);
+/*
+ * This macro-looking function will cause Emscripten to
+ * generate a comment in the generated code.
+ */
+extern void EMSCRIPTEN_COMMENT(const char *text);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/tests/runner.py b/tests/runner.py
index 3f124df7..bf71cf2c 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1430,11 +1430,17 @@ if 'benchmark' not in str(sys.argv):
#include "emscripten.h"
int main() {
+ EMSCRIPTEN_COMMENT("hello from the source");
emscripten_run_script("print('hello world' + '!')");
return 0;
}
'''
- self.do_test(src, 'hello world!')
+
+ def check(filename):
+ src = open(filename, 'r').read()
+ assert '// hello from the source' in src
+
+ self.do_test(src, 'hello world!', post_build=check)
def test_ssr(self): # struct self-ref
src = '''