summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--iseq.c5
-rw-r--r--iseq.h1
-rw-r--r--parse.y7
4 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3b02b53e68..f2eabfe237 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Mar 10 17:34:16 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * iseq.c (prepare_iseq_build): enable coverage by coverage_enabled
+ option, not by parse_in_eval flag in the thread context.
+
+ * iseq.h (rb_compile_option_struct): add coverage_enabled flag.
+
+ * parse.y (yycompile0): set coverage_enabled flag if coverage
+ array is made.
+
Thu Mar 10 15:19:54 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* node.c (dump_option): nd_compile_option is a hidden hash object,
diff --git a/iseq.c b/iseq.c
index e0a33d6288..01e6d44add 100644
--- a/iseq.c
+++ b/iseq.c
@@ -298,7 +298,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
ISEQ_COMPILE_DATA(iseq)->option = option;
ISEQ_COMPILE_DATA(iseq)->last_coverable_line = -1;
- if (!GET_THREAD()->parse_in_eval) {
+ if (option->coverage_enabled) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages)) {
coverage = rb_hash_lookup(coverages, path);
@@ -336,6 +336,7 @@ static rb_compile_option_t COMPILE_OPTION_DEFAULT = {
OPT_TRACE_INSTRUCTION, /* int trace_instruction */
OPT_FROZEN_STRING_LITERAL,
OPT_DEBUG_FROZEN_STRING_LITERAL,
+ TRUE, /* coverage_enabled */
};
static const rb_compile_option_t COMPILE_OPTION_FALSE = {0};
@@ -362,6 +363,7 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
SET_COMPILE_OPTION(option, opt, trace_instruction);
SET_COMPILE_OPTION(option, opt, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
+ SET_COMPILE_OPTION(option, opt, coverage_enabled);
SET_COMPILE_OPTION_NUM(option, opt, debug_level);
#undef SET_COMPILE_OPTION
#undef SET_COMPILE_OPTION_NUM
@@ -416,6 +418,7 @@ make_compile_option_value(rb_compile_option_t *option)
SET_COMPILE_OPTION(option, opt, trace_instruction);
SET_COMPILE_OPTION(option, opt, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
+ SET_COMPILE_OPTION(option, opt, coverage_enabled);
SET_COMPILE_OPTION_NUM(option, opt, debug_level);
}
#undef SET_COMPILE_OPTION
diff --git a/iseq.h b/iseq.h
index 11e67352f8..e9c97dccbe 100644
--- a/iseq.h
+++ b/iseq.h
@@ -134,6 +134,7 @@ struct rb_compile_option_struct {
unsigned int trace_instruction: 1;
unsigned int frozen_string_literal: 1;
unsigned int debug_frozen_string_literal: 1;
+ unsigned int coverage_enabled: 1;
int debug_level;
};
diff --git a/parse.y b/parse.y
index 3b5f5f8ed8..d9663853b3 100644
--- a/parse.y
+++ b/parse.y
@@ -5516,6 +5516,7 @@ yycompile0(VALUE arg)
int n;
NODE *tree;
struct parser_params *parser = (struct parser_params *)arg;
+ VALUE cov = Qfalse;
if (!compile_for_eval && rb_safe_level() == 0) {
ruby_debug_lines = debug_lines(ruby_sourcefile_string);
@@ -5529,6 +5530,7 @@ yycompile0(VALUE arg)
if (!e_option_supplied(parser)) {
ruby_coverage = coverage(ruby_sourcefile_string, ruby_sourceline);
+ cov = Qtrue;
}
}
@@ -5559,7 +5561,10 @@ yycompile0(VALUE arg)
tree = NEW_NIL();
}
else {
- tree->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, tree->nd_body, parser->compile_option);
+ VALUE opt = parser->compile_option;
+ if (!opt) opt = rb_obj_hide(rb_ident_hash_new());
+ rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov);
+ tree->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, tree->nd_body, opt);
}
return (VALUE)tree;
}