*polished code.
This commit is contained in:
parent
d4137157a7
commit
125b2d617b
@ -108,7 +108,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* Helper */
|
/* Helper */
|
||||||
#ifndef sgn
|
#ifndef sgn
|
||||||
# define sgn(__v) ((__v) ? ((__v) > 0 ? 1 : -1) : (0))
|
# define sgn(__v) ((__v) ? ((__v) > 0 ? 1 : -1) : 0)
|
||||||
#endif /* sgn */
|
#endif /* sgn */
|
||||||
|
|
||||||
#ifndef _countof
|
#ifndef _countof
|
||||||
@ -2217,8 +2217,6 @@ static unsigned int _ls_foreach(_ls_node_t* list, _ls_operation op) {
|
|||||||
node->prev = tmp->prev;
|
node->prev = tmp->prev;
|
||||||
safe_free(tmp);
|
safe_free(tmp);
|
||||||
list->data = (char*)list->data - 1;
|
list->data = (char*)list->data - 1;
|
||||||
} else {
|
|
||||||
/* Do nothing */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4993,11 +4991,8 @@ static int _parse_char(mb_interpreter_t* s, char c, int pos, unsigned short row,
|
|||||||
_mb_check(result = _append_char_to_symbol(s, c), _exit);
|
_mb_check(result = _append_char_to_symbol(s, c), _exit);
|
||||||
}
|
}
|
||||||
} else if(context->parsing_state == _PS_COMMENT) {
|
} else if(context->parsing_state == _PS_COMMENT) {
|
||||||
if(_is_newline(c)) { /* \r \n EOF */
|
if(_is_newline(c)) /* \r \n EOF */
|
||||||
context->parsing_state = _PS_NORMAL;
|
context->parsing_state = _PS_NORMAL;
|
||||||
} else {
|
|
||||||
/* Do nothing */
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
mb_assert(0 && "Unknown parsing state.");
|
mb_assert(0 && "Unknown parsing state.");
|
||||||
}
|
}
|
||||||
@ -5705,13 +5700,16 @@ static void _gc_collect_garbage(mb_interpreter_t* s, int depth) {
|
|||||||
/* Avoid infinity loop */
|
/* Avoid infinity loop */
|
||||||
if(s->gc.collecting) return;
|
if(s->gc.collecting) return;
|
||||||
s->gc.collecting++;
|
s->gc.collecting++;
|
||||||
|
|
||||||
/* Get reachable information */
|
/* Get reachable information */
|
||||||
valid = _ht_create(0, _ht_cmp_ref, _ht_hash_ref, _do_nothing_on_object);
|
valid = _ht_create(0, _ht_cmp_ref, _ht_hash_ref, _do_nothing_on_object);
|
||||||
if(depth != -1)
|
if(depth != -1)
|
||||||
s->gc.valid_table = valid;
|
s->gc.valid_table = valid;
|
||||||
_gc_get_reachable(s, valid);
|
_gc_get_reachable(s, valid);
|
||||||
|
|
||||||
/* Get unreachable information */
|
/* Get unreachable information */
|
||||||
_HT_FOREACH(valid, _do_nothing_on_object, _ht_remove_exist, s->gc.table);
|
_HT_FOREACH(valid, _do_nothing_on_object, _ht_remove_exist, s->gc.table);
|
||||||
|
|
||||||
/* Collect garbage */
|
/* Collect garbage */
|
||||||
do {
|
do {
|
||||||
#ifdef MB_ENABLE_CLASS
|
#ifdef MB_ENABLE_CLASS
|
||||||
@ -5728,6 +5726,7 @@ static void _gc_collect_garbage(mb_interpreter_t* s, int depth) {
|
|||||||
_gc_swap_tables(s);
|
_gc_swap_tables(s);
|
||||||
s->gc.collecting++;
|
s->gc.collecting++;
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
/* Tidy */
|
/* Tidy */
|
||||||
_ht_clear(s->gc.collected_table);
|
_ht_clear(s->gc.collected_table);
|
||||||
s->gc.valid_table = 0;
|
s->gc.valid_table = 0;
|
||||||
@ -9069,6 +9068,7 @@ _retry:
|
|||||||
result = _core_let(s, (void**)&ast);
|
result = _core_let(s, (void**)&ast);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/* Normal node */
|
||||||
result = _core_let(s, (void**)&ast);
|
result = _core_let(s, (void**)&ast);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -9126,7 +9126,7 @@ _retry:
|
|||||||
goto _exit;
|
goto _exit;
|
||||||
|
|
||||||
if(ast) {
|
if(ast) {
|
||||||
obj = ast ? (_object_t*)ast->data : 0;
|
obj = DON(ast);
|
||||||
if(!obj) {
|
if(!obj) {
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
} else if(_IS_EOS(obj)) {
|
} else if(_IS_EOS(obj)) {
|
||||||
|
@ -92,7 +92,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define _LINE_INC_STEP 16
|
#define _LINE_INC_STEP 16
|
||||||
|
|
||||||
#define _NO_END(s) (MB_FUNC_OK == (s) || MB_FUNC_SUSPEND == (s) || MB_FUNC_WARNING == (s) || MB_FUNC_ERR == (s) || MB_FUNC_END == (s))
|
#define _NO_END(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;
|
static struct mb_interpreter_t* bas = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user