diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-08-15 18:16:37 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-08-15 18:16:37 -0700 |
commit | ea6f1cebc098aef798cfdb9dbd0097875b0a5aae (patch) | |
tree | e9e658e705b7bc746edea905e2f405974e525cce /src | |
parent | 10cfcfa316a13b94ac7cc1966809e01adafc5f45 (diff) |
allow generateStructInfo to work at runtime with structMetadata
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 1 | ||||
-rw-r--r-- | src/runtime.js | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 078e57ea..3da296f1 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -840,6 +840,7 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { if (RUNTIME_TYPE_INFO) { Types.cleanForRuntime(); print('Runtime.typeInfo = ' + JSON.stringify(Types.types)); + print('Runtime.structMetadata = ' + JSON.stringify(Types.structMetadata)); } generated.forEach(function(item) { print(indentify(item.JS || '', 2)); }); print(Functions.generateIndexing()); diff --git a/src/runtime.js b/src/runtime.js index ad3c973d..abeb0d2a 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -183,11 +183,11 @@ Runtime = { var type, alignment; if (typeName) { offset = offset || 0; - type = typeof Types === 'undefined' ? Runtime.typeInfo[typeName] : Types.types[typeName]; + type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName]; if (!type) return null; - if (!struct) struct = Types.structMetadata[typeName.replace(/.*\./, '')]; + if (!struct) struct = (typeof Types === 'undefined' ? Runtime : Types).structMetadata[typeName.replace(/.*\./, '')]; if (!struct) return null; - assert(type.fields.length === struct.length, 'Number of named fields must match the type for ' + typeName); + assert(type.fields.length === struct.length, 'Number of named fields must match the type for ' + typeName + '. Perhaps due to inheritance, which is not supported yet?'); alignment = type.flatIndexes; } else { var type = { fields: struct.map(function(item) { return item[0] }) }; |