// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 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 set D_firstFree = 0 set D_maxIndex = 0 endfunction function D_B_A_getX takes integer this returns integer call println("get x " + I2S(D_B_A_x[this])) return D_B_A_x[this] endfunction function D_C_A_getX takes integer this returns integer call println("get x " + I2S(D_C_A_x[this])) return D_C_A_x[this] endfunction function D_getX takes integer this returns integer return D_B_A_getX(this) + D_C_A_getX(this) 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 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 test_D_getX_result = D_getX(this) return test_D_getX_result endfunction function D_B_A_setX takes integer this, integer x returns nothing call println("set x " + I2S(x)) set D_B_A_x[this] = x endfunction function D_C_A_setX takes integer this, integer x returns nothing call println("set x " + I2S(x)) set D_C_A_x[this] = x endfunction function D_setX takes integer this, integer x returns nothing call D_B_A_setX(this, x / 2) call D_C_A_setX(this, x - D_B_A_getX(this)) endfunction function dispatch_D_test_D_setX takes integer this, integer x returns nothing 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) endfunction function alloc_D takes nothing returns integer local integer this if D_firstFree == 0 then if D_maxIndex < 32768 then set D_maxIndex = D_maxIndex + 1 set this = D_maxIndex set D_typeId[this] = 1 else call error("Out of memory: Could not create D.") set this = 0 endif else set D_firstFree = D_firstFree - 1 set this = D_nextFree[D_firstFree] set D_typeId[this] = 1 endif return this endfunction function construct_D_B_A takes integer this returns nothing endfunction function construct_D_B takes integer this returns nothing call construct_D_B_A(this) endfunction function construct_D_C_A takes integer this returns nothing endfunction function construct_D_C takes integer this returns nothing call construct_D_C_A(this) endfunction function D_init takes integer this returns nothing call construct_D_B(this) call construct_D_C(this) endfunction function construct_D takes integer this returns nothing call D_init(this) endfunction function new_D takes nothing returns integer local integer this = alloc_D() call construct_D(this) return this endfunction function init_test takes nothing returns nothing local integer d = new_D() call dispatch_D_test_D_setX(d, 5) 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