* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
88d63339b3
commit
506af65de1
@ -1,3 +1,9 @@
|
|||||||
|
Fri Feb 27 18:30:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Fri Feb 27 18:01:20 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* gc.c (ruby_get_stack_grow_direction): no needs to use thread
|
* gc.c (ruby_get_stack_grow_direction): no needs to use thread
|
||||||
|
33
compile.c
33
compile.c
@ -1216,6 +1216,38 @@ iseq_set_local_table(rb_iseq_t *iseq, ID *tbl)
|
|||||||
return COMPILE_OK;
|
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
|
ruby insn object array -> raw instruction sequence
|
||||||
*/
|
*/
|
||||||
@ -1343,6 +1375,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
|||||||
int i;
|
int i;
|
||||||
VALUE lits = operands[j];
|
VALUE lits = operands[j];
|
||||||
VALUE map = rb_hash_new();
|
VALUE map = rb_hash_new();
|
||||||
|
RHASH_TBL(map)->type = &cdhash_type;
|
||||||
|
|
||||||
for (i=0; i < RARRAY_LEN(lits); i+=2) {
|
for (i=0; i < RARRAY_LEN(lits); i+=2) {
|
||||||
VALUE obj = rb_ary_entry(lits, i);
|
VALUE obj = rb_ary_entry(lits, i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user