* ruby.c (process_options): decrement parse_in_eval to recognize
parsing main or normal eval script. * compile.c (rb_parse_in_main): return 1 if parsing main script. (if parse_in_eval is negative value, it means main script) * parse.y (yycompile0): check rb_parse_in_main() to accumulate script text. Bug #848 [ruby-core:20450] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e317b93409
commit
e40928733d
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Fri Jan 16 01:09:37 2009 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* ruby.c (process_options): decrement parse_in_eval to recognize
|
||||||
|
parsing main or normal eval script.
|
||||||
|
|
||||||
|
* compile.c (rb_parse_in_main): return 1 if parsing main script.
|
||||||
|
(if parse_in_eval is negative value, it means main script)
|
||||||
|
|
||||||
|
* parse.y (yycompile0): check rb_parse_in_main() to accumulate
|
||||||
|
script text. Bug #848 [ruby-core:20450]
|
||||||
|
|
||||||
Fri Jan 16 00:57:34 2009 Koichi Sasada <ko1@atdot.net>
|
Fri Jan 16 00:57:34 2009 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* lib/debug.rb: as wanabe-san pointed out,
|
* lib/debug.rb: as wanabe-san pointed out,
|
||||||
|
@ -5350,3 +5350,9 @@ rb_parse_in_eval(void)
|
|||||||
{
|
{
|
||||||
return GET_THREAD()->parse_in_eval != 0;
|
return GET_THREAD()->parse_in_eval != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
rb_parse_in_main(void)
|
||||||
|
{
|
||||||
|
return GET_THREAD()->parse_in_eval < 0;
|
||||||
|
}
|
||||||
|
3
parse.y
3
parse.y
@ -437,6 +437,7 @@ static void fixup_nodes(NODE **);
|
|||||||
extern int rb_dvar_defined(ID);
|
extern int rb_dvar_defined(ID);
|
||||||
extern int rb_local_defined(ID);
|
extern int rb_local_defined(ID);
|
||||||
extern int rb_parse_in_eval(void);
|
extern int rb_parse_in_eval(void);
|
||||||
|
extern int rb_prase_in_main(void);
|
||||||
|
|
||||||
static VALUE reg_compile_gen(struct parser_params*, VALUE, int);
|
static VALUE reg_compile_gen(struct parser_params*, VALUE, int);
|
||||||
#define reg_compile(str,options) reg_compile_gen(parser, str, options)
|
#define reg_compile(str,options) reg_compile_gen(parser, str, options)
|
||||||
@ -4983,7 +4984,7 @@ yycompile0(VALUE arg, int tracing)
|
|||||||
NODE *tree;
|
NODE *tree;
|
||||||
struct parser_params *parser = (struct parser_params *)arg;
|
struct parser_params *parser = (struct parser_params *)arg;
|
||||||
|
|
||||||
if (!compile_for_eval && rb_safe_level() == 0) {
|
if ((!compile_for_eval || rb_parse_in_main()) && rb_safe_level() == 0) {
|
||||||
ruby_debug_lines = debug_lines(ruby_sourcefile);
|
ruby_debug_lines = debug_lines(ruby_sourcefile);
|
||||||
if (ruby_debug_lines && ruby_sourceline > 0) {
|
if (ruby_debug_lines && ruby_sourceline > 0) {
|
||||||
VALUE str = STR_NEW0();
|
VALUE str = STR_NEW0();
|
||||||
|
4
ruby.c
4
ruby.c
@ -1343,10 +1343,10 @@ process_options(VALUE arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define PREPARE_PARSE_MAIN(expr) do { \
|
#define PREPARE_PARSE_MAIN(expr) do { \
|
||||||
th->parse_in_eval++; \
|
th->parse_in_eval--; \
|
||||||
th->base_block = &env->block; \
|
th->base_block = &env->block; \
|
||||||
expr; \
|
expr; \
|
||||||
th->parse_in_eval--; \
|
th->parse_in_eval++; \
|
||||||
th->base_block = 0; \
|
th->base_block = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user