mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
remove RuntimeError from mrb_state
This commit is contained in:
+1
-1
@@ -279,7 +279,6 @@ typedef struct mrb_state {
|
||||
|
||||
struct RClass *eException_class;
|
||||
struct RClass *eStandardError_class;
|
||||
struct RClass *eRuntimeError_class;
|
||||
|
||||
void *ud; /* auxiliary data */
|
||||
} mrb_state;
|
||||
@@ -430,6 +429,7 @@ void rb_raise(struct RClass *c, const char *fmt, ...);
|
||||
void mrb_warn(const char *fmt, ...);
|
||||
void mrb_bug(const char *fmt, ...);
|
||||
|
||||
#define E_RUNTIME_ERROR (mrb_class_obj_get(mrb, "RuntimeError"))
|
||||
#define E_TYPE_ERROR (mrb_class_obj_get(mrb, "TypeError"))
|
||||
#define E_ARGUMENT_ERROR (mrb_class_obj_get(mrb, "ArgumentError"))
|
||||
#define E_INDEX_ERROR (mrb_class_obj_get(mrb, "IndexError"))
|
||||
|
||||
+4
-4
@@ -301,7 +301,7 @@ make_exception(mrb_state *mrb, int argc, mrb_value *argv, int isstr)
|
||||
if (isstr) {
|
||||
mesg = mrb_check_string_type(mrb, argv[0]);
|
||||
if (!mrb_nil_p(mesg)) {
|
||||
mesg = mrb_exc_new3(mrb, mrb->eRuntimeError_class, mesg);
|
||||
mesg = mrb_exc_new3(mrb, E_RUNTIME_ERROR, mesg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -352,7 +352,7 @@ mrb_make_exception(mrb_state *mrb, int argc, mrb_value *argv)
|
||||
void
|
||||
mrb_sys_fail(mrb_state *mrb, const char *mesg)
|
||||
{
|
||||
mrb_raise(mrb, mrb->eRuntimeError_class, "%s", mesg);
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "%s", mesg);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -369,6 +369,6 @@ mrb_init_exception(mrb_state *mrb)
|
||||
mrb_define_method(mrb, e, "message", exc_message, ARGS_NONE());
|
||||
mrb_define_method(mrb, e, "inspect", exc_inspect, ARGS_NONE());
|
||||
|
||||
mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
|
||||
mrb->eRuntimeError_class = mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class); /* 15.2.28 */
|
||||
mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
|
||||
mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class); /* 15.2.28 */
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ gc_protect(mrb_state *mrb, struct RBasic *p)
|
||||
if (mrb->arena_idx > MRB_ARENA_SIZE) {
|
||||
/* arena overflow error */
|
||||
mrb->arena_idx = MRB_ARENA_SIZE - 4; /* force room in arena */
|
||||
mrb_raise(mrb, mrb->eRuntimeError_class, "arena overflow error");
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "arena overflow error");
|
||||
}
|
||||
mrb->arena[mrb->arena_idx++] = p;
|
||||
}
|
||||
|
||||
+3
-3
@@ -573,7 +573,7 @@ mrb_obj_instance_eval(mrb_state *mrb, mrb_value self)
|
||||
mrb_value a, b;
|
||||
|
||||
if (mrb_get_args(mrb, "|S&", &a, &b) == 1) {
|
||||
mrb_raise(mrb, mrb->eRuntimeError_class, "instance_eval with string not implemented");
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "instance_eval with string not implemented");
|
||||
}
|
||||
return mrb_yield_with_self(mrb, b, 0, 0, self);
|
||||
}
|
||||
@@ -1019,13 +1019,13 @@ mrb_f_raise(mrb_state *mrb, mrb_value self)
|
||||
argc = mrb_get_args(mrb, "|oo", &a[0], &a[1]);
|
||||
switch (argc) {
|
||||
case 0:
|
||||
mrb_raise(mrb, mrb->eRuntimeError_class, "");
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "");
|
||||
break;
|
||||
case 1:
|
||||
a[1] = mrb_check_string_type(mrb, a[0]);
|
||||
if (!mrb_nil_p(a[1])) {
|
||||
argc = 2;
|
||||
a[0] = mrb_obj_value(mrb->eRuntimeError_class);
|
||||
a[0] = mrb_obj_value(E_RUNTIME_ERROR);
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
|
||||
@@ -2143,7 +2143,7 @@ mrb_reg_regsub(mrb_state *mrb, mrb_value str, mrb_value src, struct re_registers
|
||||
break;
|
||||
}
|
||||
else {
|
||||
mrb_raise(mrb, mrb->eRuntimeError_class, "invalid group name reference format");
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "invalid group name reference format");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ str_mod_check(mrb_state *mrb, mrb_value str, char *p, mrb_int len)
|
||||
struct RString *s = mrb_str_ptr(str);
|
||||
|
||||
if (s->ptr != p || s->len != len) {
|
||||
mrb_raise(mrb, mrb->eRuntimeError_class, "string modified");
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "string modified");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1604,7 +1604,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
|
||||
CASE(OP_ERR) {
|
||||
/* Bx raise RuntimeError with message Lit(Bx) */
|
||||
mrb_value msg = pool[GETARG_Bx(i)];
|
||||
mrb_value exc = mrb_exc_new3(mrb, mrb->eRuntimeError_class, msg);
|
||||
mrb_value exc = mrb_exc_new3(mrb, E_RUNTIME_ERROR, msg);
|
||||
|
||||
mrb->exc = (struct RObject*)mrb_object(exc);
|
||||
goto L_RAISE;
|
||||
|
||||
Reference in New Issue
Block a user