// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals string test_s=null integer array T_nextFree integer T_firstFree=0 integer T_maxIndex=0 integer array T_typeId endglobals native testSuccess takes nothing returns nothing function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function destroyB takes integer this returns nothing local integer obj set test_s = test_s + "B" set obj = this if T_typeId[obj] == 0 then call error("Double free: object of type B") else set T_nextFree[T_firstFree] = obj set T_firstFree = T_firstFree + 1 set T_typeId[obj] = 0 endif endfunction function dispatch_T_destroyT takes integer this returns nothing local integer this_1 local integer obj if T_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling T.T") else call error("Called T.T on invalid object.") endif endif if T_typeId[this] <= 2 then set this_1 = this set obj = this_1 if T_typeId[obj] == 0 then call error("Double free: object of type T") else set T_nextFree[T_firstFree] = obj set T_firstFree = T_firstFree + 1 set T_typeId[obj] = 0 endif else call destroyB(this) endif endfunction function initGlobals takes nothing returns nothing endfunction function new_A takes nothing returns integer local integer this local integer this_1 if T_firstFree == 0 then if T_maxIndex < 32768 then set T_maxIndex = T_maxIndex + 1 set this_1 = T_maxIndex set T_typeId[this_1] = 2 else call error("Out of memory: Could not create A.") set this_1 = 0 endif else set T_firstFree = T_firstFree - 1 set this_1 = T_nextFree[T_firstFree] set T_typeId[this_1] = 2 endif set this = this_1 return this endfunction function main takes nothing returns nothing local integer t call initGlobals() set test_s = "" set t = new_A() call dispatch_T_destroyT(t) if test_s == "" then call testSuccess() endif endfunction function config takes nothing returns nothing endfunction