+added an mb_schedule_suspend interface
This commit is contained in:
parent
3487cf13b6
commit
edb1e8da56
3
HISTORY
3
HISTORY
@ -1,3 +1,6 @@
|
||||
Jun. 19 2015
|
||||
Added an mb_schedule_suspend interface to schedule to suspend the execution
|
||||
|
||||
Jun. 15 2015
|
||||
Fixed a wrong token position marking issue with interactive mode, thanks to Daniel Haensse for pointing it out
|
||||
|
||||
|
@ -78,7 +78,7 @@ extern "C" {
|
||||
/** Macros */
|
||||
#define _VER_MAJOR 1
|
||||
#define _VER_MINOR 1
|
||||
#define _VER_REVISION 55
|
||||
#define _VER_REVISION 56
|
||||
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
|
||||
|
||||
/* Uncomment this line to treat warnings as error */
|
||||
@ -316,6 +316,7 @@ typedef struct _parsing_context_t {
|
||||
typedef struct _running_context_t {
|
||||
_ls_node_t* temp_values;
|
||||
_ls_node_t* suspent_point;
|
||||
int schedule_suspend_tag;
|
||||
_ls_node_t* sub_stack;
|
||||
_var_t* next_loop_var;
|
||||
mb_value_t intermediate_value;
|
||||
@ -2942,8 +2943,16 @@ int _execute_statement(mb_interpreter_t* s, _ls_node_t** l) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(running->schedule_suspend_tag) {
|
||||
mb_suspend(s, (void**)(&ast));
|
||||
result = MB_FUNC_SUSPEND;
|
||||
running->schedule_suspend_tag = 0;
|
||||
}
|
||||
|
||||
if(result != MB_FUNC_OK && result != MB_FUNC_SUSPEND && result != MB_SUB_RETURN)
|
||||
goto _exit;
|
||||
|
||||
if(ast) {
|
||||
obj = (_object_t*)(ast->data);
|
||||
if(_IS_EOS(obj)) {
|
||||
@ -2959,6 +2968,7 @@ int _execute_statement(mb_interpreter_t* s, _ls_node_t** l) {
|
||||
_handle_error_on_obj(s, SE_RN_COLON_EXPECTED, DON(ast), MB_FUNC_ERR, _exit, result);
|
||||
}
|
||||
}
|
||||
|
||||
if(skip_to_eoi && running->skip_to_eoi && running->skip_to_eoi == _ls_back(running->sub_stack)) {
|
||||
running->skip_to_eoi = 0;
|
||||
obj = (_object_t*)(ast->data);
|
||||
@ -3955,7 +3965,7 @@ _exit:
|
||||
int mb_suspend(struct mb_interpreter_t* s, void** l) {
|
||||
/* Suspend current execution and save the context */
|
||||
int result = MB_FUNC_OK;
|
||||
_ls_node_t* ast;
|
||||
_ls_node_t* ast = 0;
|
||||
|
||||
mb_assert(s && l && *l);
|
||||
|
||||
@ -3965,6 +3975,17 @@ int mb_suspend(struct mb_interpreter_t* s, void** l) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int mb_schedule_suspend(struct mb_interpreter_t* s) {
|
||||
/* Schedule to suspend current execution and will save the context */
|
||||
int result = MB_FUNC_OK;
|
||||
|
||||
mb_assert(s);
|
||||
|
||||
s->running_context->schedule_suspend_tag = 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int mb_debug_get(struct mb_interpreter_t* s, const char* n, mb_value_t* val) {
|
||||
/* Get the value of an identifier */
|
||||
int result = MB_FUNC_OK;
|
||||
|
@ -278,6 +278,7 @@ MBAPI int mb_load_string(struct mb_interpreter_t* s, const char* l);
|
||||
MBAPI int mb_load_file(struct mb_interpreter_t* s, const char* f);
|
||||
MBAPI int mb_run(struct mb_interpreter_t* s);
|
||||
MBAPI int mb_suspend(struct mb_interpreter_t* s, void** l);
|
||||
MBAPI int mb_schedule_suspend(struct mb_interpreter_t* s);
|
||||
|
||||
MBAPI int mb_debug_get(struct mb_interpreter_t* s, const char* n, mb_value_t* val);
|
||||
MBAPI int mb_debug_set(struct mb_interpreter_t* s, const char* n, mb_value_t val);
|
||||
|
Binary file not shown.
@ -36,8 +36,8 @@
|
||||
IDI_ICON_MAIN ICON "icon.ico"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,1,55,0
|
||||
PRODUCTVERSION 1,1,55,0
|
||||
FILEVERSION 1,1,56,0
|
||||
PRODUCTVERSION 1,1,56,0
|
||||
FILEFLAGSMASK 0x17L
|
||||
# ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@ -55,13 +55,13 @@
|
||||
VALUE "Comments", "MY-BASIC"
|
||||
VALUE "CompanyName", "W. Renxin"
|
||||
VALUE "FileDescription", "MY-BASIC interpreter"
|
||||
VALUE "FileVersion", "1, 1, 55, 0"
|
||||
VALUE "FileVersion", "1, 1, 56, 0"
|
||||
VALUE "InternalName", "my_basic"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2011 - 2015 W. Renxin"
|
||||
VALUE "LegalTrademarks", "MY-BASIC"
|
||||
VALUE "OriginalFilename", "my_basic.exe"
|
||||
VALUE "ProductName", "MY-BASIC"
|
||||
VALUE "ProductVersion", "1, 1, 55, 0"
|
||||
VALUE "ProductVersion", "1, 1, 56, 0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -110,7 +110,7 @@ static void _append_line(_code_line_t* code, char* txt) {
|
||||
code->size += _LINE_INC_STEP;
|
||||
code->lines = (char**)realloc(code->lines, sizeof(char*) * code->size);
|
||||
}
|
||||
l = strlen(txt);
|
||||
l = (int)strlen(txt);
|
||||
buf = (char*)malloc(l + 2);
|
||||
memcpy(buf, txt, l);
|
||||
buf[l] = '\n';
|
||||
@ -267,7 +267,7 @@ static void _list_program(const char* sn, const char* cn) {
|
||||
if(lsn == 0 && lcn == 0) {
|
||||
long i = 0;
|
||||
for(i = 0; i < c->count; ++i) {
|
||||
printf("%d]%s\n", i + 1, c->lines[i]);
|
||||
printf("%ld]%s\n", i + 1, c->lines[i]);
|
||||
}
|
||||
} else {
|
||||
long i = 0;
|
||||
@ -288,7 +288,7 @@ static void _list_program(const char* sn, const char* cn) {
|
||||
if(i >= c->count)
|
||||
break;
|
||||
|
||||
printf("%d]%s\n", i + 1, c->lines[i]);
|
||||
printf("%ld]%s\n", i + 1, c->lines[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,7 +339,7 @@ static void _insert_program(const char* no) {
|
||||
|
||||
static void _alter_program(const char* no) {
|
||||
long lno = 0;
|
||||
int i = 0;
|
||||
long i = 0;
|
||||
mb_assert(no);
|
||||
lno = atoi(no);
|
||||
if(lno < 1 || lno > c->count) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user