// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals integer array Func_nextFree integer Func_firstFree=0 integer Func_maxIndex=0 integer array Func_typeId integer array C_nextFree integer C_firstFree=0 integer C_maxIndex=0 integer array C_typeId integer array C_x endglobals native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing set Func_firstFree = 0 set Func_maxIndex = 0 set C_firstFree = 0 set C_maxIndex = 0 endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function alloc_Func_map_A takes nothing returns integer local integer this if Func_firstFree == 0 then if Func_maxIndex < 32768 then set Func_maxIndex = Func_maxIndex + 1 set this = Func_maxIndex set Func_typeId[this] = 3 else call error("Out of memory: Could not create Func_map_A.") set this = 0 endif else set Func_firstFree = Func_firstFree - 1 set this = Func_nextFree[Func_firstFree] set Func_typeId[this] = 3 endif return this endfunction function apply_map_A takes integer this, integer x returns integer return 2 * x endfunction function dispatch_Func_A_Func_apply takes integer this, integer x returns integer local integer A_Func_apply_result if Func_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling Func.apply") else call error("Called Func.apply on invalid object.") endif endif set A_Func_apply_result = apply_map_A(this, x) return A_Func_apply_result endfunction function alloc_C takes nothing returns integer local integer this if C_firstFree == 0 then if C_maxIndex < 32768 then set C_maxIndex = C_maxIndex + 1 set this = C_maxIndex set C_typeId[this] = 1 else call error("Out of memory: Could not create C.") set this = 0 endif else set C_firstFree = C_firstFree - 1 set this = C_nextFree[C_firstFree] set C_typeId[this] = 1 endif return this endfunction function C_init takes integer this returns nothing endfunction function construct_C takes integer this, integer x returns nothing call C_init(this) set C_x[this] = x endfunction function new_C takes integer x returns integer local integer this = alloc_C() call construct_C(this, x) return this endfunction function C_map takes integer this, integer f returns integer return new_C(dispatch_Func_A_Func_apply(f, C_x[this])) endfunction function dispatch_C_A_C_map takes integer this, integer f returns integer local integer A_C_map_result if C_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling C.map") else call error("Called C.map on invalid object.") endif endif set A_C_map_result = C_map(this, f) return A_C_map_result endfunction function init_A takes nothing returns nothing local integer a = new_C(5) local integer temp = a local integer clVar = alloc_Func_map_A() local integer b = dispatch_C_A_C_map(temp, clVar) if C_x[b] == 10 then call testSuccess() endif endfunction function main takes nothing returns nothing call initGlobals() call init_A() endfunction function config takes nothing returns nothing endfunction