-Removed redundant EOS; *Polished data precision macros
This commit is contained in:
parent
12bc50b408
commit
3d4a28d157
4
HISTORY
4
HISTORY
@ -1,3 +1,7 @@
|
|||||||
|
May. 6 2015
|
||||||
|
Removed redundant EOS tokens
|
||||||
|
Polished data precision related macros
|
||||||
|
|
||||||
May. 5 2015
|
May. 5 2015
|
||||||
Added string type support for non-simple array
|
Added string type support for non-simple array
|
||||||
Fixed a memory leak when storing strings to a non-string array
|
Fixed a memory leak when storing strings to a non-string array
|
||||||
|
@ -78,7 +78,7 @@ extern "C" {
|
|||||||
/** Macros */
|
/** Macros */
|
||||||
#define _VER_MAJOR 1
|
#define _VER_MAJOR 1
|
||||||
#define _VER_MINOR 1
|
#define _VER_MINOR 1
|
||||||
#define _VER_REVISION 53
|
#define _VER_REVISION 54
|
||||||
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
|
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
|
||||||
|
|
||||||
/* Uncomment this line to treat warnings as error */
|
/* Uncomment this line to treat warnings as error */
|
||||||
@ -1939,6 +1939,12 @@ int _create_symbol(mb_interpreter_t* s, _ls_node_t* l, char* sym, _object_t** ob
|
|||||||
type = _get_symbol_type(s, sym, &value);
|
type = _get_symbol_type(s, sym, &value);
|
||||||
(*obj)->type = type;
|
(*obj)->type = type;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
|
case _DT_NIL:
|
||||||
|
safe_free(*obj);
|
||||||
|
*obj = 0;
|
||||||
|
safe_free(sym);
|
||||||
|
|
||||||
|
break;
|
||||||
case _DT_INT:
|
case _DT_INT:
|
||||||
memcpy(tmp.any, value, sizeof(_raw_t));
|
memcpy(tmp.any, value, sizeof(_raw_t));
|
||||||
(*obj)->data.integer = tmp.integer;
|
(*obj)->data.integer = tmp.integer;
|
||||||
@ -2083,7 +2089,7 @@ _data_e _get_symbol_type(mb_interpreter_t* s, char* sym, _raw_t* value) {
|
|||||||
context = s->parsing_context;
|
context = s->parsing_context;
|
||||||
|
|
||||||
/* int_t */
|
/* int_t */
|
||||||
tmp.integer = (int_t)strtol(sym, &conv_suc, 0);
|
tmp.integer = (int_t)mb_strtol(sym, &conv_suc, 0);
|
||||||
if(*conv_suc == '\0') {
|
if(*conv_suc == '\0') {
|
||||||
memcpy(*value, tmp.any, sizeof(_raw_t));
|
memcpy(*value, tmp.any, sizeof(_raw_t));
|
||||||
|
|
||||||
@ -2092,7 +2098,7 @@ _data_e _get_symbol_type(mb_interpreter_t* s, char* sym, _raw_t* value) {
|
|||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
/* real_t */
|
/* real_t */
|
||||||
tmp.float_point = (real_t)strtod(sym, &conv_suc);
|
tmp.float_point = (real_t)mb_strtod(sym, &conv_suc);
|
||||||
if(*conv_suc == '\0') {
|
if(*conv_suc == '\0') {
|
||||||
memcpy(*value, tmp.any, sizeof(_raw_t));
|
memcpy(*value, tmp.any, sizeof(_raw_t));
|
||||||
|
|
||||||
@ -2155,7 +2161,10 @@ _data_e _get_symbol_type(mb_interpreter_t* s, char* sym, _raw_t* value) {
|
|||||||
}
|
}
|
||||||
/* MB_EOS */
|
/* MB_EOS */
|
||||||
if(_sl == 1 && sym[0] == MB_EOS) {
|
if(_sl == 1 && sym[0] == MB_EOS) {
|
||||||
result = _DT_EOS;
|
if(_IS_EOS(context->last_symbol))
|
||||||
|
result = _DT_NIL;
|
||||||
|
else
|
||||||
|
result = _DT_EOS;
|
||||||
|
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
@ -3779,7 +3788,7 @@ int mb_dispose_value(struct mb_interpreter_t* s, mb_value_t val) {
|
|||||||
mb_assert(s);
|
mb_assert(s);
|
||||||
|
|
||||||
if(val.type == MB_DT_STRING)
|
if(val.type == MB_DT_STRING)
|
||||||
mb_free(val.value.string);
|
safe_free(val.value.string);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -3863,7 +3872,7 @@ int mb_load_file(struct mb_interpreter_t* s, const char* f) {
|
|||||||
buf[l] = '\0';
|
buf[l] = '\0';
|
||||||
|
|
||||||
result = mb_load_string(s, buf);
|
result = mb_load_string(s, buf);
|
||||||
mb_free(buf);
|
safe_free(buf);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
goto _exit;
|
goto _exit;
|
||||||
@ -5977,14 +5986,14 @@ int _std_val(mb_interpreter_t* s, void** l) {
|
|||||||
|
|
||||||
mb_check(mb_attempt_close_bracket(s, l));
|
mb_check(mb_attempt_close_bracket(s, l));
|
||||||
|
|
||||||
val.value.integer = (int_t)strtol(arg, &conv_suc, 0);
|
val.value.integer = (int_t)mb_strtol(arg, &conv_suc, 0);
|
||||||
if(*conv_suc == '\0') {
|
if(*conv_suc == '\0') {
|
||||||
val.type = MB_DT_INT;
|
val.type = MB_DT_INT;
|
||||||
mb_check(mb_push_value(s, l, val));
|
mb_check(mb_push_value(s, l, val));
|
||||||
|
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
val.value.float_point = (real_t)strtod(arg, &conv_suc);
|
val.value.float_point = (real_t)mb_strtod(arg, &conv_suc);
|
||||||
if(*conv_suc == '\0') {
|
if(*conv_suc == '\0') {
|
||||||
val.type = MB_DT_REAL;
|
val.type = MB_DT_REAL;
|
||||||
mb_check(mb_push_value(s, l, val));
|
mb_check(mb_push_value(s, l, val));
|
||||||
@ -6107,10 +6116,10 @@ int _std_input(mb_interpreter_t* s, void** l) {
|
|||||||
if(obj->data.variable->data->type == _DT_INT || obj->data.variable->data->type == _DT_REAL) {
|
if(obj->data.variable->data->type == _DT_INT || obj->data.variable->data->type == _DT_REAL) {
|
||||||
_get_inputer(s)(line, sizeof(line));
|
_get_inputer(s)(line, sizeof(line));
|
||||||
obj->data.variable->data->type = _DT_INT;
|
obj->data.variable->data->type = _DT_INT;
|
||||||
obj->data.variable->data->data.integer = (int_t)strtol(line, &conv_suc, 0);
|
obj->data.variable->data->data.integer = (int_t)mb_strtol(line, &conv_suc, 0);
|
||||||
if(*conv_suc != '\0') {
|
if(*conv_suc != '\0') {
|
||||||
obj->data.variable->data->type = _DT_REAL;
|
obj->data.variable->data->type = _DT_REAL;
|
||||||
obj->data.variable->data->data.float_point = (real_t)strtod(line, &conv_suc);
|
obj->data.variable->data->data.float_point = (real_t)mb_strtod(line, &conv_suc);
|
||||||
if(*conv_suc != '\0') {
|
if(*conv_suc != '\0') {
|
||||||
result = MB_FUNC_ERR;
|
result = MB_FUNC_ERR;
|
||||||
|
|
||||||
|
@ -75,6 +75,13 @@ extern "C" {
|
|||||||
# define real_t float
|
# define real_t float
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef mb_strtol
|
||||||
|
# define mb_strtol(__s, __e, __r) strtol((__s), (__e), (__r))
|
||||||
|
#endif
|
||||||
|
#ifndef mb_strtod
|
||||||
|
# define mb_strtod(__s, __e) strtod((__s), (__e))
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MB_INT_FMT
|
#ifndef MB_INT_FMT
|
||||||
# define MB_INT_FMT "%d"
|
# define MB_INT_FMT "%d"
|
||||||
#endif
|
#endif
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -36,8 +36,8 @@
|
|||||||
IDI_ICON_MAIN ICON "icon.ico"
|
IDI_ICON_MAIN ICON "icon.ico"
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,1,53,0
|
FILEVERSION 1,1,54,0
|
||||||
PRODUCTVERSION 1,1,53,0
|
PRODUCTVERSION 1,1,54,0
|
||||||
FILEFLAGSMASK 0x17L
|
FILEFLAGSMASK 0x17L
|
||||||
# ifdef _DEBUG
|
# ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@ -55,13 +55,13 @@
|
|||||||
VALUE "Comments", "MY-BASIC"
|
VALUE "Comments", "MY-BASIC"
|
||||||
VALUE "CompanyName", "W. Renxin"
|
VALUE "CompanyName", "W. Renxin"
|
||||||
VALUE "FileDescription", "MY-BASIC interpreter"
|
VALUE "FileDescription", "MY-BASIC interpreter"
|
||||||
VALUE "FileVersion", "1, 1, 53, 0"
|
VALUE "FileVersion", "1, 1, 54, 0"
|
||||||
VALUE "InternalName", "my_basic"
|
VALUE "InternalName", "my_basic"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2011 - 2015 W. Renxin"
|
VALUE "LegalCopyright", "Copyright (C) 2011 - 2015 W. Renxin"
|
||||||
VALUE "LegalTrademarks", "MY-BASIC"
|
VALUE "LegalTrademarks", "MY-BASIC"
|
||||||
VALUE "OriginalFilename", "my_basic.exe"
|
VALUE "OriginalFilename", "my_basic.exe"
|
||||||
VALUE "ProductName", "MY-BASIC"
|
VALUE "ProductName", "MY-BASIC"
|
||||||
VALUE "ProductVersion", "1, 1, 53, 0"
|
VALUE "ProductVersion", "1, 1, 54, 0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user