
format elfobj64

einclude "oaas.h" "oaas.oh"

#multithread unsafe
char stored_char#1
charx outvalue#1+11+1+10+1 ;#zflash.text. TextFormat\0
#                            gDynamic
char firstline=FALSE

importx "strcmp" strcmp
importx "strncmp" strncmp
importx "printf" printf
importx "sprintf" sprintf
importx "strstr" strstr

^import "new_string_get" new_string_get 1
^import "on_string_get" on_string_get 1
^import "enterframe_string_get" enterframe_string_get 1
^import "press_string_get" press_string_get 1
^import "rollover_string_get" rollover_string_get 1
^import "rollout_string_get" rollout_string_get 1
import "var_advance" var_advance
import "verbosev" verbosev

function _resolve()
	return globals.stored_char
end
function _firstline()
	return #globals.firstline
end

function solver_end(ss value,ss ?small_size)
	add value small_size
	if value#=(Nullchar)
		return #globals.outvalue
	end
	return (NULL)
end
function solver_endb(ss value,ss ?small_size)
	add value small_size
	if value#=(Nullchar)
		return ""
	end
	return (NULL)
end
function solver(ss value,ss s)
	if s=(NULL)
		ss ?v
		set v verbosev()
		if v!=(FALSE)
			call printf("postponed %s\n",value)
		end
	end
	return s
