diff options
Diffstat (limited to 'mrbgems/mruby-compiler')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 11 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 1 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/y.tab.c | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 54eb611ca..ce513feee 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -167,6 +167,14 @@ codegen_realloc(codegen_scope *s, void *p, size_t len) return p; } +static void +check_no_ext_ops(codegen_scope *s, uint16_t a, uint16_t b) +{ + if (s->parser->no_ext_ops && (a | b) > 0xff) { + codegen_error(s, "need OP_EXTs instruction (currently OP_EXTs are prohibited)"); + } +} + static int new_label(codegen_scope *s) { @@ -235,6 +243,7 @@ static void genop_1(codegen_scope *s, mrb_code i, uint16_t a) { s->lastpc = s->pc; + check_no_ext_ops(s, a, 0); if (a > 0xff) { gen_B(s, OP_EXT1); gen_B(s, i); @@ -250,6 +259,7 @@ static void genop_2(codegen_scope *s, mrb_code i, uint16_t a, uint16_t b) { s->lastpc = s->pc; + check_no_ext_ops(s, a, b); if (a > 0xff && b > 0xff) { gen_B(s, OP_EXT3); gen_B(s, i); @@ -555,6 +565,7 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, uint32_t pc, int val) } if (a > 0xff) { + check_no_ext_ops(s, a, 0); gen_B(s, OP_EXT1); genop_0(s, i); gen_S(s, a); diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 76fcffa70..97e6e868c 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -6569,6 +6569,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt) } p->capture_errors = cxt->capture_errors; p->no_optimize = cxt->no_optimize; + p->no_ext_ops = cxt->no_ext_ops; p->upper = cxt->upper; if (cxt->partial_hook) { p->cxt = cxt; diff --git a/mrbgems/mruby-compiler/core/y.tab.c b/mrbgems/mruby-compiler/core/y.tab.c index 1d67b63ff..27f50cd11 100644 --- a/mrbgems/mruby-compiler/core/y.tab.c +++ b/mrbgems/mruby-compiler/core/y.tab.c @@ -12796,6 +12796,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt) } p->capture_errors = cxt->capture_errors; p->no_optimize = cxt->no_optimize; + p->no_ext_ops = cxt->no_ext_ops; p->upper = cxt->upper; if (cxt->partial_hook) { p->cxt = cxt; |
