diff --git a/HISTORY b/HISTORY index c183f18..71506ad 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,6 @@ +Jan. 6 2016 +Added support to use TYPE("NUMBER") to represent both integer and real + Jan. 5 2016 Developing lambda, added data structure Developing lambda, added a LAMBDA statement diff --git a/core/my_basic.c b/core/my_basic.c index d764f0a..2dc1f74 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -9592,9 +9592,11 @@ const char* mb_get_type_string(mb_data_e t) { case MB_DT_TYPE: return "TYPE"; case MB_DT_INT: - return "INT"; + return "INTEGER"; case MB_DT_REAL: return "REAL"; + case MB_DT_NUM: + return "NUMBER"; case MB_DT_STRING: return "STRING"; case MB_DT_USERTYPE: @@ -10213,7 +10215,10 @@ int _core_is(mb_interpreter_t* s, void** l) { } if(scd->type == _DT_TYPE) { val->type = _DT_INT; - val->data.integer = (int_t)(_internal_type_to_public_type(fst->type) == scd->data.type); + if((fst->type == _DT_INT || fst->type == _DT_REAL) && scd->data.type == MB_DT_NUM) + val->data.integer = 1; + else + val->data.integer = (int_t)(_internal_type_to_public_type(fst->type) == scd->data.type); } else { #ifdef MB_ENABLE_CLASS if(!_IS_CLASS(fst) || !_IS_CLASS(scd)) { diff --git a/core/my_basic.h b/core/my_basic.h index a4a5396..607ce77 100755 --- a/core/my_basic.h +++ b/core/my_basic.h @@ -348,20 +348,21 @@ typedef enum mb_data_e { MB_DT_TYPE = 1 << 2, MB_DT_INT = 1 << 3, MB_DT_REAL = 1 << 4, - MB_DT_STRING = 1 << 5, - MB_DT_USERTYPE = 1 << 6, - MB_DT_USERTYPE_REF = 1 << 7, - MB_DT_ARRAY = 1 << 8, + MB_DT_NUM = 1 << 5, + MB_DT_STRING = 1 << 6, + MB_DT_USERTYPE = 1 << 7, + MB_DT_USERTYPE_REF = 1 << 8, + MB_DT_ARRAY = 1 << 9, #ifdef MB_ENABLE_COLLECTION_LIB - MB_DT_LIST = 1 << 9, - MB_DT_LIST_IT = 1 << 10, - MB_DT_DICT = 1 << 11, - MB_DT_DICT_IT = 1 << 12, + MB_DT_LIST = 1 << 10, + MB_DT_LIST_IT = 1 << 11, + MB_DT_DICT = 1 << 12, + MB_DT_DICT_IT = 1 << 13, #endif /* MB_ENABLE_COLLECTION_LIB */ #ifdef MB_ENABLE_CLASS - MB_DT_CLASS = 1 << 13, + MB_DT_CLASS = 1 << 14, #endif /* MB_ENABLE_CLASS */ - MB_DT_ROUTINE = 1 << 14 + MB_DT_ROUTINE = 1 << 15 } mb_data_e; typedef unsigned char mb_val_bytes_t[sizeof(void*) > sizeof(unsigned long) ? sizeof(void*) : sizeof(unsigned long)];