array B_nextFree113 integer B_firstFree616 integer B_maxIndex318 array B_typeId108 integer B_firstFree616 = 0 integer B_maxIndex318 = 0 function initGlobals157() { B_firstFree_616 = 0; B_maxIndex_318 = 0; } function main170() { initGlobals157(); init_test184(); } function config189() { } function init_test184() { local integer x1104 local integer x2949 local integer x3194 local integer x4440 x1_104 = new_C182(); x2_949 = new_D198(); x3_194 = new_C182(); x4_440 = new_D198(); if (dispatch_A_test_A_foo915(x1_104) != 1) { testFail738("1"); } else { }; if (dispatch_A_test_A_foo915(x2_949) != 2) { testFail738("2"); } else { }; if (dispatch_B_test_B_bar196(x3_194) != 3) { testFail738("3"); } else { }; if (dispatch_B_test_B_bar196(x4_440) != 4) { testFail738("4"); } else { }; testSuccess132(); } IS_NATIVE function testFail738(string s213) { } IS_NATIVE function testSuccess132() { } function C_foo188(integer this783) returns integer { return 1; } function C_bar809(integer this133) returns integer { return 3; } function C_init144(integer this182) { } function new_C182() returns integer { local integer this899 this_899 = alloc_C100(); construct_C209(this_899); return this_899; } function construct_C209(integer this170) { C_init144(this_170); } function D_foo394(integer this762) returns integer { return 2; } function D_bar119(integer this108) returns integer { return 4; } function D_init141(integer this249) { } function new_D198() returns integer { local integer this881 this_881 = alloc_D200(); construct_D158(this_881); return this_881; } function construct_D158(integer this168) { D_init141(this_168); } function error435(string msg970) { $debugPrint595((msg_970 + (" " + #getStackTrace()))); } function alloc_C100() returns integer { local integer this101 if (B_firstFree_616 == 0) { if (B_maxIndex_318 < 32768) { B_maxIndex_318 = (B_maxIndex_318 + 1); this_101 = B_maxIndex_318; B_typeId_108[this_101] = 2; } else { error435("Out of memory: Could not create C."); this_101 = 0; }; } else { B_firstFree_616 = (B_firstFree_616 - 1); this_101 = B_nextFree_113[B_firstFree_616]; B_typeId_108[this_101] = 2; }; return this_101; } function alloc_D200() returns integer { local integer this118 if (B_firstFree_616 == 0) { if (B_maxIndex_318 < 32768) { B_maxIndex_318 = (B_maxIndex_318 + 1); this_118 = B_maxIndex_318; B_typeId_108[this_118] = 3; } else { error435("Out of memory: Could not create D."); this_118 = 0; }; } else { B_firstFree_616 = (B_firstFree_616 - 1); this_118 = B_nextFree_113[B_firstFree_616]; B_typeId_108[this_118] = 3; }; return this_118; } function dispatch_A_test_A_foo915(integer this133) returns integer { local integer test_A_foo_result146 if (B_typeId_108[this_133] == 0) { if (this_133 == 0) { error435("Nullpointer exception when calling A.foo"); } else { error435("Called A.foo on invalid object."); }; } else { }; if (B_typeId_108[this_133] <= 2) { test_A_foo_result_146 = C_foo188(this_133); } else { test_A_foo_result_146 = D_foo394(this_133); }; return test_A_foo_result_146; } function dispatch_B_test_B_bar196(integer this209) returns integer { local integer test_B_bar_result284 if (B_typeId_108[this_209] == 0) { if (this_209 == 0) { error435("Nullpointer exception when calling B.bar"); } else { error435("Called B.bar on invalid object."); }; } else { }; if (B_typeId_108[this_209] <= 2) { test_B_bar_result_284 = C_bar809(this_209); } else { test_B_bar_result_284 = D_bar119(this_209); }; return test_B_bar_result_284; }