// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1366 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 destroyA takes integer this returns nothing set test_s = test_s + "C" if T_typeId[this] == 0 then call error("Double free: object of type A") else set T_nextFree[T_firstFree] = this set T_firstFree = T_firstFree + 1 set T_typeId[this] = 0 endif endfunction function destroyB takes integer this returns nothing set test_s = test_s + "B" + "C" if T_typeId[this] == 0 then call error("Double free: object of type B") else set T_nextFree[T_firstFree] = this set T_firstFree = T_firstFree + 1 set T_typeId[this] = 0 endif endfunction function dispatch_T_destroyT takes integer this returns nothing 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] <= 3 then if T_typeId[this] <= 2 then call destroyA(this) else call destroyB(this) endif elseif T_typeId[this] == 0 then call error("Double free: object of type T") else set T_nextFree[T_firstFree] = this set T_firstFree = T_firstFree + 1 set T_typeId[this] = 0 endif endfunction function initGlobals takes nothing returns nothing endfunction function new_A takes nothing returns integer local integer this if T_firstFree == 0 then if T_maxIndex < 32768 then set T_maxIndex = T_maxIndex + 1 set this = T_maxIndex set T_typeId[this] = 2 else call error("Out of memory: Could not create A.") set this = 0 endif else set T_firstFree = T_firstFree - 1 set this = T_nextFree[T_firstFree] set T_typeId[this] = 2 endif return this endfunction function main takes nothing returns nothing call initGlobals() set test_s = "" call dispatch_T_destroyT(new_A()) if test_s == "C" then call testSuccess() endif endfunction function config takes nothing returns nothing endfunction