use rb_source_loc and rb_source_location
* error.c, eval.c, eval_error.c, gc.c, variable.c, vm.c, vm_eval.c, vm_trace.c: use rb_source_loc/rb_source_location instead of combination of rb_sourcefile/rb_sourcefilename and rb_sourceline. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
954224f3c5
commit
1546ffed49
10
error.c
10
error.c
@ -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);
|
||||
|
5
eval.c
5
eval.c
@ -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)) {
|
||||
|
@ -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)
|
||||
|
3
gc.c
3
gc.c
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
6
vm.c
6
vm.c
@ -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;
|
||||
|
11
vm_eval.c
11
vm_eval.c
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user