string test_s188 array C_nextFree727 integer C_firstFree157 integer C_maxIndex436 array C_typeId110 string test_s188 = "" integer C_firstFree157 = 0 integer C_maxIndex436 = 0 function initGlobals172() { C_firstFree_157 = 0; C_maxIndex_436 = 0; } function main180() { initGlobals172(); init_test187(); } function config117() { } function init_test187() { local integer c307 test_s_188 = ""; c_307 = new_C202(); dispatch_C_destroyC145(c_307); if (test_s_188 != "ABCcba") { testFail410(("fail, result = " + test_s_188)); } else { }; testSuccess258(); } IS_NATIVE function testFail410(string msg172) { } IS_NATIVE function testSuccess258() { } function C_init110(integer this120) { construct_C_B840(this_120); } function construct_C_B840(integer this173) { local string x581 construct_C_B_A459(this_173); x_581 = "B"; test_s_188 = (test_s_188 + x_581); } function construct_C_B_A459(integer this946) { local string x102 x_102 = "A"; test_s_188 = (test_s_188 + x_102); } function new_C202() returns integer { local integer this114 this_114 = alloc_C199(); construct_C112(this_114); return this_114; } function construct_C112(integer this118) { C_init110(this_118); test_s_188 = (test_s_188 + "C"); } function C_onDestroy158(integer this157) { test_s_188 = (test_s_188 + "c"); test_s_188 = (test_s_188 + "b"); test_s_188 = (test_s_188 + "a"); } function destroyC410(integer this121) { C_onDestroy158(this_121); dealloc_C191(this_121); } function alloc_C199() returns integer { local integer this778 if (C_firstFree_157 == 0) { if (C_maxIndex_436 < 32768) { C_maxIndex_436 = (C_maxIndex_436 + 1); this_778 = C_maxIndex_436; C_typeId_110[this_778] = 1; } else { error108("Out of memory: Could not create C."); this_778 = 0; }; } else { C_firstFree_157 = (C_firstFree_157 - 1); this_778 = C_nextFree_727[C_firstFree_157]; C_typeId_110[this_778] = 1; }; return this_778; } function error108(string msg155) { $debugPrint324((msg_155 + (" " + #getStackTrace()))); } function dealloc_C191(integer obj213) { if (C_typeId_110[obj_213] == 0) { error108("Double free: object of type C"); } else { C_nextFree_727[C_firstFree_157] = obj_213; C_firstFree_157 = (C_firstFree_157 + 1); C_typeId_110[obj_213] = 0; }; } function dispatch_C_destroyC145(integer this277) { if (C_typeId_110[this_277] == 0) { if (this_277 == 0) { error108("Nullpointer exception when calling C.C"); } else { error108("Called C.C on invalid object."); }; } else { }; destroyC410(this_277); }