aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js18
-rw-r--r--src/utility.js9
2 files changed, 16 insertions, 11 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index aadc021c..e5ab6b4c 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -137,11 +137,15 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) {
soFar++;
}
// Add current value(s)
- var currValue = values[i];
+ var currValue = flatten(values[i]);
ret.push(currValue);
i += 1;
soFar += typeof currValue === 'object' ? currValue.length : 1;
}
+ while (soFar < typeData.flatSize) {
+ ret.push(0);
+ soFar++;
+ }
return ret;
}
@@ -215,14 +219,6 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) {
function parseConst(value, type, ident) {
var constant = makeConst(value, type);
if (typeof constant === 'object') {
- function flatten(x) {
- if (typeof x !== 'object') return x;
- var ret = [];
- for (var i = 0; i < x.length; i++) {
- ret = ret.concat(flatten(x[i]));
- }
- return ret;
- }
constant = flatten(constant).map(function(x) { return parseNumerical(x) })
}
return constant;
@@ -863,12 +859,12 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) {
function finalizeLLVMFunctionCall(item) {
switch(item.intertype) {
- case 'getelementptr':
+ case 'getelementptr': // XXX finalizeLLVMParameter on the ident and the indexes?
return makePointer(makeGetSlab(item.ident, item.type), getGetElementPtrIndexes(item), null, item.type);
case 'bitcast':
case 'inttoptr':
case 'ptrtoint':
- return item.ident;
+ return finalizeLLVMParameter(item.params[0]);
default:
throw 'Invalid function to finalize: ' + dump(item);
}
diff --git a/src/utility.js b/src/utility.js
index 5020c911..68fab711 100644
--- a/src/utility.js
+++ b/src/utility.js
@@ -227,3 +227,12 @@ function isNumber(x) {
return x == parseFloat(x);
}
+function flatten(x) {
+ if (typeof x !== 'object') return x;
+ var ret = [];
+ for (var i = 0; i < x.length; i++) {
+ ret = ret.concat(flatten(x[i]));
+ }
+ return ret;
+}
+