diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 15:32:45 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-27 15:32:45 -0800 |
commit | cb88b99fc40e27ba503ba6f29f9f15d3d7f15f63 (patch) | |
tree | b5ad4d3176bed4d27c79a2f49529e53ac4a79b40 | |
parent | 8e708a251fe5c62e1f36fcfb15d44705d17efa93 (diff) |
fix vtable null termination with indexed globals
-rw-r--r-- | src/jsifier.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 9c180652..714bd33c 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -264,7 +264,7 @@ function JSify(data, functionsOnly, givenFunctions) { } else { var constant = null; var allocator = (BUILD_AS_SHARED_LIB && !item.external) ? 'ALLOC_NORMAL' : 'ALLOC_STATIC'; - var index = null; + var index = 0; if (item.external && BUILD_AS_SHARED_LIB) { // External variables in shared libraries should not be declared as // they would shadow similarly-named globals in the parent. @@ -328,7 +328,7 @@ function JSify(data, functionsOnly, givenFunctions) { // Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations if (item.ident.substr(0, 5) == '__ZTV') { - js += '\n' + makePointer('[0]', null, allocator, ['void*'], index) + ';'; + js += '\n' + makePointer('[0]', null, allocator, ['void*'], getFastValue(index, '+', Runtime.alignMemory(calcAllocatedSize(Variables.globals[item.ident].type)))) + ';'; } if (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS)) { js += '\nModule["' + item.ident + '"] = ' + item.ident + ';'; |