+added an _ONCOND macro.

This commit is contained in:
Wang Renxin 2017-11-20 13:59:18 +08:00
parent 4b75e2ae16
commit 246348777d
3 changed files with 13 additions and 5 deletions

View File

@ -1 +1 @@
theme: jekyll-theme-architect
theme: jekyll-theme-architect

View File

@ -1343,6 +1343,10 @@ static int mb_uu_substr(const char* ch, int begin, int count, char** o);
/** Expression processing */
#ifndef _ONCOND
# define _ONCOND(__s, __o, __v) do { ((void)(__s)); ((void)(__o)); ((void)(__v)); } while(0)
#endif /* _ONCOND */
static bool_t _is_operator(mb_func_t op);
static bool_t _is_flow(mb_func_t op);
static bool_t _is_unary(mb_func_t op);
@ -15110,6 +15114,7 @@ static int _core_not(mb_interpreter_t* s, void** l) {
mb_check(mb_attempt_func_end(s, l));
}
_ONCOND(s, 0, &arg);
switch(arg.type) {
case MB_DT_NIL:
@ -15535,6 +15540,7 @@ static int _core_if(mb_interpreter_t* s, void** l) {
_elseif:
_MAKE_NIL(val);
result = _calc_expression(s, &ast, &val);
_ONCOND(s, val, 0);
if(result != MB_FUNC_OK)
goto _exit;
@ -15819,6 +15825,7 @@ _loop_begin:
ast = loop_begin_node;
result = _calc_expression(s, &ast, &loop_cond_ptr);
_ONCOND(s, loop_cond_ptr, 0);
if(result != MB_FUNC_OK)
goto _exit;
@ -15932,6 +15939,7 @@ _loop_begin:
ast = ast->next;
result = _calc_expression(s, &ast, &loop_cond_ptr);
_ONCOND(s, loop_cond_ptr, 0);
if(result != MB_FUNC_OK)
goto _exit;

View File

@ -97,7 +97,7 @@ extern "C" {
#define _REALLOC_INC_STEP 16
#define _NO_END(s) ((s) == MB_FUNC_OK || (s) == MB_FUNC_SUSPEND || (s) == MB_FUNC_WARNING || (s) == MB_FUNC_ERR || (s) == MB_FUNC_END)
#define _NOT_FINISHED(s) ((s) == MB_FUNC_OK || (s) == MB_FUNC_SUSPEND || (s) == MB_FUNC_WARNING || (s) == MB_FUNC_ERR || (s) == MB_FUNC_END)
static struct mb_interpreter_t* bas = 0;
@ -993,9 +993,9 @@ static void _show_help(void) {
_printf("Options:\n");
_printf(" -h - Show help information\n");
#if _USE_MEM_POOL
_printf(" -p n - Set memory pool threashold size, n is size in bytes\n");
_printf(" -p n - Set memory pool threashold, n is size in bytes\n");
#endif /* _USE_MEM_POOL */
_printf(" -f \"dirs\" - Set importing directories, separated with \";\" for more than one\n");
_printf(" -f \"dirs\" - Set importing directories, separated with \";\" with more than one\n");
_printf("\n");
_printf("Interactive commands:\n");
_printf(" HELP - View help information\n");
@ -1585,7 +1585,7 @@ int main(int argc, char* argv[]) {
_show_tip();
do {
status = _do_line();
} while(_NO_END(status));
} while(_NOT_FINISHED(status));
}
return 0;