// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals integer array A_nextFree integer A_firstFree=0 integer A_maxIndex=0 integer array Cell_nextFree integer Cell_firstFree=0 integer Cell_maxIndex=0 integer array Cell_typeId integer array A_x integer array Cell_x endglobals native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing set A_firstFree = 0 set A_maxIndex = 0 set Cell_firstFree = 0 set Cell_maxIndex = 0 endfunction function Cell_get takes integer this returns integer return Cell_x[this] endfunction function error takes string msg returns nothing call BJDebugMsg(msg + "\n" + "") endfunction function dispatch_Cell_test_Cell_get takes integer this returns integer local integer test_Cell_get_result if Cell_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling Cell.get") else call error("Called Cell.get on invalid object.") endif endif set test_Cell_get_result = Cell_get(this) return test_Cell_get_result endfunction function Cell_set takes integer this, integer x returns nothing set Cell_x[this] = x endfunction function dispatch_Cell_test_Cell_set takes integer this, integer x returns nothing if Cell_typeId[this] == 0 then if this == 0 then call error("Nullpointer exception when calling Cell.set") else call error("Called Cell.set on invalid object.") endif endif call Cell_set(this, x) endfunction function alloc_A takes nothing returns integer local integer this if A_firstFree == 0 then if A_maxIndex < 32768 then set A_maxIndex = A_maxIndex + 1 set this = A_maxIndex else call error("Out of memory: Could not create A.") set this = 0 endif else set A_firstFree = A_firstFree - 1 set this = A_nextFree[A_firstFree] endif return this endfunction function A_init takes integer this returns nothing set A_x[this] = 1 endfunction function construct_A takes integer this, integer x returns nothing call A_init(this) set A_x[this] = x endfunction function new_A takes integer x returns integer local integer this = alloc_A() call construct_A(this, x) return this endfunction function alloc_Cell takes nothing returns integer local integer this if Cell_firstFree == 0 then if Cell_maxIndex < 32768 then set Cell_maxIndex = Cell_maxIndex + 1 set this = Cell_maxIndex set Cell_typeId[this] = 2 else call error("Out of memory: Could not create Cell.") set this = 0 endif else set Cell_firstFree = Cell_firstFree - 1 set this = Cell_nextFree[Cell_firstFree] set Cell_typeId[this] = 2 endif return this endfunction function Cell_init takes integer this returns nothing endfunction function construct_Cell takes integer this returns nothing call Cell_init(this) endfunction function new_Cell takes nothing returns integer local integer this = alloc_Cell() call construct_Cell(this) return this endfunction function init_test takes nothing returns nothing local integer a = new_A(42) local integer c = new_Cell() call dispatch_Cell_test_Cell_set(c, a) if A_x[dispatch_Cell_test_Cell_get(c)] == 42 then call testSuccess() endif endfunction function main takes nothing returns nothing call initGlobals() call init_test() endfunction function config takes nothing returns nothing endfunction