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

ruby-changes:36782

From: nobu <ko1@a...>
Date: Tue, 16 Dec 2014 14:54:47 +0900 (JST)
Subject: [ruby-changes:36782] nobu:r48863 (trunk): compile.c: wrap funcptr

nobu	2014-12-16 14:54:32 +0900 (Tue, 16 Dec 2014)

  New Revision: 48863

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

  Log:
    compile.c: wrap funcptr
    
    * compile.c (iseq_build_from_ary_body): enclose funcptr with
      Integer as raw pointer cannot appear in an Array.
    
    * iseq.c (iseq_data_to_ary): extract funcptr from Integer.

  Modified files:
    trunk/compile.c
    trunk/iseq.c
Index: iseq.c
===================================================================
--- iseq.c	(revision 48862)
+++ iseq.c	(revision 48863)
@@ -1987,7 +1987,14 @@ iseq_data_to_ary(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1987
 		}
 		break;
 	      case TS_FUNCPTR:
-		rb_ary_push(ary, Qnil);
+		{
+#if SIZEOF_VALUE <= SIZEOF_LONG
+		    VALUE val = LONG2NUM((SIGNED_VALUE)*seq);
+#else
+		    VALUE val = LL2NUM((SIGNED_VALUE)*seq);
+#endif
+		    rb_ary_push(ary, val);
+		}
 		break;
 	      default:
 		rb_bug("unknown operand: %c", insn_op_type(insn, j));
Index: compile.c
===================================================================
--- compile.c	(revision 48862)
+++ compile.c	(revision 48863)
@@ -5964,8 +5964,14 @@ iseq_build_from_ary_body(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L5964
 			}
 			break;
 		      case TS_FUNCPTR:
-			if (!RTEST(op)) rb_raise(rb_eArgError, "cannot load funcptr");
-			argv[j] = op;
+			{
+#if SIZEOF_VALUE <= SIZEOF_LONG
+			    long funcptr = NUM2LONG(op);
+#else
+			    LONG_LONG funcptr = NUM2LL(op);
+#endif
+			    argv[j] = (VALUE)funcptr;
+			}
 			break;
 		      default:
 			rb_raise(rb_eSyntaxError, "unknown operand: %c", insn_op_type((VALUE)insn_id, j));

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

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