aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2023-01-21 13:51:59 -0800
committerGitHub <noreply@github.com>2023-01-22 10:51:59 +1300
commit2c93c554019ebdc394d3c51c6d925620d3005f84 (patch)
tree492a8bc798b885a25908bf2ef662e60232e02da8 /iseq.c
parent3e7fdf29532333667271f01fff84c10ec80822e1 (diff)
downloadruby-2c93c554019ebdc394d3c51c6d925620d3005f84.tar.gz
Ensure main file has default coverage if required. (#7169)
* Extract common code for coverage setup.
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/iseq.c b/iseq.c
index 97b9da9339..49d907b0a8 100644
--- a/iseq.c
+++ b/iseq.c
@@ -835,13 +835,20 @@ iseq_setup_coverage(VALUE coverages, VALUE path, const rb_ast_body_t *ast, int l
return Qnil;
}
-rb_iseq_t *
-rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
+static inline void
+iseq_new_setup_coverage(VALUE path, const rb_ast_body_t *ast, int line_offset)
{
VALUE coverages = rb_get_coverages();
+
if (RTEST(coverages)) {
iseq_setup_coverage(coverages, path, ast, 0);
}
+}
+
+rb_iseq_t *
+rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent)
+{
+ iseq_new_setup_coverage(path, ast, 0);
return rb_iseq_new_with_opt(ast, name, path, realpath, 0, parent, 0,
ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT);
@@ -850,6 +857,8 @@ rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath
rb_iseq_t *
rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
{
+ iseq_new_setup_coverage(path, ast, 0);
+
return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
path, realpath, 0,
parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE);