Raname `mrb_exc_new_str_lit()` to `mrb_exc_new_lit()`.
It uses `mrb_str_new_lit()` internally, but it doesn't need to express
it in the name of the function (macro).
MODIFY
include/mruby/error.h
include/mruby/error.h
@@ -23,7 +23,8 @@ struct RException {
MRB_API void mrb_sys_fail(mrb_state *mrb, const char *mesg);
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
-#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
+#define mrb_exc_new_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
+#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_str_lit(mrb, c, lit)
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
MRB_API mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
MRB_API mrb_value mrb_get_backtrace(mrb_state *mrb);

MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -6575,7 +6575,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
}
else {
if (mrb->exc == NULL) {
- mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
+ mrb->exc = mrb_obj_ptr(mrb_exc_new_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
}
mrb_parser_free(p);
return mrb_undef_value();
@@ -6585,7 +6585,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
mrb_parser_free(p);
if (proc == NULL) {
if (mrb->exc == NULL) {
- mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
+ mrb->exc = mrb_obj_ptr(mrb_exc_new_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
}
return mrb_undef_value();
}

MODIFY
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
@@ -12467,7 +12467,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
}
else {
if (mrb->exc == NULL) {
- mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
+ mrb->exc = mrb_obj_ptr(mrb_exc_new_lit(mrb, E_SYNTAX_ERROR, "syntax error"));
}
mrb_parser_free(p);
return mrb_undef_value();
@@ -12477,7 +12477,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
mrb_parser_free(p);
if (proc == NULL) {
if (mrb->exc == NULL) {
- mrb->exc = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
+ mrb->exc = mrb_obj_ptr(mrb_exc_new_lit(mrb, E_SCRIPT_ERROR, "codegen error"));
}
return mrb_undef_value();
}

MODIFY
src/error.c
src/error.c
@@ -622,11 +622,11 @@ mrb_init_exception(mrb_state *mrb)
script_error = mrb_define_class(mrb, "ScriptError", mrb->eException_class); /* 15.2.37 */
mrb_define_class(mrb, "SyntaxError", script_error); /* 15.2.38 */
stack_error = mrb_define_class(mrb, "SystemStackError", exception);
- mrb->stack_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, stack_error, "stack level too deep"));
+ mrb->stack_err = mrb_obj_ptr(mrb_exc_new_lit(mrb, stack_error, "stack level too deep"));
nomem_error = mrb_define_class(mrb, "NoMemoryError", exception);
- mrb->nomem_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, nomem_error, "Out of memory"));
+ mrb->nomem_err = mrb_obj_ptr(mrb_exc_new_lit(mrb, nomem_error, "Out of memory"));
#ifdef MRB_GC_FIXED_ARENA
- mrb->arena_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, nomem_error, "arena overflow error"));
+ mrb->arena_err = mrb_obj_ptr(mrb_exc_new_lit(mrb, nomem_error, "arena overflow error"));
#endif
}

MODIFY
src/load.c
src/load.c
@@ -625,7 +625,7 @@ void mrb_exc_set(mrb_state *mrb, mrb_value exc);
static void
irep_error(mrb_state *mrb)
{
- mrb_exc_set(mrb, mrb_exc_new_str_lit(mrb, E_SCRIPT_ERROR, "irep load error"));
+ mrb_exc_set(mrb, mrb_exc_new_lit(mrb, E_SCRIPT_ERROR, "irep load error"));
}
void mrb_codedump_all(mrb_state*, struct RProc*);

MODIFY
src/vm.c
src/vm.c
@@ -1016,7 +1016,7 @@ static mrb_bool
check_target_class(mrb_state *mrb)
{
if (!mrb->c->ci->target_class) {
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR, "no target class or module");
+ mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR, "no target class or module");
mrb_exc_set(mrb, exc);
return FALSE;
}
@@ -1096,7 +1096,7 @@ RETRY_TRY_BLOCK:
}
#endif
{
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "integer overflow");
+ mrb_value exc = mrb_exc_new_lit(mrb, E_RUNTIME_ERROR, "integer overflow");
mrb_exc_set(mrb, exc);
}
goto L_RAISE;
@@ -1357,7 +1357,7 @@ RETRY_TRY_BLOCK:
{
mrb_value exc;
- exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR,
+ exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,
"class or module required for rescue clause");
mrb_exc_set(mrb, exc);
goto L_RAISE;
@@ -1585,21 +1585,21 @@ RETRY_TRY_BLOCK:
mrb_assert(bidx < irep->nregs);
if (mid == 0 || !target_class) {
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
+ mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
if (target_class->tt == MRB_TT_MODULE) {
target_class = ci->target_class;
if (target_class->tt != MRB_TT_ICLASS) {
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "superclass info lost [mruby limitations]");
+ mrb_value exc = mrb_exc_new_lit(mrb, E_RUNTIME_ERROR, "superclass info lost [mruby limitations]");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
}
recv = regs[0];
if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR,
+ mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,
"self has wrong type to call super in this context");
mrb_exc_set(mrb, exc);
goto L_RAISE;
@@ -1700,7 +1700,7 @@ RETRY_TRY_BLOCK:
mrb_value exc;
L_NOSUPER:
- exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
+ exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
@@ -2066,7 +2066,7 @@ RETRY_TRY_BLOCK:
goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);
}
if (c->prev->ci == c->prev->cibase) {
- mrb_value exc = mrb_exc_new_str_lit(mrb, E_FIBER_ERROR, "double resume");
+ mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, "double resume");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
@@ -2099,7 +2099,7 @@ RETRY_TRY_BLOCK:
mrb_value exc;
L_BREAK_ERROR:
- exc = mrb_exc_new_str_lit(mrb, E_LOCALJUMP_ERROR,
+ exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,
"break from proc-closure");
mrb_exc_set(mrb, exc);
goto L_RAISE;

Raname `mrb_exc_new_str_lit()` to `mrb_exc_new_lit()`.

It uses `mrb_str_new_lit()` internally, but it doesn't need to express
it in the name of the function (macro).