// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1366 globals integer array IntList_elements integer array IntList_nextFree integer IntList_firstFree=0 integer IntList_maxIndex=0 integer array IntList_typeId integer array IntListIterator_nextFree integer IntListIterator_firstFree=0 integer IntListIterator_maxIndex=0 integer array IntListIterator_typeId integer array IntList_size integer array IntListIterator_list integer array IntListIterator_pos 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 dispatch_IntListIterator_destroyIntListIterator takes integer this returns nothing local integer this_1 local integer obj if IntListIterator_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling IntListIterator.IntListIterator") else call error("Called IntListIterator.IntListIterator on invalid object.") endif endif set this_1 = this set obj = this_1 if IntListIterator_typeId[obj] == 0 then call error("Double free: object of type IntListIterator") else set IntListIterator_nextFree[IntListIterator_firstFree] = obj set IntListIterator_firstFree = IntListIterator_firstFree + 1 set IntListIterator_typeId[obj] = 0 endif endfunction function dispatch_IntList_test_IntList_add takes integer this, integer x returns integer local integer test_IntList_add_result local integer this_1 local integer x_1 local integer this_2 local integer test_IntList_getOffset_result local integer this_3 if IntList_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling IntList.add") else call error("Called IntList.add on invalid object.") endif endif set this_1 = this set x_1 = x set this_2 = this_1 if IntList_typeId[this_2] == 0 then if this_2 == 0 then call error("Nullpointer exception when calling IntList.getOffset") else call error("Called IntList.getOffset on invalid object.") endif endif set this_3 = this_2 set test_IntList_getOffset_result = 64 * (this_3 - 1) set IntList_elements[test_IntList_getOffset_result + IntList_size[this_1]] = x_1 set IntList_size[this_1] = IntList_size[this_1] + 1 set test_IntList_add_result = this_1 return test_IntList_add_result endfunction function dispatch_IntList_test_IntList_get takes integer this, integer i returns integer local integer test_IntList_get_result local integer this_1 local integer i_1 local integer this_2 local integer test_IntList_getOffset_result local integer this_3 if IntList_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling IntList.get") else call error("Called IntList.get on invalid object.") endif endif set this_1 = this set i_1 = i set this_2 = this_1 if IntList_typeId[this_2] == 0 then if this_2 == 0 then call error("Nullpointer exception when calling IntList.getOffset") else call error("Called IntList.getOffset on invalid object.") endif endif set this_3 = this_2 set test_IntList_getOffset_result = 64 * (this_3 - 1) set test_IntList_get_result = IntList_elements[test_IntList_getOffset_result + i_1] return test_IntList_get_result endfunction function new_IntList takes nothing returns integer local integer this local integer this_1 local integer this_2 local integer this_3 if IntList_firstFree == 0 then if IntList_maxIndex < 32768 then set IntList_maxIndex = IntList_maxIndex + 1 set this_1 = IntList_maxIndex set IntList_typeId[this_1] = 1 else call error("Out of memory: Could not create IntList.") set this_1 = 0 endif else set IntList_firstFree = IntList_firstFree - 1 set this_1 = IntList_nextFree[IntList_firstFree] set IntList_typeId[this_1] = 1 endif set this = this_1 set this_2 = this set this_3 = this_2 set IntList_size[this_3] = 0 return this endfunction function new_IntListIterator takes integer list returns integer local integer this local integer this_1 local integer this_2 local integer list_1 local integer this_3 if IntListIterator_firstFree == 0 then if IntListIterator_maxIndex < 32768 then set IntListIterator_maxIndex = IntListIterator_maxIndex + 1 set this_1 = IntListIterator_maxIndex set IntListIterator_typeId[this_1] = 2 else call error("Out of memory: Could not create IntListIterator.") set this_1 = 0 endif else set IntListIterator_firstFree = IntListIterator_firstFree - 1 set this_1 = IntListIterator_nextFree[IntListIterator_firstFree] set IntListIterator_typeId[this_1] = 2 endif set this = this_1 set this_2 = this set list_1 = list set this_3 = this_2 set IntListIterator_pos[this_3] = 0 set IntListIterator_list[this_2] = list_1 return this endfunction function init_test takes nothing returns nothing local integer list = dispatch_IntList_test_IntList_add(dispatch_IntList_test_IntList_add(dispatch_IntList_test_IntList_add(new_IntList(), 7), 3), 5) local integer sum = 0 local integer this = list local integer iterator = new_IntListIterator(this) local integer i local integer this_1 local integer this_2 local integer this_3 loop set this_1 = iterator exitwhen not (IntListIterator_pos[this_1] < IntList_size[IntListIterator_list[this_1]]) set this_2 = iterator set IntListIterator_pos[this_2] = IntListIterator_pos[this_2] + 1 set i = dispatch_IntList_test_IntList_get(IntListIterator_list[this_2], IntListIterator_pos[this_2] - 1) set sum = sum + i endloop set this_3 = iterator call dispatch_IntListIterator_destroyIntListIterator(this_3) if sum == 15 then call testSuccess() endif endfunction function main takes nothing returns nothing call initGlobals() call init_test() endfunction function config takes nothing returns nothing endfunction