*fixed an unknown type handling bug.
This commit is contained in:
parent
dff4324ef1
commit
98631c35ac
3
HISTORY
3
HISTORY
@ -1,3 +1,6 @@
|
|||||||
|
Jan. 20 2016
|
||||||
|
Fixed an unknown type handling bug
|
||||||
|
|
||||||
Jan. 19 2016
|
Jan. 19 2016
|
||||||
Added support to apply the LEN statement to variable arguments as LEN(...)
|
Added support to apply the LEN statement to variable arguments as LEN(...)
|
||||||
Polished code
|
Polished code
|
||||||
|
@ -3248,7 +3248,7 @@ _routine:
|
|||||||
}
|
}
|
||||||
|
|
||||||
c = (_object_t*)(_ls_popback(opnd));
|
c = (_object_t*)(_ls_popback(opnd));
|
||||||
if(!c || !(c->type == _DT_TYPE || c->type == _DT_NIL ||
|
if(!c || !(c->type == _DT_NIL || c->type == _DT_UNKNOWN || c->type == _DT_TYPE ||
|
||||||
c->type == _DT_INT || c->type == _DT_REAL || c->type == _DT_STRING ||
|
c->type == _DT_INT || c->type == _DT_REAL || c->type == _DT_STRING ||
|
||||||
#ifdef MB_ENABLE_COLLECTION_LIB
|
#ifdef MB_ENABLE_COLLECTION_LIB
|
||||||
c->type == _DT_LIST || c->type == _DT_LIST_IT || c->type == _DT_DICT || c->type == _DT_DICT_IT ||
|
c->type == _DT_LIST || c->type == _DT_LIST_IT || c->type == _DT_DICT || c->type == _DT_DICT_IT ||
|
||||||
@ -7786,10 +7786,10 @@ bool_t _is_internal_object(_object_t* obj) {
|
|||||||
_data_e _public_type_to_internal_type(mb_data_e t) {
|
_data_e _public_type_to_internal_type(mb_data_e t) {
|
||||||
/* Convert a public mb_data_e type to an internal _data_e */
|
/* Convert a public mb_data_e type to an internal _data_e */
|
||||||
switch(t) {
|
switch(t) {
|
||||||
case MB_DT_TYPE:
|
|
||||||
return _DT_TYPE;
|
|
||||||
case MB_DT_NIL:
|
case MB_DT_NIL:
|
||||||
return _DT_NIL;
|
return _DT_NIL;
|
||||||
|
case MB_DT_TYPE:
|
||||||
|
return _DT_TYPE;
|
||||||
case MB_DT_INT:
|
case MB_DT_INT:
|
||||||
return _DT_INT;
|
return _DT_INT;
|
||||||
case MB_DT_REAL:
|
case MB_DT_REAL:
|
||||||
@ -7828,10 +7828,10 @@ _data_e _public_type_to_internal_type(mb_data_e t) {
|
|||||||
mb_data_e _internal_type_to_public_type(_data_e t) {
|
mb_data_e _internal_type_to_public_type(_data_e t) {
|
||||||
/* Convert an internal mb_data_e type to a public _data_e */
|
/* Convert an internal mb_data_e type to a public _data_e */
|
||||||
switch(t) {
|
switch(t) {
|
||||||
case _DT_TYPE:
|
|
||||||
return MB_DT_TYPE;
|
|
||||||
case _DT_NIL:
|
case _DT_NIL:
|
||||||
return MB_DT_NIL;
|
return MB_DT_NIL;
|
||||||
|
case _DT_TYPE:
|
||||||
|
return MB_DT_TYPE;
|
||||||
case _DT_INT:
|
case _DT_INT:
|
||||||
return MB_DT_INT;
|
return MB_DT_INT;
|
||||||
case _DT_REAL:
|
case _DT_REAL:
|
||||||
@ -7876,15 +7876,20 @@ int _public_value_to_internal_object(mb_value_t* pbl, _object_t* itn) {
|
|||||||
_UNREF(itn)
|
_UNREF(itn)
|
||||||
|
|
||||||
switch(pbl->type) {
|
switch(pbl->type) {
|
||||||
case MB_DT_TYPE:
|
|
||||||
itn->type = _DT_TYPE;
|
|
||||||
itn->data.type = pbl->value.type;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case MB_DT_NIL:
|
case MB_DT_NIL:
|
||||||
itn->type = _DT_NIL;
|
itn->type = _DT_NIL;
|
||||||
itn->data.integer = false;
|
itn->data.integer = false;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case MB_DT_UNKNOWN:
|
||||||
|
itn->type = _DT_UNKNOWN;
|
||||||
|
itn->data.integer = false;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case MB_DT_TYPE:
|
||||||
|
itn->type = _DT_TYPE;
|
||||||
|
itn->data.type = pbl->value.type;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MB_DT_INT:
|
case MB_DT_INT:
|
||||||
itn->type = _DT_INT;
|
itn->type = _DT_INT;
|
||||||
@ -7973,15 +7978,20 @@ int _internal_object_to_public_value(_object_t* itn, mb_value_t* pbl) {
|
|||||||
case _DT_VAR:
|
case _DT_VAR:
|
||||||
result = _internal_object_to_public_value(itn->data.variable->data, pbl);
|
result = _internal_object_to_public_value(itn->data.variable->data, pbl);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case _DT_NIL:
|
||||||
|
mb_make_nil(*pbl);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case _DT_UNKNOWN:
|
||||||
|
pbl->type = MB_DT_UNKNOWN;
|
||||||
|
pbl->value.integer = false;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case _DT_TYPE:
|
case _DT_TYPE:
|
||||||
pbl->type = MB_DT_TYPE;
|
pbl->type = MB_DT_TYPE;
|
||||||
pbl->value.type = itn->data.type;
|
pbl->value.type = itn->data.type;
|
||||||
|
|
||||||
break;
|
|
||||||
case _DT_NIL:
|
|
||||||
mb_make_nil(*pbl);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case _DT_INT:
|
case _DT_INT:
|
||||||
pbl->type = MB_DT_INT;
|
pbl->type = MB_DT_INT;
|
||||||
@ -10688,6 +10698,8 @@ const char* mb_get_type_string(mb_data_e t) {
|
|||||||
switch(t) {
|
switch(t) {
|
||||||
case MB_DT_NIL:
|
case MB_DT_NIL:
|
||||||
return "NIL";
|
return "NIL";
|
||||||
|
case MB_DT_UNKNOWN:
|
||||||
|
return "UNKNOWN";
|
||||||
case MB_DT_TYPE:
|
case MB_DT_TYPE:
|
||||||
return "TYPE";
|
return "TYPE";
|
||||||
case MB_DT_INT:
|
case MB_DT_INT:
|
||||||
@ -10722,9 +10734,8 @@ const char* mb_get_type_string(mb_data_e t) {
|
|||||||
#endif /* MB_ENABLE_CLASS */
|
#endif /* MB_ENABLE_CLASS */
|
||||||
case MB_DT_ROUTINE:
|
case MB_DT_ROUTINE:
|
||||||
return "ROUTINE";
|
return "ROUTINE";
|
||||||
case MB_DT_UNKNOWN: /* Fall through */
|
default: /* Return a not exist string */
|
||||||
default:
|
return "";
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11441,7 +11452,6 @@ int _core_let(mb_interpreter_t* s, void** l) {
|
|||||||
result = _calc_expression(s, &ast, &val);
|
result = _calc_expression(s, &ast, &val);
|
||||||
|
|
||||||
if(var) {
|
if(var) {
|
||||||
if(val->type != _DT_UNKNOWN) {
|
|
||||||
#ifdef MB_ENABLE_COLLECTION_LIB
|
#ifdef MB_ENABLE_COLLECTION_LIB
|
||||||
if(is_coll) {
|
if(is_coll) {
|
||||||
switch(var->data->type) {
|
switch(var->data->type) {
|
||||||
@ -11496,7 +11506,6 @@ _proc_extra_var:
|
|||||||
goto _proc_extra_var;
|
goto _proc_extra_var;
|
||||||
}
|
}
|
||||||
#endif /* MB_ENABLE_CLASS */
|
#endif /* MB_ENABLE_CLASS */
|
||||||
}
|
|
||||||
} else if(arr && literally) {
|
} else if(arr && literally) {
|
||||||
if(val->type != _DT_UNKNOWN) {
|
if(val->type != _DT_UNKNOWN) {
|
||||||
#ifdef MB_ENABLE_ARRAY_REF
|
#ifdef MB_ENABLE_ARRAY_REF
|
||||||
|
@ -358,27 +358,27 @@ typedef enum mb_error_e {
|
|||||||
|
|
||||||
typedef enum mb_data_e {
|
typedef enum mb_data_e {
|
||||||
MB_DT_NIL = 0,
|
MB_DT_NIL = 0,
|
||||||
MB_DT_UNKNOWN = 1 << 1,
|
MB_DT_UNKNOWN = 1 << 0,
|
||||||
MB_DT_TYPE = 1 << 2,
|
MB_DT_TYPE = 1 << 1,
|
||||||
MB_DT_INT = 1 << 3,
|
MB_DT_INT = 1 << 2,
|
||||||
MB_DT_REAL = 1 << 4,
|
MB_DT_REAL = 1 << 3,
|
||||||
MB_DT_NUM = 1 << 5,
|
MB_DT_NUM = 1 << 4,
|
||||||
MB_DT_STRING = 1 << 6,
|
MB_DT_STRING = 1 << 5,
|
||||||
MB_DT_USERTYPE = 1 << 7,
|
MB_DT_USERTYPE = 1 << 6,
|
||||||
#ifdef MB_ENABLE_USERTYPE_REF
|
#ifdef MB_ENABLE_USERTYPE_REF
|
||||||
MB_DT_USERTYPE_REF = 1 << 8,
|
MB_DT_USERTYPE_REF = 1 << 7,
|
||||||
#endif /* MB_ENABLE_USERTYPE_REF */
|
#endif /* MB_ENABLE_USERTYPE_REF */
|
||||||
MB_DT_ARRAY = 1 << 9,
|
MB_DT_ARRAY = 1 << 8,
|
||||||
#ifdef MB_ENABLE_COLLECTION_LIB
|
#ifdef MB_ENABLE_COLLECTION_LIB
|
||||||
MB_DT_LIST = 1 << 10,
|
MB_DT_LIST = 1 << 9,
|
||||||
MB_DT_LIST_IT = 1 << 11,
|
MB_DT_LIST_IT = 1 << 10,
|
||||||
MB_DT_DICT = 1 << 12,
|
MB_DT_DICT = 1 << 11,
|
||||||
MB_DT_DICT_IT = 1 << 13,
|
MB_DT_DICT_IT = 1 << 12,
|
||||||
#endif /* MB_ENABLE_COLLECTION_LIB */
|
#endif /* MB_ENABLE_COLLECTION_LIB */
|
||||||
#ifdef MB_ENABLE_CLASS
|
#ifdef MB_ENABLE_CLASS
|
||||||
MB_DT_CLASS = 1 << 14,
|
MB_DT_CLASS = 1 << 13,
|
||||||
#endif /* MB_ENABLE_CLASS */
|
#endif /* MB_ENABLE_CLASS */
|
||||||
MB_DT_ROUTINE = 1 << 15
|
MB_DT_ROUTINE = 1 << 14
|
||||||
} mb_data_e;
|
} mb_data_e;
|
||||||
|
|
||||||
typedef unsigned char mb_val_bytes_t[sizeof(void*) > sizeof(unsigned long) ? sizeof(void*) : sizeof(unsigned long)];
|
typedef unsigned char mb_val_bytes_t[sizeof(void*) > sizeof(unsigned long) ? sizeof(void*) : sizeof(unsigned long)];
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user