// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1367 globals integer array test_b integer array Blub_nextFree integer Blub_firstFree=0 integer Blub_maxIndex=0 integer array Blub_typeId integer array Blub_x integer wurst_stack_depth=0 string array wurst_stack endglobals native testFail takes string msg returns nothing native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing endfunction function error takes string msg, string w__wurst_stackPos returns nothing local integer stacktraceIndex local integer stacktraceLimit set wurst_stack[wurst_stack_depth] = w__wurst_stackPos set wurst_stack_depth = wurst_stack_depth + 1 set w__wurst_stackPos = "" set stacktraceIndex = wurst_stack_depth set stacktraceLimit = 0 loop set stacktraceIndex = stacktraceIndex - 1 set stacktraceLimit = stacktraceLimit + 1 exitwhen stacktraceLimit > 20 or stacktraceIndex < 0 set w__wurst_stackPos = w__wurst_stackPos + "\n " + wurst_stack[stacktraceIndex] endloop call BJDebugMsg(msg + "\n" + w__wurst_stackPos) set wurst_stack_depth = wurst_stack_depth - 1 endfunction function dispatch_Blub_destroyBlub takes integer this, string w__wurst_stackPos returns nothing set wurst_stack[wurst_stack_depth] = w__wurst_stackPos set wurst_stack_depth = wurst_stack_depth + 1 if Blub_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling Blub.Blub", "when calling error in Classes_lifecycle.wurst, line 8") else call error("Called Blub.Blub on invalid object.", "when calling error in Classes_lifecycle.wurst, line 8") endif endif set wurst_stack[wurst_stack_depth] = "when calling destroyBlub in Classes_lifecycle.wurst, line 8" set wurst_stack_depth = wurst_stack_depth + 1 set wurst_stack[wurst_stack_depth] = "when calling dealloc_Blub in Classes_lifecycle.wurst, line 8" set wurst_stack_depth = wurst_stack_depth + 1 if Blub_typeId[this] == 0 then call error("Double free: object of type Blub", "when calling error in Classes_lifecycle.wurst, line 8") else set Blub_nextFree[Blub_firstFree] = this set Blub_firstFree = Blub_firstFree + 1 set Blub_typeId[this] = 0 endif set wurst_stack_depth = wurst_stack_depth - 1 - 1 - 1 endfunction function new_Blub takes integer x, string w__wurst_stackPos returns integer local integer this set wurst_stack[wurst_stack_depth] = w__wurst_stackPos set wurst_stack_depth = wurst_stack_depth + 1 set wurst_stack[wurst_stack_depth] = "when calling alloc_Blub in Classes_lifecycle.wurst, line 10" set wurst_stack_depth = wurst_stack_depth + 1 if Blub_firstFree == 0 then if Blub_maxIndex < 32768 then set Blub_maxIndex = Blub_maxIndex + 1 set this = Blub_maxIndex set Blub_typeId[this] = 1 else call error("Out of memory: Could not create Blub.", "when calling error in Classes_lifecycle.wurst, line 8") set this = 0 endif else set Blub_firstFree = Blub_firstFree - 1 set this = Blub_nextFree[Blub_firstFree] set Blub_typeId[this] = 1 endif set wurst_stack_depth = wurst_stack_depth - 1 set Blub_x[this] = x set wurst_stack_depth = wurst_stack_depth - 1 return this endfunction function init_test takes string w__wurst_stackPos returns nothing local integer i set wurst_stack[wurst_stack_depth] = w__wurst_stackPos set wurst_stack_depth = wurst_stack_depth + 1 set test_b[0] = new_Blub(0, "when calling new_Blub in Classes_lifecycle.wurst, line 19") set test_b[1] = new_Blub(1, "when calling new_Blub in Classes_lifecycle.wurst, line 20") set test_b[2] = new_Blub(2, "when calling new_Blub in Classes_lifecycle.wurst, line 21") set test_b[3] = new_Blub(3, "when calling new_Blub in Classes_lifecycle.wurst, line 22") set test_b[4] = new_Blub(4, "when calling new_Blub in Classes_lifecycle.wurst, line 23") set test_b[5] = new_Blub(5, "when calling new_Blub in Classes_lifecycle.wurst, line 24") set test_b[6] = new_Blub(6, "when calling new_Blub in Classes_lifecycle.wurst, line 25") set test_b[7] = new_Blub(7, "when calling new_Blub in Classes_lifecycle.wurst, line 26") call dispatch_Blub_destroyBlub(test_b[0], "when calling dispatch_Blub_destroyBlub in Classes_lifecycle.wurst, line 28") call dispatch_Blub_destroyBlub(test_b[6], "when calling dispatch_Blub_destroyBlub in Classes_lifecycle.wurst, line 29") call dispatch_Blub_destroyBlub(test_b[2], "when calling dispatch_Blub_destroyBlub in Classes_lifecycle.wurst, line 30") call dispatch_Blub_destroyBlub(test_b[4], "when calling dispatch_Blub_destroyBlub in Classes_lifecycle.wurst, line 31") set test_b[8] = new_Blub(8, "when calling new_Blub in Classes_lifecycle.wurst, line 35") set test_b[9] = new_Blub(9, "when calling new_Blub in Classes_lifecycle.wurst, line 36") set i = 0 loop exitwhen i >= 10 if ModuloInteger(i, 2) == 1 and Blub_x[test_b[i]] != i then call testFail("fail " + I2S(i) + ", " + I2S(Blub_x[test_b[i]])) endif set i = i + 1 endloop call testSuccess() set wurst_stack_depth = wurst_stack_depth - 1 endfunction function main takes nothing returns nothing call initGlobals() call init_test("when calling init_test in Classes_lifecycle.wurst, line 1") endfunction function config takes nothing returns nothing endfunction