diff options
Diffstat (limited to 'src/intertyper.js')
-rw-r--r-- | src/intertyper.js | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 96db6966..940c677f 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -660,9 +660,10 @@ function intertyper(lines, sidePass, baseLineNums) { var tokensLeft = item.tokens.slice(2); item.ident = eatLLVMIdent(tokensLeft); if (item.ident == 'asm') { + warnOnce('inline JavaScript using asm() has some oddities due to how gcc asm() syntax works. use EM_ASM where possible (see emscripten.h)'); if (ASM_JS) { Types.hasInlineJS = true; - warnOnce('inline JavaScript (asm, EM_ASM) will cause the code to no longer fall in the asm.js subset of JavaScript, which can reduce performance - consider using emscripten_run_script'); + warnOnce('inline JavaScript using asm() will cause the code to no longer fall in the asm.js subset of JavaScript, which can reduce performance - consider using emscripten_run_script'); } assert(TARGET_LE32, 'inline js is only supported in le32'); // Inline assembly is just JavaScript that we paste into the code @@ -672,15 +673,20 @@ function intertyper(lines, sidePass, baseLineNums) { assert((item.tokens[5].text.match(/=/g) || []).length <= 1, 'we only support at most 1 exported variable from inline js: ' + item.ident); var i = 0; var params = [], args = []; - splitTokenList(tokensLeft[3].tokens).map(function(element) { - var ident = toNiceIdent(element[1].text); - var type = element[0].text; - params.push('$' + (i++)); - args.push(ident); + if (tokensLeft[3].tokens) { + splitTokenList(tokensLeft[3].tokens).map(function(element) { + var ident = toNiceIdent(element[1].text); + var type = element[0].text; + params.push('$' + (i++)); + 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 { forward: null, ret: item, item: item }; + return { ret: item, item: item }; } if (item.ident.substr(-2) == '()') { // See comment in isStructType() @@ -703,13 +709,12 @@ function intertyper(lines, sidePass, baseLineNums) { if (item.indent == 2) { // standalone call - not in assign item.standalone = true; - return { forward: null, ret: item, item: item }; + return { ret: item, item: item }; } - return { forward: item, ret: null, item: item }; + return { ret: null, item: item }; } function callHandler(item) { var result = makeCall.call(this, item, 'call'); - if (result.forward) this.forwardItem(result.forward, 'Reintegrator'); return result.ret; } function invokeHandler(item) { @@ -719,10 +724,9 @@ function intertyper(lines, sidePass, baseLineNums) { finalResults.push({ intertype: 'branch', label: result.item.toLabel, - lineNum: (result.forward ? item.parentLineNum : item.lineNum) + 0.5 + lineNum: item.lineNum + 0.5 }); } - if (result.forward) this.forwardItem(result.forward, 'Reintegrator'); return result.ret; } function atomicHandler(item) { @@ -839,7 +843,7 @@ function intertyper(lines, sidePass, baseLineNums) { item.variant = item.tokens[1].text; item.tokens.splice(1, 1); } - if (item.tokens[1].text == 'exact') item.tokens.splice(1, 1); // TODO: Implement trap values + while (item.tokens[1].text in LLVM.MATHOP_IGNORABLES) item.tokens.splice(1, 1); var segments = splitTokenList(item.tokens.slice(1)); item.params = []; for (var i = 1; i <= 4; i++) { |