*fixed a crash bug when re-entry a script
This commit is contained in:
parent
3e10389428
commit
69bd7780a2
@ -694,6 +694,8 @@ static int _skip_to(mb_interpreter_t* s, _ls_node_t** l, mb_func_t f, _data_e t)
|
|||||||
static int _skip_if_chunk(mb_interpreter_t* s, _ls_node_t** l);
|
static int _skip_if_chunk(mb_interpreter_t* s, _ls_node_t** l);
|
||||||
static int _skip_struct(mb_interpreter_t* s, _ls_node_t** l, mb_func_t open_func, mb_func_t close_func);
|
static int _skip_struct(mb_interpreter_t* s, _ls_node_t** l, mb_func_t open_func, mb_func_t close_func);
|
||||||
|
|
||||||
|
static _parsing_context_t* _reset_parsing_context(_parsing_context_t* context);
|
||||||
|
|
||||||
static int _register_func(mb_interpreter_t* s, const char* n, mb_func_t f, bool_t local);
|
static int _register_func(mb_interpreter_t* s, const char* n, mb_func_t f, bool_t local);
|
||||||
static int _remove_func(mb_interpreter_t* s, const char* n, bool_t local);
|
static int _remove_func(mb_interpreter_t* s, const char* n, bool_t local);
|
||||||
|
|
||||||
@ -3057,6 +3059,15 @@ _exit:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_parsing_context_t* _reset_parsing_context(_parsing_context_t* context) {
|
||||||
|
if(!context)
|
||||||
|
context = (_parsing_context_t*)mb_malloc(sizeof(_parsing_context_t));
|
||||||
|
memset(context, 0, sizeof(_parsing_context_t));
|
||||||
|
context->parsing_row = 1;
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
int _register_func(mb_interpreter_t* s, const char* n, mb_func_t f, bool_t local) {
|
int _register_func(mb_interpreter_t* s, const char* n, mb_func_t f, bool_t local) {
|
||||||
/* Register a function to a MY-BASIC environment */
|
/* Register a function to a MY-BASIC environment */
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -3315,10 +3326,7 @@ int mb_open(struct mb_interpreter_t** s) {
|
|||||||
ast = _ls_create();
|
ast = _ls_create();
|
||||||
(*s)->ast = ast;
|
(*s)->ast = ast;
|
||||||
|
|
||||||
context = (_parsing_context_t*)mb_malloc(sizeof(_parsing_context_t));
|
(*s)->parsing_context = context = _reset_parsing_context(context);
|
||||||
memset(context, 0, sizeof(_parsing_context_t));
|
|
||||||
context->parsing_row = 1;
|
|
||||||
(*s)->parsing_context = context;
|
|
||||||
|
|
||||||
running = (_running_context_t*)mb_malloc(sizeof(_running_context_t));
|
running = (_running_context_t*)mb_malloc(sizeof(_running_context_t));
|
||||||
memset(running, 0, sizeof(_running_context_t));
|
memset(running, 0, sizeof(_running_context_t));
|
||||||
@ -3410,14 +3418,7 @@ int mb_reset(struct mb_interpreter_t** s, bool_t clrf/* = false*/) {
|
|||||||
running->no_eat_comma_mark = 0;
|
running->no_eat_comma_mark = 0;
|
||||||
memset(&(running->intermediate_value), 0, sizeof(mb_value_t));
|
memset(&(running->intermediate_value), 0, sizeof(mb_value_t));
|
||||||
|
|
||||||
context = (*s)->parsing_context;
|
(*s)->parsing_context = context = _reset_parsing_context(context);
|
||||||
if(!context) {
|
|
||||||
context = (_parsing_context_t*)mb_malloc(sizeof(_parsing_context_t));
|
|
||||||
memset(context, 0, sizeof(_parsing_context_t));
|
|
||||||
(*s)->parsing_context = context;
|
|
||||||
}
|
|
||||||
memset(context, 0, sizeof(_parsing_context_t));
|
|
||||||
context->parsing_row = 1;
|
|
||||||
|
|
||||||
ast = (*s)->ast;
|
ast = (*s)->ast;
|
||||||
_ls_foreach(ast, _destroy_object);
|
_ls_foreach(ast, _destroy_object);
|
||||||
@ -3859,10 +3860,12 @@ int mb_load_file(struct mb_interpreter_t* s, const char* f) {
|
|||||||
long l = 0;
|
long l = 0;
|
||||||
_parsing_context_t* context = 0;
|
_parsing_context_t* context = 0;
|
||||||
|
|
||||||
mb_assert(s && s->parsing_context);
|
mb_assert(s);
|
||||||
|
|
||||||
context = s->parsing_context;
|
context = s->parsing_context;
|
||||||
|
|
||||||
|
s->parsing_context = context = _reset_parsing_context(context);
|
||||||
|
|
||||||
fp = fopen(f, "rb");
|
fp = fopen(f, "rb");
|
||||||
if(fp) {
|
if(fp) {
|
||||||
curpos = ftell(fp);
|
curpos = ftell(fp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user