示例#1
0
文件: hash.c 项目: Jaharmi/MacRuby
static VALUE
rhash_values_at(VALUE hash, SEL sel, int argc, VALUE *argv)
{
    VALUE result = rb_ary_new2(argc);
    for (int i = 0; i < argc; i++) {
	rb_ary_push(result, rhash_aref(hash, 0, argv[i]));
    }
    return result;
}
示例#2
0
文件: hash.c 项目: Jaharmi/MacRuby
static int
update_block_i(VALUE key, VALUE value, VALUE hash)
{
    if (key != Qundef) {
	if (rhash_has_key(hash, 0, key)) {
	    value = rb_yield_values(3, key, rhash_aref(hash, 0, key), value);
	    ST_STOP_IF_BROKEN();
	}
	rhash_aset(hash, 0, key, value);
    }
    return ST_CONTINUE;
}
示例#3
0
文件: kernel.c 项目: silicon/MacRuby
PRIMITIVE VALUE
vm_fast_aref(VALUE obj, VALUE other, unsigned char overriden)
{
    if (overriden == 0 && !SPECIAL_CONST_P(obj)) {
	VALUE klass = *(VALUE *)obj;
	if (klass == rb_cRubyArray) {
	    if (FIXNUM_P(other)) {
		return rary_entry(obj, FIX2LONG(other));
	    }
	}
	else if (klass == rb_cRubyHash) {
	    return rhash_aref(obj, 0, other);
	}
    }
    return vm_dispatch(0, obj, selAREF, NULL, 0, 1, &other);
}