aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-05 17:56:14 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 14:23:23 -0800
commit67f423ed8e38e76b11bac0347d4713e349d6b1b9 (patch)
tree3c8a64b1355bc7d0c508f89b77a64e6c978ed295 /src/parseTools.js
parent5c7a624b2d60c021f4d27f40272fca0c16dfa535 (diff)
legalize loads and stores of entire structures
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index c1428353..132e6e96 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -140,13 +140,20 @@ function isIntImplemented(type) {
return type[0] == 'i' || isPointerType(type);
}
-// Note: works for iX types, not pointers (even though they are implemented as ints)
+// Note: works for iX types and structure types, not pointers (even though they are implemented as ints)
function getBits(type) {
+ if (!type) return 0;
+ if (type[0] == 'i') {
+ var left = type.substr(1);
+ if (!isNumber(left)) return 0;
+ return parseInt(left);
+ }
if (isStructuralType(type)) return getStructuralTypeParts(type).length*32; // 32 bits per part in { i32, i1, i8, i32 } etc
- if (!type || type[0] != 'i') return 0;
- var left = type.substr(1);
- if (!isNumber(left)) return 0;
- return parseInt(left);
+ if (isStructType(type)) {
+ var typeData = Types.types[type];
+ return typeData.flatSize*8;
+ }
+ return 0;
}
function isIllegalType(type) {