mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
AST.of -e script
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6e610f5ea7
commit
f53bd45d6f
2 changed files with 10 additions and 0 deletions
5
ast.c
5
ast.c
|
@ -184,6 +184,8 @@ node_find(VALUE self, const int node_id)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
extern VALUE rb_e_script;
|
||||
|
||||
static VALUE
|
||||
script_lines(VALUE path)
|
||||
{
|
||||
|
@ -223,6 +225,9 @@ rb_ast_s_of(VALUE module, VALUE body)
|
|||
if (!NIL_P(lines = script_lines(path))) {
|
||||
node = rb_ast_parse_array(lines);
|
||||
}
|
||||
else if (RSTRING_LEN(path) == 2 && memcmp(RSTRING_PTR(path), "-e", 2) == 0) {
|
||||
node = rb_ast_parse_str(rb_e_script);
|
||||
}
|
||||
else {
|
||||
node = rb_ast_parse_file(path);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue