// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1366 globals integer array D_nextFree integer D_firstFree=0 integer D_maxIndex=0 integer array D_typeId integer array D_B_A_x integer array D_C_A_x endglobals native println takes string s returns nothing native testFail takes string msg returns nothing native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing endfunction function D_setX takes integer this, integer x returns nothing local integer this_1 = this local integer x_1 = x / 2 local integer this_2 local integer x_2 local integer this_3 local integer temp call println("set x " + I2S(x_1)) set D_B_A_x[this_1] = x_1 set this_2 = this set temp = x set this_3 = this call println("get x " + I2S(D_B_A_x[this_3])) set x_2 = temp - D_B_A_x[this_3] call println("set x " + I2S(x_2)) set D_C_A_x[this_2] = x_2 endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function dispatch_D_test_D_getX takes integer this returns integer local integer test_D_getX_result local integer this_1 local integer this_2 local integer this_3 local integer temp if D_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling D.getX") else call error("Called D.getX on invalid object.") endif endif set this_1 = this set this_2 = this_1 call println("get x " + I2S(D_B_A_x[this_2])) set temp = D_B_A_x[this_2] set this_3 = this_1 call println("get x " + I2S(D_C_A_x[this_3])) set test_D_getX_result = temp + D_C_A_x[this_3] return test_D_getX_result endfunction function new_D takes nothing returns integer local integer this local integer this_1 local integer this_2 if D_firstFree == 0 then if D_maxIndex < 32768 then set D_maxIndex = D_maxIndex + 1 set this_1 = D_maxIndex set D_typeId[this_1] = 1 else call error("Out of memory: Could not create D.") set this_1 = 0 endif else set D_firstFree = D_firstFree - 1 set this_1 = D_nextFree[D_firstFree] set D_typeId[this_1] = 1 endif set this = this_1 set this_2 = this return this endfunction function init_test takes nothing returns nothing local integer d = new_D() local integer this = d local integer x = 5 if D_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling D.setX") else call error("Called D.setX on invalid object.") endif endif call D_setX(this, x) if dispatch_D_test_D_getX(d) != 5 then call testFail("foo fail" + I2S(dispatch_D_test_D_getX(d))) endif call testSuccess() endfunction function main takes nothing returns nothing call initGlobals() call init_test() endfunction function config takes nothing returns nothing endfunction