diff options
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/runtime.js b/src/runtime.js index fa127fe7..ca2304da 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -145,7 +145,7 @@ var Runtime = { //! @param type The type, by name. getNativeTypeSize: function(type) { #if QUANTUM_SIZE == 1 - return 1; + return 1; #else switch (type) { case 'i1': case 'i8': return 1; @@ -161,6 +161,8 @@ var Runtime = { var bits = parseInt(type.substr(1)); assert(bits % 8 === 0); return bits/8; + } else { + return 0; } } } @@ -224,9 +226,16 @@ var Runtime = { // bN, large number field, like a [N x i8] size = field.substr(1)|0; alignSize = 1; - } else { - assert(field[0] === '<', field); // assumed to be a vector type, if none of the above + } else if (field[0] === '<') { + // vector type size = alignSize = Types.types[field].flatSize; // fully aligned + } else if (field[0] === 'i') { + // illegal integer field, that could not be legalized because it is an internal structure field + // it is ok to have such fields, if we just use them as markers of field size and nothing more complex + size = alignSize = parseInt(field.substr(1))/8; + assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field); + } else { + assert(false, 'invalid type for calculateStructAlignment'); } if (type.packed) alignSize = 1; type.alignSize = Math.max(type.alignSize, alignSize); |