1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

vm_eval.c: fstring format

* vm_eval.c (make_no_method_exception): make format string
  fstring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-01-13 08:05:07 +00:00
parent 22121544e1
commit be61b2b12d
3 changed files with 12 additions and 11 deletions

View file

@ -680,15 +680,15 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj)
} }
static VALUE static VALUE
make_no_method_exception(VALUE exc, const char *format, VALUE obj, int argc, const VALUE *argv) make_no_method_exception(VALUE exc, VALUE format, VALUE obj, int argc, const VALUE *argv)
{ {
int n = 0; int n = 0;
VALUE args[3]; VALUE args[3];
if (!format) { if (!format) {
format = "undefined method `%s' for %s%s%s"; format = rb_fstring_cstr("undefined method `%s' for %s%s%s");
} }
args[n++] = rb_name_err_mesg_new(rb_str_new_cstr(format), obj, argv[0]); args[n++] = rb_name_err_mesg_new(format, obj, argv[0]);
args[n++] = argv[0]; args[n++] = argv[0];
if (exc == rb_eNoMethodError) { if (exc == rb_eNoMethodError) {
args[n++] = rb_ary_new4(argc - 1, argv + 1); args[n++] = rb_ary_new4(argc - 1, argv + 1);
@ -701,7 +701,7 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
enum method_missing_reason last_call_status) enum method_missing_reason last_call_status)
{ {
VALUE exc = rb_eNoMethodError; VALUE exc = rb_eNoMethodError;
const char *format = 0; VALUE format = 0;
if (UNLIKELY(argc == 0)) { if (UNLIKELY(argc == 0)) {
rb_raise(rb_eArgError, "no method name given"); rb_raise(rb_eArgError, "no method name given");
@ -715,17 +715,17 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
stack_check(); stack_check();
if (last_call_status & MISSING_PRIVATE) { if (last_call_status & MISSING_PRIVATE) {
format = "private method `%s' called for %s%s%s"; format = rb_fstring_cstr("private method `%s' called for %s%s%s");
} }
else if (last_call_status & MISSING_PROTECTED) { else if (last_call_status & MISSING_PROTECTED) {
format = "protected method `%s' called for %s%s%s"; format = rb_fstring_cstr("protected method `%s' called for %s%s%s");
} }
else if (last_call_status & MISSING_VCALL) { else if (last_call_status & MISSING_VCALL) {
format = "undefined local variable or method `%s' for %s%s%s"; format = rb_fstring_cstr("undefined local variable or method `%s' for %s%s%s");
exc = rb_eNameError; exc = rb_eNameError;
} }
else if (last_call_status & MISSING_SUPER) { else if (last_call_status & MISSING_SUPER) {
format = "super: no superclass method `%s' for %s%s%s"; format = rb_fstring_cstr("super: no superclass method `%s' for %s%s%s");
} }
{ {
@ -920,7 +920,7 @@ send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope)
id = rb_check_id(&vid); id = rb_check_id(&vid);
if (!id) { if (!id) {
if (rb_method_basic_definition_p(CLASS_OF(recv), idMethodMissing)) { if (rb_method_basic_definition_p(CLASS_OF(recv), idMethodMissing)) {
VALUE exc = make_no_method_exception(rb_eNoMethodError, NULL, VALUE exc = make_no_method_exception(rb_eNoMethodError, 0,
recv, argc, argv); recv, argc, argv);
rb_exc_raise(exc); rb_exc_raise(exc);
} }

View file

@ -1825,7 +1825,8 @@ vm_call_opt_send(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling
if (!(ci->mid = rb_check_id(&sym))) { if (!(ci->mid = rb_check_id(&sym))) {
if (rb_method_basic_definition_p(CLASS_OF(calling->recv), idMethodMissing)) { if (rb_method_basic_definition_p(CLASS_OF(calling->recv), idMethodMissing)) {
VALUE exc = make_no_method_exception(rb_eNoMethodError, NULL, calling->recv, rb_long2int(calling->argc), &TOPN(i)); VALUE exc = make_no_method_exception(rb_eNoMethodError, 0, calling->recv,
rb_long2int(calling->argc), &TOPN(i));
rb_exc_raise(exc); rb_exc_raise(exc);
} }
TOPN(i) = rb_str_intern(sym); TOPN(i) = rb_str_intern(sym);

View file

@ -185,7 +185,7 @@ enum vm_regan_acttype {
#define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state) #define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state)
#define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state) #define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state)
static VALUE make_no_method_exception(VALUE exc, const char *format, static VALUE make_no_method_exception(VALUE exc, VALUE format,
VALUE obj, int argc, const VALUE *argv); VALUE obj, int argc, const VALUE *argv);
static inline struct vm_throw_data * static inline struct vm_throw_data *