// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals integer array F_nextFree integer F_firstFree=0 integer F_maxIndex=0 integer array F_typeId endglobals native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing set F_firstFree = 0 set F_maxIndex = 0 endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function alloc_F_blub_A takes nothing returns integer local integer this if F_firstFree == 0 then if F_maxIndex < 32768 then set F_maxIndex = F_maxIndex + 1 set this = F_maxIndex set F_typeId[this] = 2 else call error("Out of memory: Could not create F_blub_A.") set this = 0 endif else set F_firstFree = F_firstFree - 1 set this = F_nextFree[F_firstFree] set F_typeId[this] = 2 endif return this endfunction function apply_blub_A takes integer this, integer x returns integer return x + 1 endfunction function dispatch_F_A_F_apply takes integer this, integer x returns integer local integer A_F_apply_result if F_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling F.apply") else call error("Called F.apply on invalid object.") endif endif set A_F_apply_result = apply_blub_A(this, x) return A_F_apply_result endfunction function blub takes integer x, integer f returns integer return dispatch_F_A_F_apply(f, x) endfunction function init_A takes nothing returns nothing local integer clVar = alloc_F_blub_A() local integer x = blub(5, clVar) if x == 6 then call testSuccess() endif endfunction function main takes nothing returns nothing call initGlobals() call init_A() endfunction function config takes nothing returns nothing endfunction