From d65f7458bc8b4fa4404c41713cfa1ece5260fc8a Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 22 Aug 2018 10:38:56 +0000 Subject: parse.y: remove coverage-related code fragments The code fragments that initializes coverage data were scattered into both parse.y and compile.c. parse.y allocated a coverage data, and compile.c initialize the data. To remove this cross-cutting concern, this change moves the allocation from "coverage" function of parse.y to "rb_iseq_new_top" of iseq.c. For the sake, parse.y just counts the line number of the original source code, and the number is passed via rb_ast_body_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index 935c69d434..04b55bba02 100644 --- a/iseq.c +++ b/iseq.c @@ -647,6 +647,14 @@ rb_iseq_new(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, rb_iseq_t * rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent) { + VALUE coverages = rb_get_coverages(); + if (RTEST(coverages)) { + if (ast->line_count >= 0) { + VALUE coverage = rb_default_coverage(ast->line_count); + rb_hash_aset(coverages, path, coverage); + } + } + return rb_iseq_new_with_opt(ast, name, path, realpath, INT2FIX(0), parent, ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT); } -- cgit v1.2.3