summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-05 11:42:34 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-05 11:42:34 +0000
commitb6b76e3a85130dc24dbacd60a82033c780581e9b (patch)
treeceb2a9ef6c63493d267159b4f4d8ab95f8b0de4a
parent7ac8fe74074a085eb79dfbf501f186fe0af7d1b2 (diff)
* internal.h: move definition of rb_cref_t to method.h.
* eval_intern.h: move definition of rb_scope_visibility_t to method.h. * method.h: change rb_cref_t::scope_visi from VALUE to rb_scope_visibility_t. [Bug #11219] * vm.c (vm_cref_new): accept rb_method_visibility_t directly. * vm_insnhelper.c (rb_vm_rewrite_cref): don't use 0, but METHOD_VISI_UNDEF. * vm_method.c (rb_scope_visibility_set): don't need to use cast. * vm_method.c (rb_scope_module_func_set): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog20
-rw-r--r--eval_intern.h13
-rw-r--r--internal.h10
-rw-r--r--method.h29
-rw-r--r--vm.c12
-rw-r--r--vm_insnhelper.c4
-rw-r--r--vm_method.c4
7 files changed, 60 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a43f6fe95..1af08d9225 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+Fri Jun 5 20:37:10 2015 Koichi Sasada <ko1@atdot.net>
+
+ * internal.h: move definition of rb_cref_t to method.h.
+
+ * eval_intern.h: move definition of rb_scope_visibility_t
+ to method.h.
+
+ * method.h: change rb_cref_t::scope_visi from VALUE to
+ rb_scope_visibility_t.
+ [Bug #11219]
+
+ * vm.c (vm_cref_new): accept rb_method_visibility_t directly.
+
+ * vm_insnhelper.c (rb_vm_rewrite_cref): don't use 0,
+ but METHOD_VISI_UNDEF.
+
+ * vm_method.c (rb_scope_visibility_set): don't need to use cast.
+
+ * vm_method.c (rb_scope_module_func_set): ditto.
+
Fri Jun 5 17:27:30 2015 Eric Wong <e@80x24.org>
* ext/socket/ancdata.c (bsock_sendmsg_internal): avoid msg_control
diff --git a/eval_intern.h b/eval_intern.h
index df2d857340..de22d56d3f 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -228,22 +228,17 @@ CREF_NEXT_SET(rb_cref_t *cref, const rb_cref_t *next_cref)
RB_OBJ_WRITE(cref, &cref->next, next_cref);
}
-typedef struct rb_scope_visi_struct {
- rb_method_visibility_t method_visi : 3;
- unsigned int module_func : 1;
-} rb_scope_visibility_t;
-
static inline const rb_scope_visibility_t *
CREF_SCOPE_VISI(const rb_cref_t *cref)
{
- return (const rb_scope_visibility_t *)&cref->scope_visi;
+ return &cref->scope_visi;
}
static inline void
-CREF_SCOPE_VISI_COPY(const rb_cref_t *dst_cref, rb_cref_t *src_cref)
+CREF_SCOPE_VISI_COPY(rb_cref_t *dst_cref, const rb_cref_t *src_cref)
{
- rb_scope_visibility_t *src = (rb_scope_visibility_t *)&src_cref->scope_visi;
- rb_scope_visibility_t *dst = (rb_scope_visibility_t *)&dst_cref->scope_visi;
+ const rb_scope_visibility_t *src = &src_cref->scope_visi;
+ rb_scope_visibility_t *dst = &dst_cref->scope_visi;
dst->method_visi = src->method_visi;
dst->module_func = src->module_func;
diff --git a/internal.h b/internal.h
index 93208768d0..f30ddee905 100644
--- a/internal.h
+++ b/internal.h
@@ -545,15 +545,7 @@ imemo_type(VALUE imemo)
return (RBASIC(imemo)->flags >> FL_USHIFT) & imemo_mask;
}
-/* CREF */
-
-typedef struct rb_cref_struct {
- VALUE flags;
- const VALUE refinements;
- const VALUE klass;
- VALUE scope_visi;
- struct rb_cref_struct * const next;
-} rb_cref_t;
+/* CREF in method.h */
/* SVAR */
diff --git a/method.h b/method.h
index 4d1cf3e6fe..2c9bddb486 100644
--- a/method.h
+++ b/method.h
@@ -21,6 +21,28 @@
# endif
#endif
+/* cref */
+
+typedef enum {
+ METHOD_VISI_UNDEF = 0x00,
+ METHOD_VISI_PUBLIC = 0x01,
+ METHOD_VISI_PRIVATE = 0x02,
+ METHOD_VISI_PROTECTED = 0x03
+} rb_method_visibility_t;
+
+typedef struct rb_scope_visi_struct {
+ rb_method_visibility_t method_visi : 3;
+ unsigned int module_func : 1;
+} rb_scope_visibility_t;
+
+typedef struct rb_cref_struct {
+ VALUE flags;
+ const VALUE refinements;
+ const VALUE klass;
+ struct rb_cref_struct * const next;
+ rb_scope_visibility_t scope_visi;
+} rb_cref_t;
+
/* method data type */
typedef struct rb_method_entry_struct {
@@ -32,13 +54,6 @@ typedef struct rb_method_entry_struct {
} rb_method_entry_t;
typedef enum {
- METHOD_VISI_UNDEF = 0x00,
- METHOD_VISI_PUBLIC = 0x01,
- METHOD_VISI_PRIVATE = 0x02,
- METHOD_VISI_PROTECTED = 0x03
-} rb_method_visibility_t;
-
-typedef enum {
VM_METHOD_TYPE_ISEQ,
VM_METHOD_TYPE_CFUNC,
VM_METHOD_TYPE_ATTRSET,
diff --git a/vm.c b/vm.c
index a772206aeb..b302674085 100644
--- a/vm.c
+++ b/vm.c
@@ -80,10 +80,16 @@ rb_vm_control_frame_block_ptr(const rb_control_frame_t *cfp)
}
static rb_cref_t *
-vm_cref_new(VALUE klass, long visi, const rb_cref_t *prev_cref)
+vm_cref_new(VALUE klass, rb_method_visibility_t visi, const rb_cref_t *prev_cref)
{
- rb_cref_t *cref = (rb_cref_t *)rb_imemo_new(imemo_cref, klass, visi, (VALUE)prev_cref, Qnil);
- return cref;
+ union {
+ rb_scope_visibility_t visi;
+ VALUE value;
+ } scope_visi;
+ scope_visi.visi.method_visi = visi;
+ scope_visi.visi.module_func = 0;
+
+ return (rb_cref_t *)rb_imemo_new(imemo_cref, klass, (VALUE)prev_cref, scope_visi.value, Qnil);
}
static rb_cref_t *
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 6670e89ea5..315eefec33 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -471,13 +471,13 @@ rb_vm_rewrite_cref(rb_cref_t *cref, VALUE old_klass, VALUE new_klass, rb_cref_t
while (cref) {
if (CREF_CLASS(cref) == old_klass) {
- new_cref = vm_cref_new(new_klass, 0, NULL);
+ new_cref = vm_cref_new(new_klass, METHOD_VISI_UNDEF, NULL);
COPY_CREF_OMOD(new_cref, cref);
CREF_NEXT_SET(new_cref, CREF_NEXT(cref));
*new_cref_ptr = new_cref;
return;
}
- new_cref = vm_cref_new(CREF_CLASS(cref), 0, NULL);
+ new_cref = vm_cref_new(CREF_CLASS(cref), METHOD_VISI_UNDEF, NULL);
COPY_CREF_OMOD(new_cref, cref);
cref = CREF_NEXT(cref);
*new_cref_ptr = new_cref;
diff --git a/vm_method.c b/vm_method.c
index e59a161cc2..48131307da 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -959,7 +959,7 @@ rb_scope_module_func_check(void)
void
rb_scope_visibility_set(rb_method_visibility_t visi)
{
- rb_scope_visibility_t *scope_visi = (rb_scope_visibility_t *)&rb_vm_cref()->scope_visi;
+ rb_scope_visibility_t *scope_visi = &rb_vm_cref()->scope_visi;
scope_visi->method_visi = visi;
scope_visi->module_func = FALSE;
}
@@ -967,7 +967,7 @@ rb_scope_visibility_set(rb_method_visibility_t visi)
static void
rb_scope_module_func_set(void)
{
- rb_scope_visibility_t *scope_visi = (rb_scope_visibility_t *)&rb_vm_cref()->scope_visi;
+ rb_scope_visibility_t *scope_visi = &rb_vm_cref()->scope_visi;
scope_visi->method_visi = METHOD_VISI_PRIVATE;
scope_visi->module_func = TRUE;
}