fix vtable null termination with indexed globals

This commit is contained in:
Alon Zakai 2012-11-27 15:32:45 -08:00
Родитель 8e708a251f
Коммит cb88b99fc4
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -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 + ';';