diff options
-rw-r--r-- | error.c | 10 | ||||
-rw-r--r-- | eval.c | 5 | ||||
-rw-r--r-- | eval_error.c | 8 | ||||
-rw-r--r-- | gc.c | 3 | ||||
-rw-r--r-- | variable.c | 3 | ||||
-rw-r--r-- | vm.c | 6 | ||||
-rw-r--r-- | vm_eval.c | 11 | ||||
-rw-r--r-- | vm_trace.c | 4 |
8 files changed, 22 insertions, 28 deletions
@@ -199,10 +199,10 @@ static VALUE warning_string(rb_encoding *enc, const char *fmt, va_list args) { VALUE str = rb_enc_str_new(0, 0, enc); - VALUE file = rb_sourcefilename(); + int line; + VALUE file = rb_source_location(&line); if (!NIL_P(file)) { - int line = rb_sourceline(); str = rb_str_append(str, file); if (line) rb_str_catf(str, ":%d", line); rb_str_cat2(str, ": "); @@ -399,8 +399,7 @@ rb_bug(const char *fmt, ...) int line = 0; if (GET_THREAD()) { - file = rb_sourcefile(); - line = rb_sourceline(); + file = rb_source_loc(&line); } report_bug(file, line, fmt, NULL); @@ -415,8 +414,7 @@ rb_bug_context(const void *ctx, const char *fmt, ...) int line = 0; if (GET_THREAD()) { - file = rb_sourcefile(); - line = rb_sourceline(); + file = rb_source_loc(&line); } report_bug(file, line, fmt, ctx); @@ -476,7 +476,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause) { VALUE e; const char *file = 0; - volatile int line = 0; + int line; int nocause = 0; if (NIL_P(mesg)) { @@ -493,8 +493,7 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause) } exc_setup_cause(mesg, cause); - file = rb_sourcefile(); - if (file) line = rb_sourceline(); + file = rb_source_loc(&line); if (file && !NIL_P(mesg)) { VALUE at; if (sysstack_error_p(mesg)) { diff --git a/eval_error.c b/eval_error.c index 82a69033b6..395b9b0196 100644 --- a/eval_error.c +++ b/eval_error.c @@ -22,8 +22,8 @@ warn_printf(const char *fmt, ...) static void error_pos(void) { - VALUE sourcefile = rb_sourcefilename(); - int sourceline = rb_sourceline(); + int sourceline; + VALUE sourcefile = rb_source_location(&sourceline); if (sourcefile) { ID caller_name; @@ -105,8 +105,8 @@ error_print(void) goto no_message; } if (NIL_P(errat)) { - const char *file = rb_sourcefile(); - int line = rb_sourceline(); + int line; + const char *file = rb_source_loc(&line); if (!file) warn_printf("%d", line); else if (!line) @@ -1756,8 +1756,7 @@ newobj_init(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_prote #endif #if GC_DEBUG - RANY(obj)->file = rb_sourcefile(); - RANY(obj)->line = rb_sourceline(); + RANY(obj)->file = rb_source_loc(&RANY(obj)->line); assert(!SPECIAL_CONST_P(obj)); /* check alignment */ #endif diff --git a/variable.c b/variable.c index 49853b64e9..048ddde069 100644 --- a/variable.c +++ b/variable.c @@ -2636,9 +2636,8 @@ setup_const_entry(rb_const_entry_t *ce, VALUE klass, VALUE val, rb_const_flag_t visibility) { ce->flag = visibility; - ce->line = rb_sourceline(); RB_OBJ_WRITE(klass, &ce->value, val); - RB_OBJ_WRITE(klass, &ce->file, rb_sourcefilename()); + RB_OBJ_WRITE(klass, &ce->file, rb_source_location(&ce->line)); } void @@ -203,16 +203,14 @@ ruby_th_dtrace_setup(rb_thread_t *th, VALUE klass, ID id, type = BUILTIN_TYPE(klass); if (type == T_CLASS || type == T_ICLASS || type == T_MODULE) { VALUE name = rb_class_path_no_cache(klass); - const char *classname; + const char *classname, *filename; const char *methodname = rb_id2name(id); - const char *filename = rb_sourcefile(); - if (methodname && filename) { + if (methodname && (filename = rb_source_loc(&args->line_no)) != 0) { if (NIL_P(name) || !(classname = StringValuePtr(name))) classname = "<unknown>"; args->classname = classname; args->methodname = methodname; args->filename = filename; - args->line_no = rb_sourceline(); args->klass = klass; args->name = name; return TRUE; @@ -1252,7 +1252,8 @@ rb_each(VALUE obj) } static VALUE -eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_arg, volatile VALUE file, volatile int line) +eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_arg, + VALUE filename, int lineno) { int state; VALUE result = Qundef; @@ -1264,11 +1265,11 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_ volatile int mild_compile_error; rb_cref_t *orig_cref; VALUE crefval; + volatile VALUE file; + volatile int line; - if (file == 0) { - file = rb_sourcefilename(); - line = rb_sourceline(); - } + file = filename ? filename : rb_source_location(&lineno); + line = lineno; parse_in_eval = th->parse_in_eval; mild_compile_error = th->mild_compile_error; diff --git a/vm_trace.c b/vm_trace.c index 1ce11f9548..bf318b1960 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -607,11 +607,11 @@ get_event_id(rb_event_flag_t event) static void call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass) { - const char *srcfile = rb_sourcefile(); + int line; + const char *srcfile = rb_source_loc(&line); VALUE eventname = rb_str_new2(get_event_name(event)); VALUE filename = srcfile ? rb_str_new2(srcfile) : Qnil; VALUE argv[6]; - int line = rb_sourceline(); rb_thread_t *th = GET_THREAD(); if (!klass) { |