integer test_x360 array B_nextFree962 integer B_firstFree115 integer B_maxIndex165 array B_typeId214 integer test_x360 = 2 integer B_firstFree115 = 0 integer B_maxIndex165 = 0 function initGlobals138() { B_firstFree_115 = 0; B_maxIndex_165 = 0; } function main274() { initGlobals138(); init_test398(); } function config219() { } function init_test398() { local integer a185 test_x_360 = 2; a_185 = new_X109(); dispatch_B_destroyB630(a_185); if (test_x_360 == 6) { testSuccess115(); } else { }; } IS_NATIVE function testSuccess115() { } function destroyA393(integer this158) { A_onDestroy120(this_158); dealloc_A114(this_158); } function A_init193(integer this872) { } function construct_A315(integer this482) { construct_B207(this_482); A_init193(this_482); } function A_onDestroy120(integer this175) { test_x_360 = (test_x_360 + 1); B_onDestroy486(this_175); } function B_init201(integer this166) { } function construct_B207(integer this685) { B_init201(this_685); } function B_onDestroy486(integer this183) { test_x_360 = (test_x_360 * 2); } function destroyB174(integer this671) { B_onDestroy486(this_671); dealloc_B190(this_671); } function destroyX101(integer this834) { X_onDestroy112(this_834); dealloc_X193(this_834); } function X_init209(integer this142) { } function new_X109() returns integer { local integer this194 this_194 = alloc_X273(); construct_X133(this_194); return this_194; } function construct_X133(integer this110) { construct_A315(this_110); X_init209(this_110); } function X_onDestroy112(integer this115) { A_onDestroy120(this_115); } function error157(string msg142) { $debugPrint212((msg_142 + (" " + #getStackTrace()))); } function dealloc_A114(integer obj493) { if (B_typeId_214[obj_493] == 0) { error157("Double free: object of type A"); } else { B_nextFree_962[B_firstFree_115] = obj_493; B_firstFree_115 = (B_firstFree_115 + 1); B_typeId_214[obj_493] = 0; }; } function dealloc_B190(integer obj205) { if (B_typeId_214[obj_205] == 0) { error157("Double free: object of type B"); } else { B_nextFree_962[B_firstFree_115] = obj_205; B_firstFree_115 = (B_firstFree_115 + 1); B_typeId_214[obj_205] = 0; }; } function alloc_X273() returns integer { local integer this174 if (B_firstFree_115 == 0) { if (B_maxIndex_165 < 32768) { B_maxIndex_165 = (B_maxIndex_165 + 1); this_174 = B_maxIndex_165; B_typeId_214[this_174] = 3; } else { error157("Out of memory: Could not create X."); this_174 = 0; }; } else { B_firstFree_115 = (B_firstFree_115 - 1); this_174 = B_nextFree_962[B_firstFree_115]; B_typeId_214[this_174] = 3; }; return this_174; } function dealloc_X193(integer obj160) { if (B_typeId_214[obj_160] == 0) { error157("Double free: object of type X"); } else { B_nextFree_962[B_firstFree_115] = obj_160; B_firstFree_115 = (B_firstFree_115 + 1); B_typeId_214[obj_160] = 0; }; } function dispatch_B_destroyB630(integer this212) { if (B_typeId_214[this_212] == 0) { if (this_212 == 0) { error157("Nullpointer exception when calling B.B"); } else { error157("Called B.B on invalid object."); }; } else { }; if (B_typeId_214[this_212] <= 2) { if (B_typeId_214[this_212] <= 1) { destroyB174(this_212); } else { destroyA393(this_212); }; } else { destroyX101(this_212); }; }