summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--class.c2
-rw-r--r--method.h18
-rw-r--r--vm_insnhelper.c2
-rw-r--r--vm_method.c21
5 files changed, 38 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 5df778b..dea5726 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Fri Jun 5 00:55:21 2015 Koichi Sasada <ko1@atdot.net>
+
+ * method.h: constify rb_method_refined_t::orig_me.
+
+ Also constify the following functions.
+
+ * rb_resolve_refined_method()
+ * rb_method_entry_with_refinements()
+ * rb_method_entry_without_refinements()
+ * rb_method_entry_copy()'s parameter.
+
+ * class.c: catch up this fix.
+
+ * vm_insnhelper.c: ditto.
+
+ * vm_method.c: ditto.
+
Thu Jun 4 12:47:54 SGT 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* array.c: Revert r50763. because "reentered" is not typo.
diff --git a/class.c b/class.c
index 94ddd7c..1f35be4 100644
--- a/class.c
+++ b/class.c
@@ -914,7 +914,7 @@ move_refined_method(st_data_t key, st_data_t value, st_data_t data)
if (me->def->type == VM_METHOD_TYPE_REFINED) {
if (me->def->body.refined.orig_me) {
- rb_method_entry_t *orig_me = me->def->body.refined.orig_me, *new_me;
+ const rb_method_entry_t *orig_me = me->def->body.refined.orig_me, *new_me;
me->def->body.refined.orig_me = NULL;
new_me = rb_method_entry_clone(me);
st_add_direct(tbl, key, (st_data_t) new_me);
diff --git a/method.h b/method.h
index 4d420e9..0b07342 100644
--- a/method.h
+++ b/method.h
@@ -78,7 +78,7 @@ typedef struct rb_method_alias_struct {
} rb_method_alias_t;
typedef struct rb_method_refined_struct {
- struct rb_method_entry_struct *orig_me;
+ const struct rb_method_entry_struct *orig_me;
} rb_method_refined_t;
typedef struct rb_method_definition_struct {
@@ -120,13 +120,13 @@ rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, voi
rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
-rb_method_entry_t *rb_resolve_refined_method(VALUE refinements,
- const rb_method_entry_t *me,
- VALUE *defined_class_ptr);
-rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id,
- VALUE *defined_class_ptr);
-rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id,
- VALUE *defined_class_ptr);
+const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements,
+ const rb_method_entry_t *me,
+ VALUE *defined_class_ptr);
+const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id,
+ VALUE *defined_class_ptr);
+const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id,
+ VALUE *defined_class_ptr);
rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE *define_class_ptr);
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
@@ -144,7 +144,7 @@ void rb_sweep_method_entry(void *vm);
rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_definition_t *def);
rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
-void rb_method_entry_copy(rb_method_entry_t *dst, rb_method_entry_t *src);
+void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
void rb_scope_visibility_set(rb_method_visibility_t);
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index a64529f..c90638e 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1136,7 +1136,7 @@ check_match(VALUE pattern, VALUE target, enum vm_check_match_type type)
/* fall through */
case VM_CHECKMATCH_TYPE_CASE: {
VALUE defined_class;
- rb_method_entry_t *me = rb_method_entry_with_refinements(CLASS_OF(pattern), idEqq, &defined_class);
+ const rb_method_entry_t *me = rb_method_entry_with_refinements(CLASS_OF(pattern), idEqq, &defined_class);
if (me) {
return vm_call0(GET_THREAD(), pattern, idEqq, 1, &target, me, defined_class);
}
diff --git a/vm_method.c b/vm_method.c
index 44abf31..8d08272 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -307,7 +307,7 @@ rb_method_definition_create(rb_method_visibility_t visi, rb_method_type_t type,
}
static void
-rb_method_definition_reset(rb_method_entry_t *me, rb_method_definition_t *def)
+rb_method_definition_reset(const rb_method_entry_t *me, rb_method_definition_t *def)
{
switch(def->type) {
case VM_METHOD_TYPE_ISEQ:
@@ -372,7 +372,7 @@ rb_method_entry_clone(const rb_method_entry_t *src_me)
}
void
-rb_method_entry_copy(rb_method_entry_t *dst, rb_method_entry_t *src)
+rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src)
{
rb_method_definition_reset(dst, rb_method_definition_clone(src->def));
dst->called_id = src->called_id;
@@ -709,7 +709,7 @@ rb_method_entry(VALUE klass, ID id, VALUE *defined_class_ptr)
return rb_method_entry_get_without_cache(klass, id, defined_class_ptr);
}
-static rb_method_entry_t *
+static const rb_method_entry_t *
get_original_method_entry(VALUE refinements,
const rb_method_entry_t *me,
VALUE *defined_class_ptr)
@@ -731,7 +731,7 @@ get_original_method_entry(VALUE refinements,
}
}
-rb_method_entry_t *
+const rb_method_entry_t *
rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me,
VALUE *defined_class_ptr)
{
@@ -759,12 +759,12 @@ rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me,
}
}
-rb_method_entry_t *
+const rb_method_entry_t *
rb_method_entry_with_refinements(VALUE klass, ID id,
VALUE *defined_class_ptr)
{
VALUE defined_class;
- rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class);
+ const rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class);
if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
const rb_cref_t *cref = rb_vm_cref();
@@ -778,12 +778,12 @@ rb_method_entry_with_refinements(VALUE klass, ID id,
return me;
}
-rb_method_entry_t *
+const rb_method_entry_t *
rb_method_entry_without_refinements(VALUE klass, ID id,
VALUE *defined_class_ptr)
{
VALUE defined_class;
- rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class);
+ const rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class);
if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
me = rb_resolve_refined_method(Qnil, me, &defined_class);
@@ -910,8 +910,7 @@ rb_export_method(VALUE klass, ID name, rb_method_visibility_t visi)
int
rb_method_boundp(VALUE klass, ID id, int ex)
{
- rb_method_entry_t *me =
- rb_method_entry_without_refinements(klass, id, 0);
+ const rb_method_entry_t *me = rb_method_entry_without_refinements(klass, id, 0);
if (me != 0) {
rb_method_definition_t *def = me->def;
@@ -1371,7 +1370,7 @@ rb_alias(VALUE klass, ID alias_name, ID original_name)
{
const VALUE target_klass = klass;
VALUE defined_class;
- rb_method_entry_t *orig_me;
+ const rb_method_entry_t *orig_me;
rb_method_visibility_t visi = METHOD_VISI_UNDEF;
if (NIL_P(klass)) {