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

ruby-changes:11145

From: yugui <ko1@a...>
Date: Wed, 4 Mar 2009 18:19:57 +0900 (JST)
Subject: [ruby-changes:11145] Ruby:r22749 (ruby_1_9_1): merges r22662 from trunk into ruby_1_9_1.

yugui	2009-03-04 18:19:45 +0900 (Wed, 04 Mar 2009)

  New Revision: 22749

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

  Log:
    merges r22662 from trunk into ruby_1_9_1.
    --
    * compile.c (cdhash_type, iseq_set_sequence): should not call
      methods of the argument of case, to keep the semantics of
      case/when.  [ruby-dev:38079]

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/compile.c

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 22748)
+++ ruby_1_9_1/ChangeLog	(revision 22749)
@@ -1,3 +1,9 @@
+Fri Feb 27 18:30:51 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (cdhash_type, iseq_set_sequence): should not call
+	  methods of the argument of case, to keep the semantics of
+	  case/when.  [ruby-dev:38079]
+
 Fri Feb 27 18:01:20 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* gc.c (ruby_get_stack_grow_direction): no needs to use thread
Index: ruby_1_9_1/compile.c
===================================================================
--- ruby_1_9_1/compile.c	(revision 22748)
+++ ruby_1_9_1/compile.c	(revision 22749)
@@ -1216,6 +1216,38 @@
     return COMPILE_OK;
 }
 
+static int
+cdhash_cmp(VALUE val, VALUE lit)
+{
+    if (val == lit) return 0;
+    if (SPECIAL_CONST_P(lit)) {
+	return val != lit;
+    }
+    if (SPECIAL_CONST_P(val) || BUILTIN_TYPE(val) != BUILTIN_TYPE(lit)) {
+	return -1;
+    }
+    if (BUILTIN_TYPE(lit) == T_STRING) {
+	return rb_str_hash_cmp(lit, val);
+    }
+    return !rb_eql(lit, val);
+}
+
+static int
+cdhash_hash(VALUE a)
+{
+    if (SPECIAL_CONST_P(a)) return (int)a;
+    if (TYPE(a) == T_STRING) return rb_str_hash(a);
+    {
+	VALUE hval = rb_hash(a);
+	return (int)FIX2LONG(hval);
+    }
+}
+
+static const struct st_hash_type cdhash_type = {
+    cdhash_cmp,
+    cdhash_hash,
+};
+
 /**
   ruby insn object array -> raw instruction sequence
  */
@@ -1343,6 +1375,7 @@
 			    int i;
 			    VALUE lits = operands[j];
 			    VALUE map = rb_hash_new();
+			    RHASH_TBL(map)->type = &cdhash_type;
 
 			    for (i=0; i < RARRAY_LEN(lits); i+=2) {
 				VALUE obj = rb_ary_entry(lits, i);

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

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