end
function solver1(ss value)
	sd ?c
	char flash_string="flash."
	set c strncmp(value,#flash_string,\.flash_string-1)
	if c=0
		add value \.flash_string-1
		char flashtext_string="text."
		set c strncmp(value,#flashtext_string,\.flashtext_string-1)
		if c=0
			add value \.flashtext_string-1
			char textformat_string="TextFormat"
			set c strcmp(value,#textformat_string) #,\.textformat_string-1)
			if c=0
				call sprintf(#globals.outvalue,"%c%s%s %s",(insert_char),#flash_string,#flashtext_string,#textformat_string)
				return #globals.outvalue ##after a strcmp. solver_end is not required
			end
		end
		char object_string="utils.Object"^
		set c strncmp(value,#object_string,\.object_string)
		if c=0
			set globals.stored_char (oreplace_char)
			callret solver_endb(value,\.object_string)
		end
	end
	return (NULL)
end
function solver2(ss value)
	sd ?c
	char class_string="Class<"^
	set c strncmp(value,#class_string,\.class_string)
	if c=0
		add value \.class_string
		call var_advance(value,#value)
		char cannotcall_string="> cannot be called"
		set c strcmp(value,#cannotcall_string,\.cannotcall_string)
		if c=0
			set globals.firstline (TRUE)
			call sprintf(#globals.outvalue,"%c",(new_char))
			return #globals.outvalue
		end
	end
	char compare_string="Int should be Bool" #with null to setFlag/return
	set c strcmp(value,#compare_string,\.compare_string)
	if c=0
		set globals.firstline (TRUE)
		call sprintf(#globals.outvalue,"%c",(compare_char)) #this is only for !comp side
		return #globals.outvalue
	end
	char align_string="String should be flash.text.TextFormatAlign"^
	set c strncmp(value,#align_string,\.align_string)
	if c=0
		call sprintf(#globals.outvalue,"%c",(align_char))
		callret solver_end(value,\.align_string)
	end
	char arrconstr_string="Too many arguments"^
	set c strncmp(value,#arrconstr_string,\.arrconstr_string)
	if c=0
		call sprintf(#globals.outvalue,"%c",(arrconstr_char))
		callret solver_end(value,\.arrconstr_string)
	end
	char vartype_string="Variable requires type-hint or initialization"^
	set c strncmp(value,#vartype_string,\.vartype_string)
	if c=0
		call sprintf(#globals.outvalue,"%cDynamic",(vartype_char))
		callret solver_end(value,\.vartype_string)
	end
	char evfunc_string="() -> Void should be Dynamic -> Void"^
	set c strncmp(value,#evfunc_string,\.evfunc_string)
	if c=0
		call sprintf(#globals.outvalue,"%c",(evfunc_char))
		callret solver_end(value,\.evfunc_string)
	end
	return (NULL)
end
function solver4(ss value)
	sd ?c
	char unex_string="Unexpected "^
	set c strncmp(value,#unex_string,\.unex_string)
	if c=0
		add value (\.unex_string)
		char main_string="main"^
		set c strncmp(value,#main_string,\.main_string)
		if c=0
			call sprintf(#globals.outvalue,"%c",(ignore_pref))
			callret solver_end(value,\.main_string)
		end
		char new_string="keyword \"new\""^
		set c strncmp(value,#new_string,\.new_string)
		if c=0
			call sprintf(#globals.outvalue,"%c",(ignore_pref))
			callret solver_end(value,\.new_string)
		end
		ss ?z
		ss cursor
		set cursor new_string_get(#z)
		set c strcmp(value,cursor,z)
		if c=0
			call sprintf(#globals.outvalue,"%c",(ignore_pref))
			return #globals.outvalue
		end
	end
	return (NULL)
end
function solver7(ss value,ss after)
	sd ?c
	if value#=(usc_pref)
		inc value
		if value#=(x_low)
			inc value
			if value#=(Nullchar)
				call sprintf(#globals.outvalue,"%c%c",(search_char),(usc_pref))
				return #globals.outvalue
			end
			return (NULL)
		end
		if value#=(y_low)
			inc value
			if value#=(Nullchar)
				call sprintf(#globals.outvalue,"%c%c",(search_char),(usc_pref))
				return #globals.outvalue
			end
			return (NULL)
		end
		char alpha_string="alpha"^
		set c strncmp(value,#alpha_string,\.alpha_string)
		if c=0
			call sprintf(#globals.outvalue,"%c",(alpha_char))
			callret solver_end(value,\.alpha_string)
		end
		return (NULL)
	end
	ss ?chr
	char var_string="attachMovie"^
	set c strncmp(value,#var_string,\.var_string)
	if c=0
		set chr solver7_var(after)
		call sprintf(#globals.outvalue,"%c",chr)
		callret solver_end(value,\.var_string)
	end
	char bfil_string="begin"^
	set c strncmp(value,#bfil_string,\.bfil_string)
	if c=0
		add value \.bfil_string
		char bfilbitmap_string="BitmapFill"^
		set c strncmp(value,#bfilbitmap_string,\.bfilbitmap_string)
		if c=0
			set globals.stored_char (fill_char)
			callret solver_endb(value,\.bfilbitmap_string)
		end
		char bfilsimple_string="Fill"^
		set c strncmp(value,#bfilsimple_string,\.bfilsimple_string)
		if c=0
			set globals.stored_char (fill_char)
			callret solver_endb(value,\.bfilsimple_string)
		end
	end
	char create_string="create"^
	set c strncmp(value,#create_string,\.create_string)
	if c=0
		add value \.create_string
		char emclip_string="EmptyMovieClip"^
		set c strncmp(value,#emclip_string,\.emclip_string)
		if c=0
			set chr solver7_var(after)
			call sprintf(#globals.outvalue,"%c",chr)
			callret solver_end(value,\.emclip_string)
		end
		char text_string="TextField"^
		set c strncmp(value,#text_string,\.text_string)
		if c=0
			call sprintf(#globals.outvalue,"%c",(text_char))
			callret solver_end(value,\.text_string)
		end
		return (NULL)
	end
	char efil_string="endFill"^
	set c strncmp(value,#efil_string,\.efil_string)
	if c=0
		set globals.stored_char (fill_char)
		callret solver_endb(value,\.efil_string)
	end
	if value#=(l_low)
		inc value
		char rect_string="ineTo"^
		set c strncmp(value,#rect_string,\.rect_string)
		if c=0
			set globals.stored_char (rect_char)
			callret solver_endb(value,\.rect_string)
		end
		char bitmap_string="oadBitmap"^
		set c strncmp(value,#bitmap_string,\.bitmap_string)
		if c=0
			call sprintf(#globals.outvalue,"%c",(bitmap_char))
			callret solver_end(value,\.bitmap_string)
		end
		return (NULL)
	end
	char stage_string="Stage"^
	set c strncmp(value,#stage_string,\.stage_string)
	if c=0
		char w=".w"^
		set c strncmp(after,#w,\.w)
		if c=0
			call sprintf(#globals.outvalue,"%cw",(search_char))
			callret solver_end(value,\.stage_string)
		end
		char h=".h"^
		set c strncmp(after,#h,\.h)
		if c=0
			call sprintf(#globals.outvalue,"%ch",(search_char))
			callret solver_end(value,\.stage_string)
		end
		return (NULL)
	end
	ss ?z
	ss cursor
	set cursor on_string_get(#z)
	set c strncmp(value,cursor,z)
	if c=0
		add value z

		set cursor enterframe_string_get(#z)
		set c strncmp(value,cursor,z)
		if c=0
			call sprintf(#globals.outvalue,"%c",(onev_char))
			callret solver_end(value,z)
		end
		set cursor press_string_get(#z)
		set c strncmp(value,cursor,z)
		if c=0
			call sprintf(#globals.outvalue,"%c",(onev_char))
			callret solver_end(value,z)
		end
		set cursor rollover_string_get(#z)
		set c strncmp(value,cursor,z)
		if c=0
			call sprintf(#globals.outvalue,"%c",(onev_char))
			callret solver_end(value,z)
		end
		set cursor rollout_string_get(#z)
		set c strncmp(value,cursor,z)
		if c=0
			call sprintf(#globals.outvalue,"%c",(onev_char))
			callret solver_end(value,z)
		end
	end
	return (NULL)
end
function solver7_var(ss after)
	ss a
	set a strstr(after,", ")
	if a=(NULL)
		return (Var_char)
	end
	return (nVar_char)
end

entryraw globals()
