diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-09 16:18:31 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-09 16:18:50 -0800 |
commit | d446e2b3c3b96474106b9bd47f35d901abb14f6d (patch) | |
tree | 9fb6378d271abbfaeddaa3ec5c7d692da581a96b | |
parent | 473ab54aafafd37d0115490c1cbcb5cdbed6f21b (diff) |
support inline asm comments; fixes #1766
-rw-r--r-- | src/intertyper.js | 3 | ||||
-rw-r--r-- | src/parseTools.js | 6 | ||||
-rw-r--r-- | tests/test_core.py | 7 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index fceeb38d..fa53c652 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -680,6 +680,9 @@ function intertyper(lines, sidePass, baseLineNums) { args.push(ident); }); } + item.ident = expandLLVMString(item.ident).replace(/(#[^\n]*)/g, function(m) { + return '/* ' + m.substr(1) + ' */'; // fix asm comments to js comments + }); if (item.assignTo) item.ident = 'return ' + item.ident; item.ident = '(function(' + params + ') { ' + item.ident + ' })(' + args + ');'; return { ret: item, item: item }; diff --git a/src/parseTools.js b/src/parseTools.js index c4f28184..52727903 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -981,6 +981,12 @@ function parseLLVMString(str) { return ret; } +function expandLLVMString(str) { + return str.replace(/\\../g, function(m) { + return String.fromCharCode(parseInt(m.substr(1), '16')); + }); +} + function getLabelIds(labels) { return labels.map(function(label) { return label.ident }); } diff --git a/tests/test_core.py b/tests/test_core.py index b2147d49..3680a92d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3821,6 +3821,10 @@ def process(filename): double get() { double ret = 0; __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable + asm("#comment1"); + asm volatile("#comment2"); + asm volatile("#comment3\n" + "#comment4\n"); return ret; } @@ -3839,6 +3843,9 @@ def process(filename): ''' self.do_run(src, 'Inline JS is very cool\n3.64\n') # TODO 1\n2\n3\n1\n2\n3\n') + if self.emcc_args == []: # opts will eliminate the comments + out = open('src.cpp.o.js').read() + for i in range(1, 5): assert ('comment%d' % i) in out def test_inlinejs2(self): if not self.is_le32(): return self.skip('le32 needed for inline js') |