diff --git a/iseq.c b/iseq.c index b6b42821e2..e9d7d85301 100644 --- a/iseq.c +++ b/iseq.c @@ -771,6 +771,15 @@ rb_iseq_method_name(const rb_iseq_t *iseq) } } +void +rb_iseq_code_range(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column) +{ + if (first_lineno) *first_lineno = iseq->body->location.code_range.first_loc.lineno; + if (first_column) *first_column = iseq->body->location.code_range.first_loc.column; + if (last_lineno) *last_lineno = iseq->body->location.code_range.last_loc.lineno;; + if (last_column) *last_column = iseq->body->location.code_range.last_loc.column; +} + VALUE rb_iseq_coverage(const rb_iseq_t *iseq) { diff --git a/iseq.h b/iseq.h index fb0a5d0d29..17066cb4bd 100644 --- a/iseq.h +++ b/iseq.h @@ -189,6 +189,7 @@ VALUE rb_iseq_label(const rb_iseq_t *iseq); VALUE rb_iseq_base_label(const rb_iseq_t *iseq); VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq); VALUE rb_iseq_method_name(const rb_iseq_t *iseq); +void rb_iseq_code_range(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column); /* proc.c */ const rb_iseq_t *rb_method_iseq(VALUE body);