検索
AND検索
OR検索
トップ
|
リロード
|
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
ws_010_stack をテンプレートにして作成
メニュー
簡易掲示板
LINK集
y.tackの公式BBSブックマーク
practice room
?
最新の20件
2022-10-09
多角形の内外判定
2021-05-19
RecentDeleted
2018-08-01
FrontPage
文字列型変数管理サブルーチン
GAME作成システム
2018-07-31
double型変数管理サブルーチン
int型変数管理サブルーチン
2018-07-21
GUIとメイン分割処理。たたき台2
2018-07-11
memo
NO_579_sample
GUIとメイン分割処理。たたき台
2018-06-28
NO_714
NO_712
NO_706
NO_705
NO_704
NO_703
NO_702
2018-06-23
Shift_JIS
モートン番号テーブル化 / 八分木
total
0
today
0
yesterday
0
now
1
Menu
Total:0/Today:0
開始行:
[[white_space]]
*white_space企画の現状 stackモジュール ver 0.1.1[#mc04b0...
#ifndef _MY_WS_DEFINE_
#define _MY_WS_DEFINE_
#define STACK_MEMBERS 1024
#define HEAP_MEMBERS 1024
#define MAX_LABELS 200
#define MAX_LABEL_LENGTH 500
#define MAX_INSTRUCTIONS 24
#define MAX_INSTRUCTION_LENGTH 5
#define MAX_NESTED_SUBROUTINES 20
#endif
//struct stack_model {
// long size;
// long current;
// long long* contents;
//} stack;
#module stack_model stack_size,stack_current,stack_conte...
#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_mode...
loop
#endif
//bool create_stack(void)
//{
// if (stack.contents = (long long*)calloc(STACK_MEMBERS...
// stack.size = STACK_MEMBERS;
// stack.current = STACK_MEMBERS;
// return true;
// }
// return false;
//}
#module
#deffunc create_stack
repeat STACK_MEMBERS
set_contents@stack_model stack@,0,cnt
loop
set_size@stack_model stack@,STACK_MEMBERS@
set_current@stack_model stack@,STACK_MEMBERS@
return 1
#global
#if 1
create_stack
#endif
//bool stack_push(long long val)
//{
// if (stack.current >= 1) {
// stack.current--;
// stack.contents[stack.current] = val;
// return true;
// }
// return false;
//}
#module
#defcfunc stack_push int p_val,local loc_cur
loc_cur=get_current@stack_model(stack@)
if loc_cur >= 1{
loc_cur--
set_current@stack_model stack@,loc_cur
set_contents@stack_model stack@,p_val,loc_cur
return 1
}
return 0
#global
#if 1
logmes ""+stack_push(10)
logmes ""+stack_push(20)
logmes ""+stack_push(30)
#endif
//long long stack_pop(void)
//{
// if (stack.current < stack.size) {
// stack.current++;
// return stack.contents[stack.current - 1];
// }
// return 0;
//}
#module
#defcfunc stack_pop local loc_cur,local loc_size
loc_cur = get_current@stack_model(stack@)
loc_size = get_size@stack_model(stack@)
if loc_cur < loc_size{
loc_cur++
set_current@stack_model stack@,loc_cur
loc_cur--
return get_contents@stack_model(stack@,loc_cur)
}
return 0
#global
#if 1
logmes "pop 1 :"+stack_pop()
logmes "pop 2 :"+stack_pop()
logmes "pop 3 :"+stack_pop()
#endif
//long long stack_peak(int depth)
//{
// if ((stack.current + depth) < stack.size) {
// return stack.contents[stack.current + depth];
// }
// return 0;
//}
#module
#defcfunc stack_peak int p_depth , local loc_cur , local...
loc_cur = get_current@stack_model(stack@)
loc_cur_b = loc_cur + p_depth
loc_size = get_size@stack_model(stack@)
if loc_cur_b < loc_size {
return get_contents@stack_model(stack@,loc_cur_b)
}
return 0
#global
#if 1
logmes ""+stack_push(10)
logmes ""+stack_push(20)
logmes ""+stack_push(30)
logmes "peak 2 : "+stack_peak(2)
logmes "peak 1 : "+stack_peak(1)
logmes "peak 0 : "+stack_peak(0)
#endif
//void cleanup_stack(void)
//{
// free (stack.contents);
// return;
//}
// stackは配列表現にしてあるので何もしなくてもたぶんOKw
#module
#deffunc cleanup_stack
return
#global
#if 1
cleanup_stack
#endif
終了行:
[[white_space]]
*white_space企画の現状 stackモジュール ver 0.1.1[#mc04b0...
#ifndef _MY_WS_DEFINE_
#define _MY_WS_DEFINE_
#define STACK_MEMBERS 1024
#define HEAP_MEMBERS 1024
#define MAX_LABELS 200
#define MAX_LABEL_LENGTH 500
#define MAX_INSTRUCTIONS 24
#define MAX_INSTRUCTION_LENGTH 5
#define MAX_NESTED_SUBROUTINES 20
#endif
//struct stack_model {
// long size;
// long current;
// long long* contents;
//} stack;
#module stack_model stack_size,stack_current,stack_conte...
#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_mode...
loop
#endif
//bool create_stack(void)
//{
// if (stack.contents = (long long*)calloc(STACK_MEMBERS...
// stack.size = STACK_MEMBERS;
// stack.current = STACK_MEMBERS;
// return true;
// }
// return false;
//}
#module
#deffunc create_stack
repeat STACK_MEMBERS
set_contents@stack_model stack@,0,cnt
loop
set_size@stack_model stack@,STACK_MEMBERS@
set_current@stack_model stack@,STACK_MEMBERS@
return 1
#global
#if 1
create_stack
#endif
//bool stack_push(long long val)
//{
// if (stack.current >= 1) {
// stack.current--;
// stack.contents[stack.current] = val;
// return true;
// }
// return false;
//}
#module
#defcfunc stack_push int p_val,local loc_cur
loc_cur=get_current@stack_model(stack@)
if loc_cur >= 1{
loc_cur--
set_current@stack_model stack@,loc_cur
set_contents@stack_model stack@,p_val,loc_cur
return 1
}
return 0
#global
#if 1
logmes ""+stack_push(10)
logmes ""+stack_push(20)
logmes ""+stack_push(30)
#endif
//long long stack_pop(void)
//{
// if (stack.current < stack.size) {
// stack.current++;
// return stack.contents[stack.current - 1];
// }
// return 0;
//}
#module
#defcfunc stack_pop local loc_cur,local loc_size
loc_cur = get_current@stack_model(stack@)
loc_size = get_size@stack_model(stack@)
if loc_cur < loc_size{
loc_cur++
set_current@stack_model stack@,loc_cur
loc_cur--
return get_contents@stack_model(stack@,loc_cur)
}
return 0
#global
#if 1
logmes "pop 1 :"+stack_pop()
logmes "pop 2 :"+stack_pop()
logmes "pop 3 :"+stack_pop()
#endif
//long long stack_peak(int depth)
//{
// if ((stack.current + depth) < stack.size) {
// return stack.contents[stack.current + depth];
// }
// return 0;
//}
#module
#defcfunc stack_peak int p_depth , local loc_cur , local...
loc_cur = get_current@stack_model(stack@)
loc_cur_b = loc_cur + p_depth
loc_size = get_size@stack_model(stack@)
if loc_cur_b < loc_size {
return get_contents@stack_model(stack@,loc_cur_b)
}
return 0
#global
#if 1
logmes ""+stack_push(10)
logmes ""+stack_push(20)
logmes ""+stack_push(30)
logmes "peak 2 : "+stack_peak(2)
logmes "peak 1 : "+stack_peak(1)
logmes "peak 0 : "+stack_peak(0)
#endif
//void cleanup_stack(void)
//{
// free (stack.contents);
// return;
//}
// stackは配列表現にしてあるので何もしなくてもたぶんOKw
#module
#deffunc cleanup_stack
return
#global
#if 1
cleanup_stack
#endif
ページ名: