diff options
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 95 |
1 files changed, 0 insertions, 95 deletions
@@ -10588,101 +10588,6 @@ rb_local_defined(ID id, const rb_iseq_t *iseq) return 0; } -static int -caller_location(VALUE *path, VALUE *realpath) -{ - const rb_execution_context_t *ec = GET_EC(); - const rb_control_frame_t *const cfp = - rb_vm_get_ruby_level_next_cfp(ec, ec->cfp); - - if (cfp) { - int line = rb_vm_get_sourceline(cfp); - *path = rb_iseq_path(cfp->iseq); - *realpath = rb_iseq_realpath(cfp->iseq); - return line; - } - else { - *path = rb_fstring_lit("<compiled>"); - *realpath = *path; - return 1; - } -} - -typedef struct { - VALUE arg; - VALUE func; - int line; -} accessor_args; - -static const rb_iseq_t * -method_for_self(VALUE name, VALUE arg, const struct rb_builtin_function *func, - void (*build)(rb_iseq_t *, LINK_ANCHOR *, const void *)) -{ - VALUE path, realpath; - accessor_args acc; - - acc.arg = arg; - acc.func = (VALUE)func; - acc.line = caller_location(&path, &realpath); - struct rb_iseq_new_with_callback_callback_func *ifunc = - rb_iseq_new_with_callback_new_callback(build, &acc); - return rb_iseq_new_with_callback(ifunc, - rb_sym2str(name), path, realpath, - INT2FIX(acc.line), 0, ISEQ_TYPE_METHOD, 0); -} - -static void -for_self_aref(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a) -{ - const accessor_args *const args = (void *)a; - const int line = args->line; - struct rb_iseq_constant_body *const body = iseq->body; - - iseq_set_local_table(iseq, 0); - body->param.lead_num = 0; - body->param.size = 0; - - NODE dummy_line_node = generate_dummy_line_node(line, -1); - ADD_INSN1(ret, &dummy_line_node, putobject, args->arg); - ADD_INSN1(ret, &dummy_line_node, invokebuiltin, args->func); -} - -static void -for_self_aset(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a) -{ - const accessor_args *const args = (void *)a; - const int line = args->line; - struct rb_iseq_constant_body *const body = iseq->body; - static const ID vars[] = {1, idUScore}; - - iseq_set_local_table(iseq, vars); - body->param.lead_num = 1; - body->param.size = 1; - - NODE dummy_line_node = generate_dummy_line_node(line, -1); - ADD_GETLOCAL(ret, &dummy_line_node, numberof(vars)-1, 0); - ADD_INSN1(ret, &dummy_line_node, putobject, args->arg); - ADD_INSN1(ret, &dummy_line_node, invokebuiltin, args->func); -} - -/* - * func (index) -> (value) - */ -const rb_iseq_t * -rb_method_for_self_aref(VALUE name, VALUE arg, const struct rb_builtin_function *func) -{ - return method_for_self(name, arg, func, for_self_aref); -} - -/* - * func (index, value) -> (value) - */ -const rb_iseq_t * -rb_method_for_self_aset(VALUE name, VALUE arg, const struct rb_builtin_function *func) -{ - return method_for_self(name, arg, func, for_self_aset); -} - /* ISeq binary format */ #ifndef IBF_ISEQ_DEBUG |