[前][次][番号順一覧][スレッド一覧]

ruby-changes:40317

From: nobu <ko1@a...>
Date: Sat, 31 Oct 2015 10:02:36 +0900 (JST)
Subject: [ruby-changes:40317] nobu:r52398 (trunk): use rb_source_loc and rb_source_location

nobu	2015-10-31 10:02:26 +0900 (Sat, 31 Oct 2015)

  New Revision: 52398

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52398

  Log:
    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.

  Modified files:
    trunk/error.c
    trunk/eval.c
    trunk/eval_error.c
    trunk/gc.c
    trunk/variable.c
    trunk/vm.c
    trunk/vm_eval.c
    trunk/vm_trace.c
Index: variable.c
===================================================================
--- variable.c	(revision 52397)
+++ variable.c	(revision 52398)
@@ -2636,9 +2636,8 @@ setup_const_entry(rb_const_entry_t *ce, https://github.com/ruby/ruby/blob/trunk/variable.c#L2636
 		  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
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 52397)
+++ eval_error.c	(revision 52398)
@@ -22,8 +22,8 @@ warn_printf(const char *fmt, ...) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L22
 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) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L105
 	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)
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 52397)
+++ vm_eval.c	(revision 52398)
@@ -1252,7 +1252,8 @@ rb_each(VALUE obj) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1252
 }
 
 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 https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1265
     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;
Index: eval.c
===================================================================
--- eval.c	(revision 52397)
+++ eval.c	(revision 52398)
@@ -476,7 +476,7 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L476
 {
     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 https://github.com/ruby/ruby/blob/trunk/eval.c#L493
     }
     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)) {
Index: gc.c
===================================================================
--- gc.c	(revision 52397)
+++ gc.c	(revision 52398)
@@ -1756,8 +1756,7 @@ newobj_init(VALUE klass, VALUE flags, VA https://github.com/ruby/ruby/blob/trunk/gc.c#L1756
 #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
 
Index: error.c
===================================================================
--- error.c	(revision 52397)
+++ error.c	(revision 52398)
@@ -199,10 +199,10 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/error.c#L199
 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, ...) https://github.com/ruby/ruby/blob/trunk/error.c#L399
     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 ch https://github.com/ruby/ruby/blob/trunk/error.c#L414
     int line = 0;
 
     if (GET_THREAD()) {
-	file = rb_sourcefile();
-	line = rb_sourceline();
+	file = rb_source_loc(&line);
     }
 
     report_bug(file, line, fmt, ctx);
Index: vm_trace.c
===================================================================
--- vm_trace.c	(revision 52397)
+++ vm_trace.c	(revision 52398)
@@ -607,11 +607,11 @@ get_event_id(rb_event_flag_t event) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L607
 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) {
Index: vm.c
===================================================================
--- vm.c	(revision 52397)
+++ vm.c	(revision 52398)
@@ -203,16 +203,14 @@ ruby_th_dtrace_setup(rb_thread_t *th, VA https://github.com/ruby/ruby/blob/trunk/vm.c#L203
     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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]