aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-19 21:05:22 -0700
committeralon@honor <none@none>2010-10-19 21:05:22 -0700
commit7a81db16fb5576bd4e378367072b8f6e389a5cf0 (patch)
tree6b51a8510d31a92221f7787ea5f5337068403a85 /src
parentc98eadd6b726ef17b56177dc81b7a9ecedfbe13c (diff)
partially handle the case of a variable in the middle of GEP indexings (and assert if cannot handle)
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 715b44f7..6f31c765 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -753,6 +753,7 @@ function JSify(data) {
var curr = toNiceIdent(arg.ident);
// TODO: If index is constant, optimize
var typeData = TYPES[type];
+ assert(typeData);
if (isStructType(type) && typeData.needsFlattening) {
if (typeData.flatFactor) {
indexes.push(getFastValue(curr, '*', typeData.flatFactor));
@@ -764,7 +765,15 @@ function JSify(data) {
indexes.push(curr); // XXX QUANTUM_SIZE?
}
}
- type = TYPES[type] ? TYPES[type].fields[curr] : '';
+ if (!isNumber(curr)) {
+ // We have a *variable* to index with. FIXME: Generate something dynamic here.
+ // But, most likely all the possible types are the same, so do that case here now...
+ for (var i = 1; i < typeData.fields.length; i++) {
+ assert(typeData.fields[0] === typeData.fields[i]);
+ }
+ curr = 0;
+ }
+ type = typeData ? typeData.fields[curr] : '';
});
var ret = indexes[0];
for (var i = 1; i < indexes.length; i++) {