aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/intertyper.js7
-rw-r--r--src/jsifier.js7
-rw-r--r--src/parseTools.js12
-rw-r--r--src/shell.js16
4 files changed, 26 insertions, 16 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 715b6fa4..972b5de6 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -715,11 +715,12 @@ function intertyper(data, parseFunctions, baseLineNum) {
lineNum: item.lineNum
}];
} else {
+ var commaIndex = findTokenText(item, ',');
return [{
intertype: 'branch',
- ident: toNiceIdent(item.tokens[2].text),
- labelTrue: toNiceIdent(item.tokens[5].text),
- labelFalse: toNiceIdent(item.tokens[8].text),
+ condition: parseLLVMSegment(item.tokens.slice(1, commaIndex)),
+ labelTrue: toNiceIdent(item.tokens[commaIndex+2].text),
+ labelFalse: toNiceIdent(item.tokens[commaIndex+5].text),
lineNum: item.lineNum
}];
}
diff --git a/src/jsifier.js b/src/jsifier.js
index 7784c1ab..1b83b991 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -606,14 +606,15 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
makeFuncLineActor('branch', function(item) {
if (item.stolen) return ';'; // We will appear where we were stolen to
- if (!item.ident) {
+ if (!item.condition) {
return makeBranch(item.label, item.currLabelId);
} else {
+ var condition = finalizeLLVMParameter(item.condition);
var labelTrue = makeBranch(item.labelTrue, item.currLabelId);
var labelFalse = makeBranch(item.labelFalse, item.currLabelId);
if (labelTrue == ';' && labelFalse == ';') return ';';
- var head = 'if (' + item.ident + ') { ';
- var head2 = 'if (!(' + item.ident + ')) { ';
+ var head = 'if (' + condition + ') { ';
+ var head2 = 'if (!(' + condition + ')) { ';
var else_ = ' } else { ';
var tail = ' }';
if (labelTrue == ';') {
diff --git a/src/parseTools.js b/src/parseTools.js
index debfb6da..8c8389fb 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -953,7 +953,7 @@ function finalizeLLVMFunctionCall(item) {
};
for (var i = 1; i <= 4; i++) {
if (item.params[i-1]) {
- temp['param' + i] = finalizeLLVMParameter(item.params[i-1]);
+ temp['param' + i] = item.params[i-1];
}
}
return processMathop(temp);
@@ -1106,8 +1106,10 @@ function isSignedOp(op, variant) {
}
function processMathop(item) { with(item) {
+ var paramTypes = ['', '', '', ''];
for (var i = 1; i <= 4; i++) {
if (item['param'+i]) {
+ paramTypes[i-1] = item['param'+i].type || type;
item['ident'+i] = finalizeLLVMParameter(item['param'+i]);
if (!isNumber(item['ident'+i])) {
item['ident'+i] = '(' + item['ident'+i] + ')'; // we may have nested expressions. So enforce the order of operations we want
@@ -1117,11 +1119,11 @@ function processMathop(item) { with(item) {
}
}
if (isUnsignedOp(op, variant)) {
- ident1 = makeSignOp(ident1, type, 'un');
- ident2 = makeSignOp(ident2, type, 'un');
+ ident1 = makeSignOp(ident1, paramTypes[0], 'un');
+ ident2 = makeSignOp(ident2, paramTypes[1], 'un');
} else if (isSignedOp(op, variant)) {
- ident1 = makeSignOp(ident1, type, 're');
- ident2 = makeSignOp(ident2, type, 're');
+ ident1 = makeSignOp(ident1, paramTypes[0], 're');
+ ident2 = makeSignOp(ident2, paramTypes[1], 're');
}
var bits = null;
if (item.type[0] === 'i') {
diff --git a/src/shell.js b/src/shell.js
index f18fc3ca..c73cf6e4 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -1,10 +1,13 @@
"use strict";
+/*
// Capture the output of this into a variable, if you want
-//(function(Module, args) {
-// Module = Module || {};
-// args = args || [];
+(function(Module, args) {
+ Module = Module || {};
+ Module.arguments = args || [];
+*/
+///*
// Runs much faster, for some reason
if (!this['Module']) {
this['Module'] = {};
@@ -14,11 +17,14 @@ try {
} catch(e) {
Module.arguments = [];
}
+//*/
{{BODY}}
// {{MODULE_ADDITIONS}}
-// return Module;
-//})({}, this.arguments); // Replace parameters as needed
+/*
+ return Module;
+}).call(this, {}, arguments); // Replace parameters as needed
+*/