*polished code. -removed an assertion.

This commit is contained in:
Wang Renxin 2016-01-17 12:12:51 +08:00
parent 85dd028a38
commit 7f81719ba1
2 changed files with 16 additions and 16 deletions

View File

@ -1077,9 +1077,9 @@ static int _pop_routine_fun_arg(mb_interpreter_t* s, void** l, mb_value_t* va, u
static bool_t _is_print_terminal(mb_interpreter_t* s, _object_t* obj); static bool_t _is_print_terminal(mb_interpreter_t* s, _object_t* obj);
/** Handlers */ /** Handlers */
#define _handle_error_now(__s, __err, __func, __result) \ #define _handle_error_now(__s, __err, __f, __result) \
do { \ do { \
_set_current_error((__s), (__err), (__func)); \ _set_current_error((__s), (__err), (__f)); \
if((__s)->error_handler) { \ if((__s)->error_handler) { \
if((__s)->handled_error) break; \ if((__s)->handled_error) break; \
(__s)->handled_error = true; \ (__s)->handled_error = true; \
@ -1092,17 +1092,17 @@ static bool_t _is_print_terminal(mb_interpreter_t* s, _object_t* obj);
} \ } \
} while(0) } while(0)
#if _WARING_AS_ERROR #if _WARING_AS_ERROR
# define _handle_error(__s, __err, __func, __pos, __row, __col, __ret, __exit, __result) \ # define _handle_error(__s, __err, __f, __pos, __row, __col, __ret, __exit, __result) \
do { \ do { \
_set_current_error((__s), (__err), (__func)); \ _set_current_error((__s), (__err), (__f)); \
_set_error_pos((__s), (__pos), (__row), (__col)); \ _set_error_pos((__s), (__pos), (__row), (__col)); \
__result = (__ret); \ __result = (__ret); \
goto __exit; \ goto __exit; \
} while(0) } while(0)
#else /* _WARING_AS_ERROR */ #else /* _WARING_AS_ERROR */
# define _handle_error(__s, __err, __func, __pos, __row, __col, __ret, __exit, __result) \ # define _handle_error(__s, __err, __f, __pos, __row, __col, __ret, __exit, __result) \
do { \ do { \
_set_current_error((__s), (__err), (__func)); \ _set_current_error((__s), (__err), (__f)); \
_set_error_pos((__s), (__pos), (__row), (__col)); \ _set_error_pos((__s), (__pos), (__row), (__col)); \
if((__ret) != MB_FUNC_WARNING) { \ if((__ret) != MB_FUNC_WARNING) { \
__result = (__ret); \ __result = (__ret); \
@ -1111,16 +1111,16 @@ static bool_t _is_print_terminal(mb_interpreter_t* s, _object_t* obj);
} while(0) } while(0)
#endif /* _WARING_AS_ERROR */ #endif /* _WARING_AS_ERROR */
#ifdef MB_ENABLE_SOURCE_TRACE #ifdef MB_ENABLE_SOURCE_TRACE
# define _HANDLE_ERROR(__s, __err, __func, __obj, __ret, __exit, __result) _handle_error((__s), (__err), (__func), (__obj)->source_pos, (__obj)->source_row, (__obj)->source_col, (__ret), __exit, (__result)) # define _HANDLE_ERROR(__s, __err, __f, __obj, __ret, __exit, __result) _handle_error((__s), (__err), (__f), (__obj)->source_pos, (__obj)->source_row, (__obj)->source_col, (__ret), __exit, (__result))
#else /* MB_ENABLE_SOURCE_TRACE */ #else /* MB_ENABLE_SOURCE_TRACE */
# define _HANDLE_ERROR(__s, __err, __func, __obj, __ret, __exit, __result) _handle_error((__s), (__err), (__func), 0, 0, 0, (__ret), __exit, (__result)) # define _HANDLE_ERROR(__s, __err, __f, __obj, __ret, __exit, __result) _handle_error((__s), (__err), (__f), 0, 0, 0, (__ret), __exit, (__result))
#endif /* MB_ENABLE_SOURCE_TRACE */ #endif /* MB_ENABLE_SOURCE_TRACE */
#define _handle_error_on_obj(__s, __err, __func, __obj, __ret, __exit, __result) \ #define _handle_error_on_obj(__s, __err, __f, __obj, __ret, __exit, __result) \
do { \ do { \
if(__obj) { \ if(__obj) { \
_HANDLE_ERROR((__s), (__err), (__func), (__obj), (__ret), __exit, (__result)); \ _HANDLE_ERROR((__s), (__err), (__f), (__obj), (__ret), __exit, (__result)); \
} else { \ } else { \
_handle_error((__s), (__err), (__func), 0, 0, 0, (__ret), __exit, (__result)); \ _handle_error((__s), (__err), (__f), 0, 0, 0, (__ret), __exit, (__result)); \
} \ } \
} while(0) } while(0)
@ -3625,12 +3625,12 @@ char* _load_file(mb_interpreter_t* s, const char* f, const char* prefix) {
if(_ls_find(context->imported, (void*)f, (_ls_compare)_ht_cmp_string)) { if(_ls_find(context->imported, (void*)f, (_ls_compare)_ht_cmp_string)) {
buf = (char*)f; buf = (char*)f;
} else { } else {
buf = mb_strdup(f, strlen(f) + 1);
_ls_pushback(context->imported, buf);
buf = 0;
fp = fopen(f, "rb"); fp = fopen(f, "rb");
if(fp) { if(fp) {
buf = mb_strdup(f, strlen(f) + 1);
_ls_pushback(context->imported, buf);
buf = 0;
curpos = ftell(fp); curpos = ftell(fp);
fseek(fp, 0L, SEEK_END); fseek(fp, 0L, SEEK_END);
l = ftell(fp); l = ftell(fp);

View File

@ -554,7 +554,7 @@ static _importing_dirs_t* _set_importing_directories(char* dirs) {
static void _destroy_importing_directories(void) { static void _destroy_importing_directories(void) {
int i = 0; int i = 0;
mb_assert(importing_dirs); if(!importing_dirs) return;
for(i = 0; i < importing_dirs->count; ++i) { for(i = 0; i < importing_dirs->count; ++i) {
free(importing_dirs->dirs[i]); free(importing_dirs->dirs[i]);