// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals string array test_s integer test_s_max=0 integer array FoldClosure_nextFree integer FoldClosure_firstFree=0 integer FoldClosure_maxIndex=0 integer array FoldClosure_typeId integer array LinkedList_nextFree integer LinkedList_firstFree=0 integer LinkedList_maxIndex=0 integer array LinkedList_typeId integer array LinkedList_x endglobals native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function alloc_FoldClosure_foldl_LinkedList_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] = 2 else call error("Out of memory: Could not create FoldClosure_foldl_LinkedList_test.") set this = 0 endif else set FoldClosure_firstFree = FoldClosure_firstFree - 1 set this = FoldClosure_nextFree[FoldClosure_firstFree] set FoldClosure_typeId[this] = 2 endif return this endfunction function run_foldl_LinkedList_test takes integer this, integer i, string q returns string return q + I2S(i) + "," endfunction function stringFromIndex takes integer i returns string return test_s[i] endfunction function stringToIndex takes string b returns integer set test_s_max = test_s_max + 1 set test_s[test_s_max] = b return test_s_max endfunction function run_wrapper takes integer this, integer t, integer q returns integer return stringToIndex(run_foldl_LinkedList_test(this, t, stringFromIndex(q))) endfunction function dispatch_FoldClosure_test_FoldClosure_run takes integer this, integer t, integer q returns integer if FoldClosure_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling FoldClosure.run") else call error("Called FoldClosure.run on invalid object.") endif endif return run_wrapper(this, t, q) endfunction function LinkedList_foldl takes integer this, integer startValue, integer predicate returns integer return dispatch_FoldClosure_test_FoldClosure_run(predicate, LinkedList_x[this], startValue) endfunction function dispatch_LinkedList_test_LinkedList_foldl takes integer this, integer startValue, integer predicate returns integer if LinkedList_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling LinkedList.foldl") else call error("Called LinkedList.foldl on invalid object.") endif endif return LinkedList_foldl(this, startValue, predicate) endfunction function LinkedList_toString takes integer this returns string return stringFromIndex(dispatch_LinkedList_test_LinkedList_foldl(this, stringToIndex("["), alloc_FoldClosure_foldl_LinkedList_test())) + "]" endfunction function dispatch_LinkedList_test_LinkedList_toString takes integer this returns string if LinkedList_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling LinkedList.toString") else call error("Called LinkedList.toString on invalid object.") endif endif return LinkedList_toString(this) endfunction function alloc_LinkedList takes nothing returns integer local integer this if LinkedList_firstFree == 0 then if LinkedList_maxIndex < 32768 then set LinkedList_maxIndex = LinkedList_maxIndex + 1 set this = LinkedList_maxIndex set LinkedList_typeId[this] = 3 else call error("Out of memory: Could not create LinkedList.") set this = 0 endif else set LinkedList_firstFree = LinkedList_firstFree - 1 set this = LinkedList_nextFree[LinkedList_firstFree] set LinkedList_typeId[this] = 3 endif return this endfunction function LinkedList_init takes integer this returns nothing endfunction function construct_LinkedList takes integer this returns nothing call LinkedList_init(this) endfunction function new_LinkedList takes nothing returns integer local integer this = alloc_LinkedList() call construct_LinkedList(this) return this endfunction function init_test takes nothing returns nothing local integer x set test_s_max = -1 set x = new_LinkedList() set LinkedList_x[x] = 5 if dispatch_LinkedList_test_LinkedList_toString(x) == "[5,]" then call testSuccess() endif endfunction function main takes nothing returns nothing call initGlobals() call init_test() endfunction function config takes nothing returns nothing endfunction