allow no_optimize esp. for debugger

parent 56384139
...@@ -29,6 +29,7 @@ typedef struct mrbc_context { ...@@ -29,6 +29,7 @@ typedef struct mrbc_context {
mrb_bool dump_result:1; mrb_bool dump_result:1;
mrb_bool no_exec:1; mrb_bool no_exec:1;
mrb_bool keep_lv:1; mrb_bool keep_lv:1;
mrb_bool no_optimize:1;
} mrbc_context; } mrbc_context;
mrbc_context* mrbc_context_new(mrb_state *mrb); mrbc_context* mrbc_context_new(mrb_state *mrb);
...@@ -143,6 +144,7 @@ struct mrb_parser_state { ...@@ -143,6 +144,7 @@ struct mrb_parser_state {
size_t nwarn; size_t nwarn;
mrb_ast_node *tree; mrb_ast_node *tree;
mrb_bool no_optimize:1;
mrb_bool capture_errors:1; mrb_bool capture_errors:1;
struct mrb_parser_message error_buffer[10]; struct mrb_parser_message error_buffer[10];
struct mrb_parser_message warn_buffer[10]; struct mrb_parser_message warn_buffer[10];
......
...@@ -162,11 +162,19 @@ genop(codegen_scope *s, mrb_code i) ...@@ -162,11 +162,19 @@ genop(codegen_scope *s, mrb_code i)
#define NOVAL 0 #define NOVAL 0
#define VAL 1 #define VAL 1
static mrb_bool
no_optimize(codegen_scope *s)
{
if (s && s->parser && s->parser->no_optimize)
return TRUE;
return FALSE;
}
static int static int
genop_peep(codegen_scope *s, mrb_code i, int val) genop_peep(codegen_scope *s, mrb_code i, int val)
{ {
/* peephole optimization */ /* peephole optimization */
if (s->lastlabel != s->pc && s->pc > 0) { if (!no_optimize(s) && s->lastlabel != s->pc && s->pc > 0) {
mrb_code i0 = s->iseq[s->pc-1]; mrb_code i0 = s->iseq[s->pc-1];
int c1 = GET_OPCODE(i); int c1 = GET_OPCODE(i);
int c0 = GET_OPCODE(i0); int c0 = GET_OPCODE(i0);
......
...@@ -5330,6 +5330,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt) ...@@ -5330,6 +5330,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt)
} }
} }
p->capture_errors = cxt->capture_errors; p->capture_errors = cxt->capture_errors;
p->no_optimize = cxt->no_optimize;
if (cxt->partial_hook) { if (cxt->partial_hook) {
p->cxt = cxt; p->cxt = cxt;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment