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

ruby-changes:37818

From: ko1 <ko1@a...>
Date: Mon, 9 Mar 2015 06:53:22 +0900 (JST)
Subject: [ruby-changes:37818] ko1:r49899 (trunk): * vm_insnhelper.h: define struct SVAR for SVAR.

ko1	2015-03-09 06:53:05 +0900 (Mon, 09 Mar 2015)

  New Revision: 49899

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

  Log:
    * vm_insnhelper.h: define struct SVAR for SVAR.
      This data type is also same layout of NODE (NODE_IF).
    * vm_insnhelper.c: catch up this change.

  Modified files:
    trunk/ChangeLog
    trunk/vm_insnhelper.c
    trunk/vm_insnhelper.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49898)
+++ ChangeLog	(revision 49899)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Mar 09 06:44:48 2015  Koichi Sasada  <ko1@a...>
+
+	* vm_insnhelper.h: define struct SVAR for SVAR.
+	  This data type is also same layout of NODE (NODE_IF).
+
+	* vm_insnhelper.c: catch up this change.
+
 Mon Mar  9 06:43:21 2015  Koichi Sasada  <ko1@a...>
 
 	* vm_insnhelper.c (lep_svar_set): add WBs.
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 49898)
+++ vm_insnhelper.c	(revision 49899)
@@ -141,7 +141,7 @@ rb_error_arity(int argc, int min, int ma https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L141
 
 /* svar */
 
-static inline NODE **
+static inline struct SVAR **
 lep_svar_place(rb_thread_t *th, const VALUE *lep)
 {
     const VALUE *svar;
@@ -153,25 +153,25 @@ lep_svar_place(rb_thread_t *th, const VA https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L153
 	svar = &th->root_svar;
     }
 
-    return (NODE **)svar;
+    return (struct SVAR **)svar;
 }
 
 static VALUE
 lep_svar_get(rb_thread_t *th, const VALUE *lep, rb_num_t key)
 {
-    NODE ** const svar_place = lep_svar_place(th, lep);
-    const NODE * const svar = *svar_place;
+    struct SVAR ** const svar_place = lep_svar_place(th, lep);
+    const struct SVAR *const svar = *svar_place;
 
     if (NIL_P((VALUE)svar)) return Qnil;
     if (nd_type(svar) == NODE_CREF) return Qnil;
 
     switch (key) {
       case VM_SVAR_LASTLINE:
-	return svar->u1.value;
+	return svar->lastline;
       case VM_SVAR_BACKREF:
-	return svar->u2.value;
+	return svar->backref;
       default: {
-	const VALUE ary = svar->u3.value;
+	const VALUE ary = svar->others;
 
 	if (NIL_P(ary)) {
 	    return Qnil;
@@ -186,31 +186,31 @@ lep_svar_get(rb_thread_t *th, const VALU https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L186
 static void
 lep_svar_set(rb_thread_t *th, VALUE *lep, rb_num_t key, VALUE val)
 {
-    NODE **svar_place = (NODE **)lep_svar_place(th, lep);
-    NODE *svar = *svar_place;
+    struct SVAR **svar_place = lep_svar_place(th, lep);
+    struct SVAR *svar = *svar_place;
 
     if (NIL_P((VALUE)svar)) {
-	svar = *svar_place = NEW_IF(Qnil, Qnil, Qnil);
-	svar->nd_reserved = Qfalse;
+	svar = *svar_place = (struct SVAR *)NEW_IF(Qnil, Qnil, Qnil);
+	svar->cref = NULL;
     }
     else if (nd_type(svar) == NODE_CREF) {
 	const rb_cref_t *cref = (rb_cref_t *)svar;
-	svar = *svar_place = NEW_IF(Qnil, Qnil, Qnil);
-	RB_OBJ_WRITE(svar, &svar->nd_reserved, (VALUE)cref);
+	svar = *svar_place = (struct SVAR *)NEW_IF(Qnil, Qnil, Qnil);
+	RB_OBJ_WRITE(svar, &svar->cref, (VALUE)cref);
     }
 
     switch (key) {
       case VM_SVAR_LASTLINE:
-	RB_OBJ_WRITE(svar, &svar->u1.value, val);
+	RB_OBJ_WRITE(svar, &svar->lastline, val);
 	return;
       case VM_SVAR_BACKREF:
-	RB_OBJ_WRITE(svar, &svar->u2.value, val);
+	RB_OBJ_WRITE(svar, &svar->backref, val);
 	return;
       default: {
-	VALUE ary = svar->u3.value;
+	VALUE ary = svar->others;
 
 	if (NIL_P(ary)) {
-	    RB_OBJ_WRITE(svar, &svar->u3.value, ary = rb_ary_new());
+	    RB_OBJ_WRITE(svar, &svar->others, ary = rb_ary_new());
 	}
 	rb_ary_store(ary, key - VM_SVAR_EXTRA_START, val);
       }
@@ -265,7 +265,7 @@ ep_cref(const VALUE *ep) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L265
 	return (rb_cref_t *)svar;
     }
     else {
-	return (rb_cref_t *)((NODE *)svar)->nd_reserved;
+	return (rb_cref_t *)((struct SVAR *)svar)->cref;
     }
 }
 
Index: vm_insnhelper.h
===================================================================
--- vm_insnhelper.h	(revision 49898)
+++ vm_insnhelper.h	(revision 49899)
@@ -229,5 +229,14 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L229
 static VALUE make_no_method_exception(VALUE exc, const char *format,
 				      VALUE obj, int argc, const VALUE *argv);
 
+/* SVAR */
+
+struct SVAR {
+    VALUE flags;
+    const rb_cref_t *cref;
+    VALUE lastline;
+    VALUE backref;
+    VALUE others;
+};
 
 #endif /* RUBY_INSNHELPER_H */

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

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