1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* parse.y (yycompile): get rid of tracing while parsing.

[ruby-dev:31351]

* thread.c (ruby_suppress_tracing): added a new parameter, which
  directs to call func always.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-12-05 04:41:27 +00:00
parent 398cdd3825
commit 8ea5018d20
4 changed files with 39 additions and 24 deletions

View file

@ -1,3 +1,11 @@
Wed Dec 5 13:41:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (yycompile): get rid of tracing while parsing.
[ruby-dev:31351]
* thread.c (ruby_suppress_tracing): added a new parameter, which
directs to call func always.
Tue Dec 4 19:56:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Dec 4 19:56:42 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (iconv_convert): should not set encoding unless * ext/iconv/iconv.c (iconv_convert): should not set encoding unless

33
parse.y
View file

@ -4656,15 +4656,15 @@ parser_yyerror(struct parser_params *parser, const char *msg)
static void parser_prepare(struct parser_params *parser); static void parser_prepare(struct parser_params *parser);
#ifndef RIPPER #ifndef RIPPER
VALUE ruby_suppress_tracing(VALUE (*func)(ANYARGS), VALUE arg); VALUE ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always);
static VALUE static VALUE
debug_lines(VALUE f) debug_lines(const char *f)
{ {
if (rb_const_defined_at(rb_cObject, rb_intern("SCRIPT_LINES__"))) { if (rb_const_defined_at(rb_cObject, rb_intern("SCRIPT_LINES__"))) {
VALUE hash = rb_const_get_at(rb_cObject, rb_intern("SCRIPT_LINES__")); VALUE hash = rb_const_get_at(rb_cObject, rb_intern("SCRIPT_LINES__"));
if (TYPE(hash) == T_HASH) { if (TYPE(hash) == T_HASH) {
VALUE fname = rb_str_new2((const char *)f); VALUE fname = rb_str_new2(f);
VALUE lines = rb_hash_lookup(hash, fname); VALUE lines = rb_hash_lookup(hash, fname);
if (NIL_P(lines)) { if (NIL_P(lines)) {
lines = rb_ary_new(); lines = rb_ary_new();
@ -4676,17 +4676,18 @@ debug_lines(VALUE f)
return 0; return 0;
} }
static NODE* static VALUE
yycompile(struct parser_params *parser, const char *f, int line) yycompile0(VALUE arg, int tracing)
{ {
int n; int n;
NODE *tree; NODE *tree;
struct parser_params *parser = (struct parser_params *)arg;
if (!compile_for_eval && rb_safe_level() == 0) { if (!compile_for_eval && rb_safe_level() == 0) {
ruby_debug_lines = ruby_suppress_tracing(debug_lines, (VALUE)f); ruby_debug_lines = debug_lines(ruby_sourcefile);
if (ruby_debug_lines && line > 1) { if (ruby_debug_lines && ruby_sourceline > 0) {
VALUE str = rb_str_new(0, 0); VALUE str = rb_str_new(0, 0);
n = line - 1; n = ruby_sourceline;
do { do {
rb_ary_push(ruby_debug_lines, str); rb_ary_push(ruby_debug_lines, str);
} while (--n); } while (--n);
@ -4694,8 +4695,6 @@ yycompile(struct parser_params *parser, const char *f, int line)
} }
parser->enc = rb_enc_get(lex_input); parser->enc = rb_enc_get(lex_input);
ruby_sourcefile = rb_source_filename(f);
ruby_sourceline = line - 1;
parser_prepare(parser); parser_prepare(parser);
n = yyparse((void*)parser); n = yyparse((void*)parser);
ruby_debug_lines = 0; ruby_debug_lines = 0;
@ -4715,12 +4714,20 @@ yycompile(struct parser_params *parser, const char *f, int line)
if (scope) { if (scope) {
scope->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, scope->nd_body); scope->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, scope->nd_body);
} }
return scope; tree = scope;
} }
else { else {
return ruby_eval_tree; tree = ruby_eval_tree;
} }
return tree; return (VALUE)tree;
}
static NODE*
yycompile(struct parser_params *parser, const char *f, int line)
{
ruby_sourcefile = rb_source_filename(f);
ruby_sourceline = line - 1;
return (NODE *)ruby_suppress_tracing(yycompile0, (VALUE)parser, Qtrue);
} }
#endif /* !RIPPER */ #endif /* !RIPPER */

View file

@ -2880,7 +2880,7 @@ get_event_name(rb_event_flag_t event)
} }
} }
VALUE ruby_suppress_tracing(VALUE (*func)(ANYARGS), VALUE arg); VALUE ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always);
struct call_trace_func_args { struct call_trace_func_args {
rb_event_flag_t event; rb_event_flag_t event;
@ -2891,7 +2891,7 @@ struct call_trace_func_args {
}; };
static VALUE static VALUE
call_trace_proc(VALUE args) call_trace_proc(VALUE args, int tracing)
{ {
struct call_trace_func_args *p = (struct call_trace_func_args *)args; struct call_trace_func_args *p = (struct call_trace_func_args *)args;
VALUE eventname = rb_str_new2(get_event_name(p->event)); VALUE eventname = rb_str_new2(get_event_name(p->event));
@ -2935,17 +2935,17 @@ call_trace_func(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klas
args.self = self; args.self = self;
args.id = id; args.id = id;
args.klass = klass; args.klass = klass;
ruby_suppress_tracing(call_trace_proc, (VALUE)&args); ruby_suppress_tracing(call_trace_proc, (VALUE)&args, Qfalse);
} }
VALUE VALUE
ruby_suppress_tracing(VALUE (*func)(ANYARGS), VALUE arg) ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always)
{ {
rb_thread_t *th = GET_THREAD(); rb_thread_t *th = GET_THREAD();
int state, raised; int state, raised, tracing;
VALUE result = Qnil; VALUE result = Qnil;
if (th->tracing) { if ((tracing = th->tracing) != 0 && !always) {
return Qnil; return Qnil;
} }
else { else {
@ -2956,7 +2956,7 @@ ruby_suppress_tracing(VALUE (*func)(ANYARGS), VALUE arg)
PUSH_TAG(); PUSH_TAG();
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
result = (*func)(arg); result = (*func)(arg, tracing);
} }
if (raised) { if (raised) {
@ -2964,7 +2964,7 @@ ruby_suppress_tracing(VALUE (*func)(ANYARGS), VALUE arg)
} }
POP_TAG(); POP_TAG();
th->tracing = 0; th->tracing = tracing;
if (state) { if (state) {
JUMP_TAG(state); JUMP_TAG(state);
} }

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0" #define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-12-04" #define RUBY_RELEASE_DATE "2007-12-05"
#define RUBY_VERSION_CODE 190 #define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20071204 #define RUBY_RELEASE_CODE 20071205
#define RUBY_PATCHLEVEL 0 #define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0 #define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007 #define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 12 #define RUBY_RELEASE_MONTH 12
#define RUBY_RELEASE_DAY 4 #define RUBY_RELEASE_DAY 5
#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];