From a57949b140170cec7776d3e073fa8607e4cdcbb7 Mon Sep 17 00:00:00 2001 From: mame Date: Tue, 1 Jul 2008 16:55:30 +0000 Subject: * Add coverage measurement constant COVERAGE__. This constant is not for casual use. Usage: (1) assign {} to COVERAGE__, (2) require or load Ruby source file, and (3) COVERAGE__["sourcefilepath"] will return an array whose elements represent number of executions per line of source code. * vm_core.h: add field of coverage array to iseq. * iseq.c (prepare_iseq_build): ditto. * insns.def (trace): update coverage array. * parse.y (coverage): create and initialize coverage array. * compile.h (ADD_TRACE): add trace instruction to update covearge array. * thread.c (clear_coverage): delete coverage array when forking. Otherwise, double count of coverage may occur. * lib/coverage.rb: sample coverage measurement tool. * error.c: distinguish explicitly between parse_in_eval and mild_compile_error. * load.c: ditto. * vm_eval.c: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@17781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_eval.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vm_eval.c') diff --git a/vm_eval.c b/vm_eval.c index ef84121ef..d89f7e972 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -667,6 +667,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char rb_env_t *env = NULL; rb_block_t block; volatile int parse_in_eval; + volatile int mild_compile_error; if (file == 0) { file = rb_sourcefile(); @@ -674,6 +675,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char } parse_in_eval = th->parse_in_eval; + mild_compile_error = th->mild_compile_error; PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { rb_iseq_t *iseq; @@ -708,7 +710,9 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char /* make eval iseq */ th->parse_in_eval++; + th->mild_compile_error++; iseqval = rb_iseq_compile(src, rb_str_new2(file), INT2FIX(line)); + th->mild_compile_error--; th->parse_in_eval--; vm_set_eval_stack(th, iseqval, cref); @@ -730,6 +734,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char result = vm_eval_body(th); } POP_TAG(); + th->mild_compile_error = mild_compile_error; th->parse_in_eval = parse_in_eval; if (state) { -- cgit