diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-21 00:13:44 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-21 00:13:44 +0000 |
commit | f12c14d3ef2474631c78d28b45d15db1d2cc668c (patch) | |
tree | 4b6deab7ffae8f30c9029bae6b9a96d9d4fd7f78 /vm_method.c | |
parent | 3052f75db499d18a7954766e1178a8d7e06c1867 (diff) | |
download | ruby-f12c14d3ef2474631c78d28b45d15db1d2cc668c.tar.gz |
* proc.c (method_hash, proc_hash): Fix {Unbound}Method#hash
[Bug #6048]. Isolate hash computation for proc
* internal.h: Declaration for above
* vm_method.c (rb_method_definition_hash): Computation for
hash part of a method definition
* method.h: Declaration for above
* test/ruby/test_method.rb: Test for above
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vm_method.c b/vm_method.c index 9ffae4ccae..d9f4a0315a 100644 --- a/vm_method.c +++ b/vm_method.c @@ -904,6 +904,40 @@ rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_defini } } +static st_index_t +rb_hash_method_definition(st_index_t hash, const rb_method_definition_t *def) +{ + hash = rb_hash_uint(hash, def->type); + switch (def->type) { + case VM_METHOD_TYPE_ISEQ: + return rb_hash_uint(hash, (st_index_t)def->body.iseq); + case VM_METHOD_TYPE_CFUNC: + hash = rb_hash_uint(hash, (st_index_t)def->body.cfunc.func); + return rb_hash_uint(hash, def->body.cfunc.argc); + case VM_METHOD_TYPE_ATTRSET: + case VM_METHOD_TYPE_IVAR: + return rb_hash_uint(hash, def->body.attr.id); + case VM_METHOD_TYPE_BMETHOD: + return rb_hash_proc(hash, def->body.proc); + case VM_METHOD_TYPE_MISSING: + return rb_hash_uint(hash, def->original_id); + case VM_METHOD_TYPE_ZSUPER: + case VM_METHOD_TYPE_NOTIMPLEMENTED: + case VM_METHOD_TYPE_UNDEF: + return hash; + case VM_METHOD_TYPE_OPTIMIZED: + return rb_hash_uint(hash, def->body.optimize_type); + default: + rb_bug("rb_hash_method_definition: unsupported method type (%d)\n", def->type); + } + return hash; +} + +st_index_t +rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me) { + return rb_hash_method_definition(hash, me->def); +} + void rb_alias(VALUE klass, ID name, ID def) { |