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

ruby-changes:36422

From: nobu <ko1@a...>
Date: Thu, 20 Nov 2014 02:09:53 +0900 (JST)
Subject: [ruby-changes:36422] nobu:r48503 (trunk): parse.y: ripper_new_yylval

nobu	2014-11-20 02:09:38 +0900 (Thu, 20 Nov 2014)

  New Revision: 48503

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

  Log:
    parse.y: ripper_new_yylval
    
    * parse.y (ripper_new_yylval): abstract function to create ripper
      wrapper, and make it able to hold another object.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48502)
+++ ChangeLog	(revision 48503)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov 20 02:09:34 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (ripper_new_yylval): abstract function to create ripper
+	  wrapper, and make it able to hold another object.
+
 Thu Nov 20 01:00:59 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (reg_named_capture_assign_gen): use predefined ID
Index: parse.y
===================================================================
--- parse.y	(revision 48502)
+++ parse.y	(revision 48503)
@@ -466,6 +466,20 @@ static NODE *reg_named_capture_assign_ge https://github.com/ruby/ruby/blob/trunk/parse.y#L466
 #define get_id(id) (id)
 #define get_value(val) (val)
 #else
+#define NODE_RIPPER NODE_CDECL
+
+static inline VALUE
+ripper_new_yylval(ID a, VALUE b, VALUE c)
+{
+    return (VALUE)NEW_CDECL(a, b, c);
+}
+
+static inline int
+ripper_is_node_yylval(VALUE n)
+{
+    return RB_TYPE_P(n, T_NODE) && nd_type(RNODE(n)) == NODE_RIPPER;
+}
+
 #define value_expr(node) ((void)(node))
 #define remove_begin(node) (node)
 #define rb_dvar_defined(id) 0
@@ -5142,7 +5156,7 @@ static int parser_here_document(struct p https://github.com/ruby/ruby/blob/trunk/parse.y#L5156
 static inline VALUE
 ripper_yylval_id(ID x)
 {
-    return (VALUE)NEW_LASGN(x, ID2SYM(x));
+    return ripper_new_yylval(x, ID2SYM(x), 0);
 }
 # define set_yylval_str(x) (void)(x)
 # define set_yylval_num(x) (void)(x)
@@ -10659,7 +10673,7 @@ ripper_validate_object(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/parse.y#L10673
       case T_RATIONAL:
         return x;
       case T_NODE:
-	if (nd_type(x) != NODE_LASGN) {
+	if (nd_type(x) != NODE_RIPPER) {
 	    rb_raise(rb_eArgError, "NODE given: %p", x);
 	}
 	return ((NODE *)x)->nd_rval;
@@ -10831,7 +10845,7 @@ ripper_get_id(VALUE v) https://github.com/ruby/ruby/blob/trunk/parse.y#L10845
     NODE *nd;
     if (!RB_TYPE_P(v, T_NODE)) return 0;
     nd = (NODE *)v;
-    if (nd_type(nd) != NODE_LASGN) return 0;
+    if (nd_type(nd) != NODE_RIPPER) return 0;
     return nd->nd_vid;
 }
 
@@ -10842,7 +10856,7 @@ ripper_get_value(VALUE v) https://github.com/ruby/ruby/blob/trunk/parse.y#L10856
     if (v == Qundef) return Qnil;
     if (!RB_TYPE_P(v, T_NODE)) return v;
     nd = (NODE *)v;
-    if (nd_type(nd) != NODE_LASGN) return Qnil;
+    if (nd_type(nd) != NODE_RIPPER) return Qnil;
     return nd->nd_rval;
 }
 

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

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