📄 gb_code_temp.h
字号:
write_ZZxx(C_JUMP_FIRST, local);}PUBLIC void CODE_jump_next(void){ LAST_CODE; use_stack(1); #ifdef DEBUG printf("JUMP NEXT\n"); #endif write_short(C_JUMP_NEXT); /**pos = CODE_get_current_pos();*/ write_short(0);}PUBLIC void CODE_jump_length(short src, short dst){ if (src < 0 || src >= (ARRAY_count(cur_func->code) - 1)) return; /* if (dst < 0 || dst > (ARRAY_length(cur_func->code))) return; */ if (cur_func->code[src] == C_BREAK) cur_func->code[src + 2] = dst - (src + 2) - 1; else cur_func->code[src + 1] = dst - (src + 1) - 1;}PUBLIC void CODE_first(short local){ LAST_CODE; use_stack(-1); #ifdef DEBUG printf("ENUM FIRST LOCAL %d\n", local); #endif write_ZZxx(C_FIRST, local);}PUBLIC void CODE_next(bool drop){ LAST_CODE; use_stack(drop ? 0 : 1); #ifdef DEBUG printf("ENUM NEXT%s\n", drop ? " DROP" : ""); #endif write_ZZxx(C_NEXT, drop ? 1 : 0); write_short(0);}#endif /* PROJECT_COMP */PUBLIC void CODE_op(short op, short nparam, boolean fixed){ LAST_CODE; use_stack(1 - nparam); #ifdef DEBUG printf("OP %d (%d)\n", op, nparam); #endif if (fixed) write_ZZxx(op, 0); else write_ZZxx(op, nparam);}PUBLIC void CODE_push_me(bool debug){ LAST_CODE; use_stack(1); #ifdef DEBUG printf("PUSH ME\n"); #endif write_ZZxx(C_PUSH_ME, debug ? 1 : 0);}PUBLIC void CODE_push_last(){ LAST_CODE; use_stack(1); #ifdef DEBUG printf("PUSH LAST\n"); #endif write_short(C_PUSH_LAST);}PUBLIC void CODE_push_null(){ LAST_CODE; use_stack(1); #ifdef DEBUG printf("PUSH NULL\n"); #endif write_short(C_PUSH_NULL);}/*PRIVATE boolean change_last_call(ushort flag){ ushort *last_code = get_last_code(); if (!last_code) return FALSE; if ((*last_code & 0xFF00) == C_CALL) { *last_code = *last_code | flag; return TRUE; } else if ((ushort)((*last_code) & 0xFF00) >= (ushort)CODE_FIRST_SUBR) { *last_code = *last_code | flag; return TRUE; } else if (((*last_code & 0xFF00) == C_DROP) && flag == CODE_CALL_DROP) return FALSE;}*/PUBLIC void CODE_dup(void){ LAST_CODE; use_stack(1); #ifdef DEBUG printf("DUP\n"); #endif write_short(C_DUP);}PUBLIC void CODE_return(int return_value){ LAST_CODE; if (return_value) { use_stack(-1); write_ZZxx(C_RETURN, return_value); } else write_ZZxx(C_RETURN, 0); #ifdef DEBUG printf("RETURN (%d)\n", return_value ? 1 : 0); #endif}#ifdef PROJECT_COMPstatic bool _allow_break = FALSE;PUBLIC void CODE_allow_break(void){ _allow_break = TRUE;}PUBLIC void CODE_break(void){ if (!_allow_break) return; /*if (last_line < 0) { if (CODE_get_current_pos()) return; } else { if (JOB->line == last_line) return; last_line = JOB->line; }*/ #ifdef DEBUG printf("BREAK\n"); #endif write_short(C_BREAK); _allow_break = FALSE;}PUBLIC void CODE_quit(void){ LAST_CODE; #ifdef DEBUG printf("QUIT\n"); #endif write_ZZxx(C_QUIT, 0);}PUBLIC void CODE_stop(void){ LAST_CODE; #ifdef DEBUG printf("STOP\n"); #endif write_ZZxx(C_QUIT, 1);}#endif /* PROJECT_COMP */PUBLIC void CODE_push_char(char car){ LAST_CODE; use_stack(1); write_ZZxx(C_PUSH_CHAR, car); #ifdef DEBUG printf("PUSH CHAR %d\n", car); #endif}/*PUBLIC void CODE_push_zero(void){ LAST_CODE; use_stack(1); write_short(C_PUSH_ZERO); #ifdef DEBUG printf("PUSH ZERO\n"); #endif}*/PUBLIC void CODE_push_void(void){ LAST_CODE; use_stack(1); write_short(C_PUSH_VOID); #ifdef DEBUG printf("PUSH VOID\n"); #endif}#ifdef PROJECT_COMPPUBLIC void CODE_event(bool on){ LAST_CODE; write_ZZxx(C_EVENT, on ? 1 : 0); #ifdef DEBUG printf("EVENT %s\n", on ? "ON" : "OFF"); #endif}PUBLIC void CODE_stop_event(void){ LAST_CODE; write_ZZxx(C_EVENT, 2); #ifdef DEBUG printf("STOP EVENT\n"); #endif}#endifPUBLIC void CODE_subr(short subr, short nparam, short optype, boolean output, boolean fixed){ LAST_CODE; if (output) use_stack(0); else use_stack(1 - nparam); #ifdef DEBUG printf("SUBR %s %d (%d)\n", output ? "OUTPUT" : "", subr, nparam); #endif if (optype == 0) { if (fixed) nparam = 0; /*if (output) nparam |= CODE_CALL_OUTPUT;*/ } else { nparam = optype; } subr += CODE_FIRST_SUBR; write_short(((subr & 0xFF) << 8) | (nparam & 0xFF));}PUBLIC void CODE_call(short nparam, boolean output){ LAST_CODE; /* Une case de pile de moins, car la valeur de retour est stock� �la place de la fonction �appeler */ if (output) use_stack(0); else use_stack(-nparam); #ifdef DEBUG printf("CALL %s ( %d )\n", output ? "OUTPUT" : "", nparam); #endif /*if (output) nparam |= CODE_CALL_OUTPUT;*/ write_ZZxx(C_CALL, nparam);}PUBLIC void CODE_push_return(void){ LAST_CODE; use_stack(1); write_short(C_PUSH_RETURN); #ifdef DEBUG printf("PUSH RETURN\n"); #endif}#ifdef PROJECT_COMPPUBLIC void CODE_try(void){ LAST_CODE; write_short(C_TRY); write_short(0); #ifdef DEBUG printf("TRY\n"); #endif}PUBLIC void CODE_end_try(void){ LAST_CODE; write_short(C_END_TRY); #ifdef DEBUG printf("END TRY\n"); #endif}PUBLIC void CODE_catch(void){ LAST_CODE; write_short(C_CATCH); #ifdef DEBUG printf("CATCH\n"); #endif}#endifPUBLIC void CODE_drop(void){ ushort *last_code = get_last_code(); ushort subr; use_stack(-1); #ifdef DEBUG printf("DROP\n"); #endif if (last_code) { switch(*last_code & 0xFF00) { case C_DROP: *last_code = (*last_code & 0xFF00) + (*last_code & 0xFF) + 1; return; case C_CALL: *last_code |= CODE_CALL_VOID; return; case C_PUSH_RETURN: ERROR_panic("C_PUSH_RETURN ?"); remove_last(); return; default: subr = (*last_code) >> 8; if (subr >= CODE_FIRST_SUBR && subr <= CODE_LAST_SUBR && (!(*last_code & CODE_CALL_VOID))) { *last_code |= CODE_CALL_VOID; return; } } } LAST_CODE; write_ZZxx(C_DROP, 1);}PUBLIC void CODE_push_special(short spec){ LAST_CODE; use_stack(0); #ifdef DEBUG printf("PUSH SPECIAL %d\n", spec); #endif write_ZZxx(C_PUSH_SPECIAL, spec);}#ifdef PROJECT_COMPPUBLIC void CODE_push_event(short event){ LAST_CODE; use_stack(1); #ifdef DEBUG printf("PUSH EVENT %d\n", event); #endif write_ZZxx(C_PUSH_EVENT, event);}PUBLIC void CODE_new(ushort nparam, boolean array, boolean event){ LAST_CODE; use_stack(1 - nparam); #ifdef DEBUG printf("NEW %s (%d)\n", (array ? "ARRAY" : (event ? "EVENT" : "")), nparam); #endif if (array) nparam |= CODE_NEW_ARRAY; if (event) nparam |= CODE_NEW_EVENT; write_ZZxx(C_NEW, nparam);}#endifPUBLIC void CODE_push_boolean(boolean value){ LAST_CODE; use_stack(1); write_ZZxx(C_PUSH_BOOLEAN, value); #ifdef DEBUG printf("PUSH %s\n", value ? "TRUE" : "FALSE"); #endif}#ifdef CODE_DUMPPUBLIC void CODE_dump(PCODE *code){ int i; printf("\n"); for (i = 0; i < ARRAY_count(code);) i += PCODE_dump(i, &code[i]); printf("\n");}#endif/* PUBLIC void CODE_case(short local) *//* { *//* LAST_CODE; *//* *//* use_stack(0); *//* *//* #ifdef DEBUG *//* printf("CASE (%d)\n", local); *//* #endif *//* *//* write_ZZxx(C_CASE, local); *//* } */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -