diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-12-18 17:29:24 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-12-18 17:29:24 -0800 |
commit | 5bbf8a976bdb547a6e6801dc4dcd9da8bb1fefb3 (patch) | |
tree | 3169c999ead4db65048fb2cf5b13cd64e995dd37 /src/jsifier.js | |
parent | 2890aa49d7d26cef710f994f7a3f838ca3466356 (diff) |
fixes for llvm optimized code in 2 tests
Diffstat (limited to 'src/jsifier.js')
-rw-r--r-- | src/jsifier.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 4a65d927..f4565bcc 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -515,7 +515,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { // Function lines function makeFuncLineActor(intertype, func) { - substrate.addActor('Intertype:' + intertype, { + return substrate.addActor('Intertype:' + intertype, { processItem: function(item) { item.JS = func(item); if (!item.JS) throw "XXX - no JS generated for " + dump(item); @@ -697,7 +697,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { } } - makeFuncLineActor('mathop', function(item) { with(item) { + var mathop = makeFuncLineActor('mathop', function(item) { with(item) { for (var i = 1; i <= 4; i++) { if (item['param'+i]) { item['ident'+i] = indexizeFunctions(finalizeLLVMParameter(item['param'+i])); @@ -878,14 +878,28 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { case 'inttoptr': case 'ptrtoint': return finalizeLLVMParameter(item.params[0]); + case 'icmp': case 'mul': case 'zext': // TODO: Other mathops + var temp = { + op: item.intertype, + variant: item.variant + }; + for (var i = 1; i <= 4; i++) { + if (item.params[i-1]) { + temp['param' + i] = finalizeLLVMParameter(item.params[i-1]); + } + } + mathop.processItem(temp); + return temp.JS; default: - throw 'Invalid function to finalize: ' + dump(item); + throw 'Invalid function to finalize: ' + dump(item.intertype); } } // From parseLLVMSegment function finalizeLLVMParameter(param) { - if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { + if (isNumber(param) || typeof param === 'string') { + return param; + } else if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { return finalizeLLVMFunctionCall(param); } else if (param.intertype == 'value') { return parseNumerical(param.ident); |