summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-05 04:41:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-05 04:41:27 +0000
commit8ea5018d20c3deed76c3347c61f11fc480ebe712 (patch)
treed57393aeb7a2a6d2aea6a3cb74611039870d2a44 /parse.y
parent398cdd3825d793f5ed7f7e7e34fc84768cd2af20 (diff)
* 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
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y33
1 files changed, 20 insertions, 13 deletions
diff --git a/parse.y b/parse.y
index 12d2e8893b..43d45c6826 100644
--- a/parse.y
+++ b/parse.y
@@ -4656,15 +4656,15 @@ parser_yyerror(struct parser_params *parser, const char *msg)
static void parser_prepare(struct parser_params *parser);
#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
-debug_lines(VALUE f)
+debug_lines(const char *f)
{
if (rb_const_defined_at(rb_cObject, rb_intern("SCRIPT_LINES__"))) {
VALUE hash = rb_const_get_at(rb_cObject, rb_intern("SCRIPT_LINES__"));
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);
if (NIL_P(lines)) {
lines = rb_ary_new();
@@ -4676,17 +4676,18 @@ debug_lines(VALUE f)
return 0;
}
-static NODE*
-yycompile(struct parser_params *parser, const char *f, int line)
+static VALUE
+yycompile0(VALUE arg, int tracing)
{
int n;
NODE *tree;
+ struct parser_params *parser = (struct parser_params *)arg;
if (!compile_for_eval && rb_safe_level() == 0) {
- ruby_debug_lines = ruby_suppress_tracing(debug_lines, (VALUE)f);
- if (ruby_debug_lines && line > 1) {
+ ruby_debug_lines = debug_lines(ruby_sourcefile);
+ if (ruby_debug_lines && ruby_sourceline > 0) {
VALUE str = rb_str_new(0, 0);
- n = line - 1;
+ n = ruby_sourceline;
do {
rb_ary_push(ruby_debug_lines, str);
} while (--n);
@@ -4694,8 +4695,6 @@ yycompile(struct parser_params *parser, const char *f, int line)
}
parser->enc = rb_enc_get(lex_input);
- ruby_sourcefile = rb_source_filename(f);
- ruby_sourceline = line - 1;
parser_prepare(parser);
n = yyparse((void*)parser);
ruby_debug_lines = 0;
@@ -4715,12 +4714,20 @@ yycompile(struct parser_params *parser, const char *f, int line)
if (scope) {
scope->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, scope->nd_body);
}
- return scope;
+ tree = scope;
}
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 */