先日、HSPでstackのモジュールを書いたんですけど、
なんか吉里吉里にも翻訳出来そうだったので、
やってみたら出来ました。
吉里吉里出来そうで翻訳しか出来ない疑惑w
でもこういうことやってたら、
真っ白から書けるかもってかんじ。
[iscript] var STACK_MEMBERS = 1024; var HEAP_MEMBERS = 1024; var MAX_LABELS = 200; var MAX_LABEL_LENGTH = 500; var MAX_INSTRUCTIONS = 30; var MAX_INSTRUCTION_LENGTH = 10; var MAX_NESTED_SUBROUTINES = 20; [endscript] [iscript] class Stack_Model { var m_size; var m_current; var m_contents = []; var m_big; function Stack_Model(p_size){ m_size = p_size; m_current = p_size; // どこまで代入したか記録 m_big=p_size; } function stack_push(p_val){ if (m_current >= 1) { m_current--; m_contents[m_current] = p_val; if (m_big >= m_current){ m_big=m_current; } return 1; } return -1; } function stack_pop(){ if (m_current < m_size){ m_current++; return m_contents[m_current-1]; } return 0; } function stack_peak(p_depth){ if ((m_current+p_depth) < m_size){ return m_contents[m_current + p_depth]; } return 0; } function stack_look(p_depth){ if (m_big > p_depth){ return 0; }else{ return m_contents[p_depth]; } } } [endscript] [iscript] var stack = new Stack_Model(STACK_MEMBERS); stack.stack_push(100); stack.stack_push(200); stack.stack_push(300); stack.stack_push(400); stack.stack_push(500); stack.stack_push(600); stack.stack_push(700); stack.stack_push(800); var r1=stack.stack_look(1023); var r2=stack.stack_look(1022); var r3=stack.stack_look(1021); var r4=stack.stack_look(1020); var r5=stack.stack_look(1019); var r6=stack.stack_look(1018); var r7=stack.stack_look(1017); var r8=stack.stack_look(1016); [endscript] [emb exp="r1"][r] [emb exp="r2"][r] [emb exp="r3"][r] [emb exp="r4"][r] [emb exp="r5"][r] [emb exp="r6"][r] [emb exp="r7"][r] [emb exp="r8"][r] [p][cm] [iscript] var r11=stack.stack_peak(2); var r12=stack.stack_peak(3); var r13=stack.stack_pop(); var r14=stack.stack_pop(); var r15=stack.stack_peak(2); var r16=stack.stack_peak(3); [endscript] peak 2:[emb exp="r11"][r] peak 3:[emb exp="r12"][r] pop:[emb exp="r13"][r] pop:[emb exp="r14"][r] peak 2:[emb exp="r15"][r] peak 3:[emb exp="r16"][r]