1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
ko1 2015-06-05 11:42:34 +00:00
parent 7ac8fe7407
commit b6b76e3a85
7 changed files with 60 additions and 32 deletions

View file

@ -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

View file

@ -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;

View file

@ -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 */

View file

@ -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 {
@ -31,13 +53,6 @@ typedef struct rb_method_entry_struct {
const VALUE klass; /* should be marked */
} 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,

12
vm.c
View file

@ -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 *

View file

@ -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;

View file

@ -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;
}