From 74f4445df249bbc846d06a77c7796298e6aea9c1 Mon Sep 17 00:00:00 2001 From: mame Date: Thu, 3 Jul 2008 12:55:12 +0000 Subject: * ext/coverage/coverage.c, ext/coverage/extconf.rb: eliminate COVERAGE__ and introduce coverage.so instead. How to measure coverage: (1) require "coverage.so", (2) require or load Ruby source file, and (3) Coverage.result will return the same hash as COVERAGE__. [ruby-dev:35324] * thread.c (rb_enable_coverages): start coverage measurement by using rb_add_event_hook. * thread.c (rb_get_coverages): returns current results of coverage measurement. * include/ruby/intern.h: add prototype for above two functions. * vm_core.h, vm.c: add field of coverages to rb_vm_t. * insns.def (trace): remove special handling for COVERAGE__. * iseq.c (prepare_iseq_build): switch COVERAGE__ to rb_get_coverages(). * parse.y (coverage): ditto. * thread.c (clear_coverage): ditto. * lib/coverage.rb: use coverage.so instead of COVERAGE__. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@17857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 54d728a1d..4d181af86 100644 --- a/parse.y +++ b/parse.y @@ -4672,17 +4672,15 @@ debug_lines(const char *f) static VALUE coverage(const char *f, int n) { - if (rb_const_defined_at(rb_cObject, rb_intern("COVERAGE__"))) { - VALUE hash = rb_const_get_at(rb_cObject, rb_intern("COVERAGE__")); - if (TYPE(hash) == T_HASH) { - VALUE fname = rb_str_new2(f); - VALUE lines = rb_ary_new2(n); - int i; - for (i = 0; i < n; i++) RARRAY_PTR(lines)[i] = Qnil; - RARRAY(lines)->len = n; - rb_hash_aset(hash, fname, lines); - return lines; - } + VALUE coverages = rb_get_coverages(); + if (RTEST(coverages)) { + VALUE fname = rb_str_new2(f); + VALUE lines = rb_ary_new2(n); + int i; + for (i = 0; i < n; i++) RARRAY_PTR(lines)[i] = Qnil; + RARRAY(lines)->len = n; + rb_hash_aset(coverages, fname, lines); + return lines; } return 0; } -- cgit