From 9b04909a85b07004ce4aa133c567fd78aa43f2ee Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 30 Sep 2021 12:35:27 -0700 Subject: Introduce rb_vm_call_with_refinements to DRY up a few calls --- vm_eval.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'vm_eval.c') diff --git a/vm_eval.c b/vm_eval.c index 920057652c..fb018c7eeb 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -57,6 +57,20 @@ rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE return vm_call0_body(ec, &calling, argv); } +MJIT_FUNC_EXPORTED VALUE +rb_vm_call_with_refinements(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, int kw_splat) +{ + const rb_callable_method_entry_t *me = + rb_callable_method_entry_with_refinements(CLASS_OF(recv), id, NULL); + if (me) { + return rb_vm_call0(ec, recv, id, argc, argv, me, kw_splat); + } + else { + /* fallback to funcall (e.g. method_missing) */ + return rb_funcallv(recv, id, argc, argv); + } +} + static inline VALUE vm_call0_cc(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const struct rb_callcache *cc, int kw_splat) { -- cgit v1.2.1