Do not funcall() Exception#set_backtrace from runtime.
This change reduce flexibility but makes mruby simpler and faster.
MODIFY
src/error.c
src/error.c
@@ -202,12 +202,9 @@ exc_get_backtrace(mrb_state *mrb, mrb_value exc)
return backtrace;
}
-static mrb_value
-exc_set_backtrace(mrb_state *mrb, mrb_value exc)
+static void
+set_backtrace(mrb_state *mrb, mrb_value exc, mrb_value backtrace)
{
- mrb_value backtrace;
-
- mrb_get_args(mrb, "o", &backtrace);
if (!mrb_array_p(backtrace)) {
type_err:
mrb_raise(mrb, E_TYPE_ERROR, "backtrace must be Array of String");
@@ -222,7 +219,15 @@ exc_set_backtrace(mrb_state *mrb, mrb_value exc)
}
}
mrb_iv_set(mrb, exc, mrb_intern_lit(mrb, "backtrace"), backtrace);
+}
+static mrb_value
+exc_set_backtrace(mrb_state *mrb, mrb_value exc)
+{
+ mrb_value backtrace;
+
+ mrb_get_args(mrb, "o", &backtrace);
+ set_backtrace(mrb, exc, backtrace);
return backtrace;
}
@@ -253,12 +258,6 @@ exc_debug_info(mrb_state *mrb, struct RObject *exc)
}
}
-static void
-set_backtrace(mrb_state *mrb, mrb_value info, mrb_value bt)
-{
- mrb_funcall(mrb, info, "set_backtrace", 1, bt);
-}
-
static mrb_bool
have_backtrace(mrb_state *mrb, struct RObject *exc)
{

Do not funcall() Exception#set_backtrace from runtime.

This change reduce flexibility but makes mruby simpler and faster.