// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals integer array FoldClosure_nextFree integer FoldClosure_firstFree=0 integer FoldClosure_maxIndex=0 integer array FoldClosure_typeId integer array Cell_nextFree integer Cell_firstFree=0 integer Cell_maxIndex=0 integer array Cell_typeId integer array Cell_elem integer blaFromIndex_return_z=0 integer blaFromIndex_return_y=0 endglobals native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing set FoldClosure_firstFree = 0 set FoldClosure_maxIndex = 0 set Cell_firstFree = 0 set Cell_maxIndex = 0 endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function alloc_FoldClosure_fold_test takes nothing returns integer local integer this if FoldClosure_firstFree == 0 then if FoldClosure_maxIndex < 32768 then set FoldClosure_maxIndex = FoldClosure_maxIndex + 1 set this = FoldClosure_maxIndex set FoldClosure_typeId[this] = 3 else call error("Out of memory: Could not create FoldClosure_fold_test.") set this = 0 endif else set FoldClosure_firstFree = FoldClosure_firstFree - 1 set this = FoldClosure_nextFree[FoldClosure_firstFree] set FoldClosure_typeId[this] = 3 endif return this endfunction function blaToIndex takes integer b_z, integer b_y returns integer return b_z endfunction function apply_fold_test takes integer this, integer e_z, integer e_y, integer a returns integer return e_z + a endfunction function blaFromIndex takes integer i returns integer set blaFromIndex_return_z = i set blaFromIndex_return_y = 2 return blaFromIndex_return_z endfunction function apply_wrapper takes integer this, integer t, integer q returns integer return apply_fold_test(this, blaFromIndex(t), blaFromIndex_return_y, q) endfunction function dispatch_FoldClosure_test_FoldClosure_apply takes integer this, integer t, integer q returns integer local integer test_FoldClosure_apply_result if FoldClosure_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling FoldClosure.apply") else call error("Called FoldClosure.apply on invalid object.") endif endif set test_FoldClosure_apply_result = apply_wrapper(this, t, q) return test_FoldClosure_apply_result endfunction function Cell_fold takes integer this, integer start, integer f returns integer return dispatch_FoldClosure_test_FoldClosure_apply(f, Cell_elem[this], start) endfunction function dispatch_Cell_test_Cell_fold takes integer this, integer start, integer f returns integer local integer test_Cell_fold_result if Cell_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling Cell.fold") else call error("Called Cell.fold on invalid object.") endif endif set test_Cell_fold_result = Cell_fold(this, start, f) return test_Cell_fold_result endfunction function Cell_set takes integer this, integer t returns nothing set Cell_elem[this] = t endfunction function dispatch_Cell_test_Cell_set takes integer this, integer t returns nothing if Cell_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling Cell.set") else call error("Called Cell.set on invalid object.") endif endif call Cell_set(this, t) endfunction function alloc_Cell takes nothing returns integer local integer this if Cell_firstFree == 0 then if Cell_maxIndex < 32768 then set Cell_maxIndex = Cell_maxIndex + 1 set this = Cell_maxIndex set Cell_typeId[this] = 1 else call error("Out of memory: Could not create Cell.") set this = 0 endif else set Cell_firstFree = Cell_firstFree - 1 set this = Cell_nextFree[Cell_firstFree] set Cell_typeId[this] = 1 endif return this endfunction function Cell_init takes integer this returns nothing endfunction function construct_Cell takes integer this returns nothing call Cell_init(this) endfunction function new_Cell takes nothing returns integer local integer this = alloc_Cell() call construct_Cell(this) return this endfunction function init_test takes nothing returns nothing local integer c = new_Cell() local integer x local integer clVar local integer temp call dispatch_Cell_test_Cell_set(c, blaToIndex(5, 3)) set temp = c set clVar = alloc_FoldClosure_fold_test() set x = dispatch_Cell_test_Cell_fold(temp, 2, clVar) if x == 7 then call testSuccess() endif endfunction function main takes nothing returns nothing call initGlobals() call init_test() endfunction function config takes nothing returns nothing endfunction