move mrb_irep_remove_lv from etc.c to mruby-bin-strip gem

parent e0064aca
...@@ -52,7 +52,6 @@ mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*); ...@@ -52,7 +52,6 @@ mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
void mrb_irep_free(mrb_state*, struct mrb_irep*); void mrb_irep_free(mrb_state*, struct mrb_irep*);
void mrb_irep_incref(mrb_state*, struct mrb_irep*); void mrb_irep_incref(mrb_state*, struct mrb_irep*);
void mrb_irep_decref(mrb_state*, struct mrb_irep*); void mrb_irep_decref(mrb_state*, struct mrb_irep*);
void mrb_irep_remove_lv(mrb_state*, struct mrb_irep*);
#if defined(__cplusplus) #if defined(__cplusplus)
} /* extern "C" { */ } /* extern "C" { */
......
...@@ -9,6 +9,22 @@ struct strip_args { ...@@ -9,6 +9,22 @@ struct strip_args {
mrb_bool lvar; mrb_bool lvar;
}; };
static void
irep_remove_lv(mrb_state *mrb, mrb_irep *irep)
{
size_t i;
if (irep->lv) {
mrb_free(mrb, irep->lv);
irep->lv = NULL;
}
for (i = 0; i < irep->rlen; ++i) {
irep_remove_lv(mrb, irep->reps[i]);
}
}
static void static void
print_usage(const char *f) print_usage(const char *f)
{ {
...@@ -99,7 +115,7 @@ main(int argc, char **argv) ...@@ -99,7 +115,7 @@ main(int argc, char **argv)
for (i = args_result; i < argc; ++i) { for (i = args_result; i < argc; ++i) {
/* clear lv if --lvar is enabled */ /* clear lv if --lvar is enabled */
if (args.lvar) { if (args.lvar) {
mrb_irep_remove_lv(mrb, ireps[i]); irep_remove_lv(mrb, ireps[i]);
} }
/* debug flag must be alway false */ /* debug flag must be alway false */
......
...@@ -183,18 +183,3 @@ mrb_regexp_p(mrb_state *mrb, mrb_value v) ...@@ -183,18 +183,3 @@ mrb_regexp_p(mrb_state *mrb, mrb_value v)
{ {
return mrb_class_defined(mrb, REGEXP_CLASS) && mrb_obj_is_kind_of(mrb, v, mrb_class_get(mrb, REGEXP_CLASS)); return mrb_class_defined(mrb, REGEXP_CLASS) && mrb_obj_is_kind_of(mrb, v, mrb_class_get(mrb, REGEXP_CLASS));
} }
void
mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep)
{
size_t i;
if (irep->lv) {
mrb_free(mrb, irep->lv);
irep->lv = NULL;
}
for (i = 0; i < irep->rlen; ++i) {
mrb_irep_remove_lv(mrb, irep->reps[i]);
}
}
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