aboutsummaryrefslogtreecommitdiff
path: root/src/analyzer.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-25 20:26:16 -0700
committeralon@honor <none@none>2010-09-25 20:26:16 -0700
commitb94c061e122f155cc5c1262a1bb470cb49ee04b4 (patch)
tree134322b7ed16b9a3ed805d4663e3233625d5ef7a /src/analyzer.js
parent481dec302bfb02b574741c4e505d274718854dff (diff)
optional memory alignment that matches c/c++; used in clang, not in llvm-gcc
Diffstat (limited to 'src/analyzer.js')
-rw-r--r--src/analyzer.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 93e61f1c..13c5c648 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -92,7 +92,7 @@ function analyzer(data) {
if (isNumberType(type) || isPointerType(type)) return;
data.types[type] = {
name_: type,
- fields: [ 'int32' ], // XXX
+ fields: [ 'i32' ], // XXX
flatSize: 1,
lineNum: '?',
};
@@ -166,9 +166,13 @@ function analyzer(data) {
var sizes = [];
type.flatIndexes = type.fields.map(function(field) {
var soFar = type.flatSize;
- var size = 1;
- if (isStructType(field)) {
+ var size;
+ if (isNumberType(field) || isPointerType(field)) {
+ size = getNativeFieldSize(field);
+ } else if (isStructType(field)) {
size = item.types[field].flatSize;
+ } else {
+ assert(0);
}
type.flatSize += size;
sizes.push(size);