diff options
author | 卜部昌平 <[email protected]> | 2019-09-26 10:22:01 +0900 |
---|---|---|
committer | 卜部昌平 <[email protected]> | 2019-09-30 10:26:38 +0900 |
commit | dd883de5ba311c38818d0f638a94b4fbc63f5ee5 (patch) | |
tree | d430c06f19a7dcafdc35558f7720d48308dfd435 /vm_insnhelper.c | |
parent | 6c6a25feca8752205d81c5247f85d8ae8fb880d8 (diff) |
refactor constify most of rb_method_entry_t
Now that we have eliminated most destructive operations over the
rb_method_entry_t / rb_callable_method_entry_t, let's make them
mostly immutabe and mark them const.
One exception is rb_export_method(), which destructively modifies
visibilities of method entries. I have left that operation as is
because I suspect that destructiveness is the nature of that
function.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2486
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index adad1df6dd..197e100607 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -578,8 +578,8 @@ vm_getspecial(const rb_execution_context_t *ec, const VALUE *lep, rb_num_t key, return val; } -PUREFUNC(static rb_callable_method_entry_t *check_method_entry(VALUE obj, int can_be_svar)); -static rb_callable_method_entry_t * +PUREFUNC(static const rb_callable_method_entry_t *check_method_entry(VALUE obj, int can_be_svar)); +static const rb_callable_method_entry_t * check_method_entry(VALUE obj, int can_be_svar) { if (obj == Qfalse) return NULL; @@ -590,7 +590,7 @@ check_method_entry(VALUE obj, int can_be_svar) switch (imemo_type(obj)) { case imemo_ment: - return (rb_callable_method_entry_t *)obj; + return (const rb_callable_method_entry_t *)obj; case imemo_cref: return NULL; case imemo_svar: @@ -609,7 +609,7 @@ MJIT_STATIC const rb_callable_method_entry_t * rb_vm_frame_method_entry(const rb_control_frame_t *cfp) { const VALUE *ep = cfp->ep; - rb_callable_method_entry_t *me; + const rb_callable_method_entry_t *me; while (!VM_ENV_LOCAL_P(ep)) { if ((me = check_method_entry(ep[VM_ENV_DATA_INDEX_ME_CREF], FALSE)) != NULL) return me; @@ -620,7 +620,7 @@ rb_vm_frame_method_entry(const rb_control_frame_t *cfp) } static rb_cref_t * -method_entry_cref(rb_callable_method_entry_t *me) +method_entry_cref(const rb_callable_method_entry_t *me) { switch (me->def->type) { case VM_METHOD_TYPE_ISEQ: @@ -644,7 +644,7 @@ check_cref(VALUE obj, int can_be_svar) switch (imemo_type(obj)) { case imemo_ment: - return method_entry_cref((rb_callable_method_entry_t *)obj); + return method_entry_cref((const rb_callable_method_entry_t *)obj); case imemo_cref: return (rb_cref_t *)obj; case imemo_svar: |