diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-10 05:26:52 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-10 05:26:52 +0000 |
commit | 61e4c999622d7f028a15379b5cd91ad1a25c2799 (patch) | |
tree | 6f313b2a2d4767a8e316f2522e8e59e4e57329f0 /iseq.c | |
parent | 324b6d306d7da4fd3fc109e4e9781c782b64369f (diff) | |
download | ruby-61e4c999622d7f028a15379b5cd91ad1a25c2799.tar.gz |
refactoring about source line.
* iseq.c (find_line_no): renamed to rb_iseq_line_no().
* vm_backtrace.c (calc_lineno): add a comment why we need to use "pos-1".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 21 |
1 files changed, 5 insertions, 16 deletions
@@ -1252,8 +1252,8 @@ get_insn_info(const rb_iseq_t *iseq, size_t pos) return &insns_info[i-1]; } -static unsigned int -find_line_no(const rb_iseq_t *iseq, size_t pos) +unsigned int +rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos) { const struct iseq_insn_info_entry *entry = get_insn_info(iseq, pos); @@ -1265,17 +1265,6 @@ find_line_no(const rb_iseq_t *iseq, size_t pos) } } -unsigned int -rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos) -{ - if (pos == 0) { - return find_line_no(iseq, pos); - } - else { - return find_line_no(iseq, pos - 1); - } -} - static VALUE id_to_name(ID id, VALUE default_value) { @@ -1479,8 +1468,8 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos, } { - unsigned int line_no = find_line_no(iseq, pos); - unsigned int prev = pos == 0 ? 0 : find_line_no(iseq, pos - 1); + unsigned int line_no = rb_iseq_line_no(iseq, pos); + unsigned int prev = pos == 0 ? 0 : rb_iseq_line_no(iseq, pos - 1); if (line_no && line_no != prev) { long slen = RSTRING_LEN(str); slen = (slen > 70) ? 0 : (70 - slen); @@ -2295,7 +2284,7 @@ rb_iseqw_line_trace_each(VALUE iseqw, int (*func)(int line, rb_event_flag_t *eve trace_num++; if (func) { - int line = find_line_no(iseq, pos); + int line = rb_iseq_line_no(iseq, pos); /* printf("line: %d\n", line); */ cont = (*func)(line, &events, data); if (current_events != events) { |