aboutsummaryrefslogtreecommitdiffstats
path: root/vm_method.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-24 08:31:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-24 08:31:43 +0000
commit220f9d5053a3b981a01af6e7606298b0065c3e2c (patch)
treeeb313f164d496cfd36daa7e8cb8134bfa7e2b321 /vm_method.c
parentd92b0dc58aa161801a5e5d4a484e67a9dd61bb65 (diff)
downloadruby-220f9d5053a3b981a01af6e7606298b0065c3e2c.tar.gz
vm_method.c: use the current visibility
* vm_method.c (rb_attr): simply use the current visibility, instead of tests for each visibilities. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/vm_method.c b/vm_method.c
index 0cbebea909..735386e201 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -912,17 +912,17 @@ rb_method_boundp(VALUE klass, ID id, int ex)
return 0;
}
-static int
-rb_scope_visibility_test(rb_method_visibility_t visi)
+static rb_method_visibility_t
+rb_scope_visibility_get(void)
{
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (!vm_env_cref_by_cref(cfp->ep)) {
- return METHOD_VISI_PUBLIC == visi;
+ return METHOD_VISI_PUBLIC;
}
else {
- return CREF_SCOPE_VISI(rb_vm_cref())->method_visi == visi;
+ return CREF_SCOPE_VISI(rb_vm_cref())->method_visi;
}
}
@@ -958,17 +958,19 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex)
visi = METHOD_VISI_PUBLIC;
}
else {
- if (rb_scope_visibility_test(METHOD_VISI_PRIVATE)) {
- visi = METHOD_VISI_PRIVATE;
+ switch (rb_scope_visibility_get()) {
+ case METHOD_VISI_PRIVATE:
if (rb_scope_module_func_check()) {
rb_warning("attribute accessor as module_function");
}
- }
- else if (rb_scope_visibility_test(METHOD_VISI_PROTECTED)) {
+ visi = METHOD_VISI_PRIVATE;
+ break;
+ case METHOD_VISI_PROTECTED:
visi = METHOD_VISI_PROTECTED;
- }
- else {
+ break;
+ default:
visi = METHOD_VISI_PUBLIC;
+ break;
}
}