integer test_x214 array I_nextFree139 integer I_firstFree187 integer I_maxIndex862 array I_typeId918 integer test_x214 = 0 integer I_firstFree187 = 0 integer I_maxIndex862 = 0 function initGlobals124() { I_firstFree_187 = 0; I_maxIndex_862 = 0; } function main661() { initGlobals124(); init_test179(); } function config177() { } function init_test179() { local integer i879 test_x_214 = 0; i_879 = new_C466(); dispatch_I_destroyI658(i_879); if (test_x_214 == 2) { testSuccess174(); } else { }; } IS_NATIVE function testSuccess174() { } function destroyB149(integer this141) { B_onDestroy192(this_141); dealloc_B510(this_141); } function B_onDestroy192(integer this147) { test_x_214 = 1; } function destroyC916(integer this706) { C_onDestroy190(this_706); dealloc_C204(this_706); } function C_init117(integer this543) { } function new_C466() returns integer { local integer this135 this_135 = alloc_C171(); construct_C213(this_135); return this_135; } function construct_C213(integer this150) { C_init117(this_150); } function C_onDestroy190(integer this116) { test_x_214 = 2; } function destroyI180(integer this108) { dealloc_I858(this_108); } function error160(string msg746) { $debugPrint128((msg_746 + (" " + #getStackTrace()))); } function dealloc_B510(integer obj207) { if (I_typeId_918[obj_207] == 0) { error160("Double free: object of type B"); } else { I_nextFree_139[I_firstFree_187] = obj_207; I_firstFree_187 = (I_firstFree_187 + 1); I_typeId_918[obj_207] = 0; }; } function alloc_C171() returns integer { local integer this144 if (I_firstFree_187 == 0) { if (I_maxIndex_862 < 32768) { I_maxIndex_862 = (I_maxIndex_862 + 1); this_144 = I_maxIndex_862; I_typeId_918[this_144] = 3; } else { error160("Out of memory: Could not create C."); this_144 = 0; }; } else { I_firstFree_187 = (I_firstFree_187 - 1); this_144 = I_nextFree_139[I_firstFree_187]; I_typeId_918[this_144] = 3; }; return this_144; } function dealloc_C204(integer obj166) { if (I_typeId_918[obj_166] == 0) { error160("Double free: object of type C"); } else { I_nextFree_139[I_firstFree_187] = obj_166; I_firstFree_187 = (I_firstFree_187 + 1); I_typeId_918[obj_166] = 0; }; } function dealloc_I858(integer obj991) { if (I_typeId_918[obj_991] == 0) { error160("Double free: object of type I"); } else { I_nextFree_139[I_firstFree_187] = obj_991; I_firstFree_187 = (I_firstFree_187 + 1); I_typeId_918[obj_991] = 0; }; } function dispatch_I_destroyI658(integer this206) { if (I_typeId_918[this_206] == 0) { if (this_206 == 0) { error160("Nullpointer exception when calling I.I"); } else { error160("Called I.I on invalid object."); }; } else { }; if (I_typeId_918[this_206] <= 2) { if (I_typeId_918[this_206] <= 1) { destroyI180(this_206); } else { destroyB149(this_206); }; } else { destroyC916(this_206); }; }