// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1367
globals
integer B_blub=0
integer array Blub_nextFree
integer Blub_firstFree=0
integer Blub_maxIndex=0
integer array Blub_typeId
integer array Blub_x
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 alloc_Blub takes nothing returns integer
	local integer this
	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.")
			set this = 0
		endif
	else
		set Blub_firstFree = Blub_firstFree - 1
		set this = Blub_nextFree[Blub_firstFree]
		set Blub_typeId[this] = 1
	endif
	return this
endfunction

function Blub_init takes integer this returns nothing
	set Blub_x[this] = 2
endfunction

function construct_Blub takes integer this returns nothing
	call Blub_init(this)
endfunction

function new_Blub takes nothing returns integer
	local integer this = alloc_Blub()
	call construct_Blub(this)
	return this
endfunction

function init_B takes nothing returns nothing
	set B_blub = new_Blub()
endfunction

function Blub_f takes integer this returns integer
	return 3
endfunction

function dispatch_Blub_A_Blub_f takes integer this returns integer
	if Blub_typeId[this] == 0 then
		if this == 0 then
			call error("Nullpointer exception when calling Blub.f")
		else
			call error("Called Blub.f on invalid object.")
		endif
	endif
	return Blub_f(this)
endfunction

function init_C takes nothing returns nothing
	if Blub_x[B_blub] == 2 and dispatch_Blub_A_Blub_f(B_blub) == 3 then
		call testSuccess()
	endif
endfunction

function main takes nothing returns nothing
	call initGlobals()
	call init_B()
	call init_C()
endfunction

function config takes nothing returns nothing
endfunction