[前][次][番号順一覧][スレッド一覧]

ruby-changes:53438

From: nobu <ko1@a...>
Date: Sat, 10 Nov 2018 20:43:07 +0900 (JST)
Subject: [ruby-changes:53438] nobu:r65654 (trunk): AST.of -e script

nobu	2018-11-10 20:43:02 +0900 (Sat, 10 Nov 2018)

  New Revision: 65654

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65654

  Log:
    AST.of -e script

  Modified files:
    trunk/ast.c
    trunk/ruby.c
Index: ast.c
===================================================================
--- ast.c	(revision 65653)
+++ ast.c	(revision 65654)
@@ -184,6 +184,8 @@ node_find(VALUE self, const int node_id) https://github.com/ruby/ruby/blob/trunk/ast.c#L184
     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) https://github.com/ruby/ruby/blob/trunk/ast.c#L225
     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);
     }
Index: ruby.c
===================================================================
--- ruby.c	(revision 65653)
+++ ruby.c	(revision 65654)
@@ -1429,6 +1429,7 @@ opt_enc_index(VALUE enc_name) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1429
 #define rb_progname      (GET_VM()->progname)
 #define rb_orig_progname (GET_VM()->orig_progname)
 VALUE rb_argv0;
+VALUE rb_e_script;
 
 static VALUE
 false_value(void)
@@ -1856,6 +1857,10 @@ process_options(int argc, char **argv, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1857
     rb_define_readonly_boolean("$-l", opt->do_line);
     rb_define_readonly_boolean("$-a", opt->do_split);
 
+    if ((rb_e_script = opt->e_script) != 0) {
+        rb_gc_register_mark_object(opt->e_script);
+    }
+
     rb_set_safe_level(opt->safe_level);
 
     return (VALUE)iseq;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]