string test_s116 array C_nextFree154 integer C_firstFree744 integer C_maxIndex448 array C_typeId100 string test_s116 = "" integer C_firstFree744 = 0 integer C_maxIndex448 = 0 function initGlobals580() { C_firstFree_744 = 0; C_maxIndex_448 = 0; } function main118() { initGlobals580(); init_test155(); } function config114() { } function init_test155() { local integer c112 test_s_116 = ""; c_112 = new_C210(); dispatch_C_destroyC133(c_112); if (test_s_116 != "ABCcba") { testFail131(("fail, result = " + test_s_116)); } else { }; testSuccess459(); } IS_NATIVE function testFail131(string msg132) { } IS_NATIVE function testSuccess459() { } function C_init174(integer this134) { construct_C_B144(this_134); } function construct_C_B144(integer this646) { local string x177 construct_C_B_A323(this_646); x_177 = "B"; test_s_116 = (test_s_116 + x_177); } function construct_C_B_A323(integer this214) { local string x965 x_965 = "A"; test_s_116 = (test_s_116 + x_965); } function new_C210() returns integer { local integer this177 this_177 = alloc_C125(); construct_C111(this_177); return this_177; } function construct_C111(integer this167) { C_init174(this_167); test_s_116 = (test_s_116 + "C"); } function C_onDestroy109(integer this963) { test_s_116 = (test_s_116 + "c"); test_s_116 = (test_s_116 + "b"); test_s_116 = (test_s_116 + "a"); } function destroyC772(integer this157) { C_onDestroy109(this_157); dealloc_C157(this_157); } function alloc_C125() returns integer { local integer this120 if (C_firstFree_744 == 0) { if (C_maxIndex_448 < 32768) { C_maxIndex_448 = (C_maxIndex_448 + 1); this_120 = C_maxIndex_448; C_typeId_100[this_120] = 1; } else { error523("Out of memory: Could not create C."); this_120 = 0; }; } else { C_firstFree_744 = (C_firstFree_744 - 1); this_120 = C_nextFree_154[C_firstFree_744]; C_typeId_100[this_120] = 1; }; return this_120; } function error523(string msg204) { $debugPrint849((msg_204 + (" " + #getStackTrace()))); } function dealloc_C157(integer obj162) { if (C_typeId_100[obj_162] == 0) { error523("Double free: object of type C"); } else { C_nextFree_154[C_firstFree_744] = obj_162; C_firstFree_744 = (C_firstFree_744 + 1); C_typeId_100[obj_162] = 0; }; } function dispatch_C_destroyC133(integer this680) { if (C_typeId_100[this_680] == 0) { if (this_680 == 0) { error523("Nullpointer exception when calling C.C"); } else { error523("Called C.C on invalid object."); }; } else { }; destroyC772(this_680); }