white_space

white_space企画の現状 stackモジュール

なんか久しぶりに使おうとしたら バグあるあるっぽいっす

//struct stack_model {
//	long size;
//	long current;
//	long long* contents;
//} stack;

#module stack_model stack_size,stack_current,stack_contents
#modinit
	stack_size = 0
	stack_current = 0
	dim stack_contents,STACK_MEMBERS@
	return
#modfunc local set_size int p_int
	stack_size = p_int
	return
#modfunc local set_current int p_int
	stack_current = p_int
	return
#modfunc local set_contents int p_value,int p_index
	stack_contents.p_index = p_value
	return
#modcfunc local get_size
	return stack_size
#modcfunc local get_current
	return stack_current
#modcfunc local get_contents int p_index
	tmp_index=STACK_MEMBERS@
	if p_index >=STACK_MEMBERS@{tmp_index=STACK_MEMBERS@-1}
;	logmes ""+STACK_MEMBERS@+" "+p_index
	return stack_contents.p_index
#global
newmod stack,stack_model
#if 1
set_size@stack_model stack,20
set_current@stack_model stack,5
repeat 5
set_contents@stack_model stack,cnt*2,cnt
loop

logmes "stack size:"+get_size@stack_model(stack)
logmes "stack current:"+get_current@stack_model(stack)
repeat 10
logmes "stack contents "+cnt+":"+get_contents@stack_model(stack,cnt)
loop
#endif