*fixed a wrong routine evaluation bug.

This commit is contained in:
paladin-t 2015-12-28 16:35:45 +08:00
parent 7298884d09
commit d653ba80e5
2 changed files with 17 additions and 15 deletions

View File

@ -1,5 +1,6 @@
Dec. 28 2015
Fixed a GC bug
Fixed a wrong routine evaluation bug
Improved threshold algorithm for the memory pool
Polished code

View File

@ -264,8 +264,9 @@ mb_static_assert(_countof(_ERR_DESC) == SE_COUNT);
/* Data type */
typedef enum _data_e {
_DT_NIL = -1,
_DT_ANY = 0,
_DT_INVALID = -1,
_DT_NIL = 0,
_DT_KNOWN,
_DT_TYPE,
_DT_INT,
_DT_REAL,
@ -3533,7 +3534,7 @@ int _create_symbol(mb_interpreter_t* s, _ls_node_t* l, char* sym, _object_t** ob
(*obj)->ref = true;
*delsym = true;
} else {
tmp.array = _create_array(sym, _DT_ANY, s);
tmp.array = _create_array(sym, _DT_KNOWN, s);
memcpy(&tmp.array->type, value, sizeof(tmp.array->type));
(*obj)->data.array = tmp.array;
@ -3728,7 +3729,7 @@ _data_e _get_symbol_type(mb_interpreter_t* s, char* sym, _raw_t* value) {
_running_context_t* running = 0;
_ls_node_t* glbsyminscope = 0;
size_t _sl = 0;
_data_e en = _DT_ANY;
_data_e en = _DT_KNOWN;
intptr_t ptr = 0;
bool_t mod = false;
@ -4144,10 +4145,10 @@ bool_t _try_get_value(_object_t* obj, mb_value_u* val, _data_e expected) {
mb_assert(obj && val);
if(obj->type == _DT_INT && (expected == _DT_ANY || expected == _DT_INT)) {
if(obj->type == _DT_INT && (expected == _DT_KNOWN || expected == _DT_INT)) {
val->integer = obj->data.integer;
result = true;
} else if(obj->type == _DT_REAL && (expected == _DT_ANY || expected == _DT_REAL)) {
} else if(obj->type == _DT_REAL && (expected == _DT_KNOWN || expected == _DT_REAL)) {
val->float_point = obj->data.float_point;
result = true;
} else if(obj->type == _DT_VAR) {
@ -4678,7 +4679,7 @@ void _init_array(_array_t* arr) {
#ifdef MB_SIMPLE_ARRAY
elemsize = (int)_get_size_of(arr->type);
#else /* MB_SIMPLE_ARRAY */
elemsize = (int)_get_size_of(_DT_ANY);
elemsize = (int)_get_size_of(_DT_KNOWN);
#endif /* MB_SIMPLE_ARRAY */
mb_assert(arr->count > 0);
mb_assert(!arr->raw);
@ -6259,9 +6260,9 @@ int _clone_object(mb_interpreter_t* s, _object_t* obj, _object_t* tgt) {
mb_assert(0 && "Not implemented.");
break;
case _DT_TYPE: /* Fall through */
case _DT_NIL: /* Fall through */
case _DT_ANY: /* Fall through */
case _DT_KNOWN: /* Fall through */
case _DT_TYPE: /* Fall through */
case _DT_INT: /* Fall through */
case _DT_REAL: /* Fall through */
case _DT_SEP: /* Fall through */
@ -6361,9 +6362,9 @@ int _dispose_object(_object_t* obj) {
}
break;
case _DT_TYPE: /* Fall through */
case _DT_NIL: /* Fall through */
case _DT_ANY: /* Fall through */
case _DT_KNOWN: /* Fall through */
case _DT_TYPE: /* Fall through */
case _DT_INT: /* Fall through */
case _DT_REAL: /* Fall through */
case _DT_SEP: /* Fall through */
@ -10031,7 +10032,7 @@ int _core_let(mb_interpreter_t* s, void** l) {
result = _calc_expression(s, &ast, &val);
if(var) {
if(val->type != _DT_ANY) {
if(val->type != _DT_KNOWN) {
_dispose_object(var->data);
var->data->type = val->type;
#ifdef MB_ENABLE_COLLECTION_LIB
@ -10048,7 +10049,7 @@ int _core_let(mb_interpreter_t* s, void** l) {
var->data->ref = val->ref;
}
} else if(arr && literally) {
if(val->type != _DT_ANY) {
if(val->type != _DT_KNOWN) {
_unref(&arr_obj->data.array->ref, arr_obj->data.array);
arr_obj->type = val->type;
#ifdef MB_ENABLE_COLLECTION_LIB
@ -10289,7 +10290,7 @@ _exit:
*l = ast;
if(val->type != _DT_ANY)
if(val->type != _DT_KNOWN)
_destroy_object(val, 0);
return result;
@ -10897,7 +10898,7 @@ int _core_def(mb_interpreter_t* s, void** l) {
ast = ast->next;
routine->func.basic.entry = ast;
_skip_to(s, &ast, _core_enddef, _DT_NIL);
_skip_to(s, &ast, _core_enddef, _DT_INVALID);
ast = ast->next;