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

ruby-changes:11257

From: nobu <ko1@a...>
Date: Tue, 10 Mar 2009 10:54:19 +0900 (JST)
Subject: [ruby-changes:11257] Ruby:r22867 (trunk): * iseq.c (rb_iseq_compile_with_option): argument may be converted.

nobu	2009-03-10 10:54:01 +0900 (Tue, 10 Mar 2009)

  New Revision: 22867

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22867

  Log:
    * iseq.c (rb_iseq_compile_with_option): argument may be converted.

  Modified files:
    trunk/ChangeLog
    trunk/iseq.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 22866)
+++ ChangeLog	(revision 22867)
@@ -1,3 +1,7 @@
+Tue Mar 10 10:53:59 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* iseq.c (rb_iseq_compile_with_option): argument may be converted.
+
 Tue Mar 10 04:56:44 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (MINIRUBY): keep macro into Makefile.
Index: iseq.c
===================================================================
--- iseq.c	(revision 22866)
+++ iseq.c	(revision 22867)
@@ -190,8 +190,7 @@
 
     iseq->compile_data = ALLOC(struct iseq_compile_data);
     MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
-    iseq->compile_data->mark_ary = rb_ary_new();
-    RBASIC(iseq->compile_data->mark_ary)->klass = 0;
+    iseq->compile_data->mark_ary = rb_ary_tmp_new();
 
     iseq->compile_data->storage_head = iseq->compile_data->storage_current =
       (struct iseq_compile_data_storage *)
@@ -359,6 +358,7 @@
 		     VALUE parent, VALUE type,
 		     const rb_compile_option_t *option)
 {
+    /* TODO: argument check */
     return rb_iseq_new_with_bopt_and_opt(node, name, filename, parent, type,
 					   Qfalse, option);
 }
@@ -367,6 +367,7 @@
 rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE filename,
 		       VALUE parent, VALUE type, VALUE bopt)
 {
+    /* TODO: argument check */
     return rb_iseq_new_with_bopt_and_opt(node, name, filename, parent, type,
 					   bopt, &COMPILE_OPTION_DEFAULT);
 }
@@ -471,11 +472,10 @@
 }
 
 static NODE *
-compile_string(VALUE str, VALUE file, VALUE line)
+compile_string(VALUE str, const char *file, int line)
 {
     VALUE parser = rb_parser_new();
-    NODE *node = rb_parser_compile_string(parser, StringValueCStr(file),
-					  str, NUM2INT(line));
+    NODE *node = rb_parser_compile_string(parser, file, str, line);
 
     if (!node) {
 	rb_exc_raise(GET_THREAD()->errinfo);	/* TODO: check err */
@@ -487,7 +487,9 @@
 rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE line, VALUE opt)
 {
     rb_compile_option_t option;
-    NODE *node = compile_string(StringValue(src), file, line);
+    const char *fn = StringValueCStr(file);
+    int ln = NUM2INT(line);
+    NODE *node = compile_string(StringValue(src), fn, ln);
     rb_thread_t *th = GET_THREAD();
     make_compile_option(&option, opt);
 
@@ -516,8 +518,8 @@
     rb_secure(1);
 
     rb_scan_args(argc, argv, "13", &src, &file, &line, &opt);
-    file = file == Qnil ? rb_str_new2("<compiled>") : file;
-    line = line == Qnil ? INT2FIX(1) : line;
+    if (NIL_P(file)) file = rb_str_new2("<compiled>");
+    if (NIL_P(line)) line = INT2FIX(1);
 
     return rb_iseq_compile_with_option(src, file, line, opt);
 }

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

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