diff options
| author | Satoshi Tagomori <s-tagomori@sakura.ad.jp> | 2025-08-12 11:36:04 +0900 |
|---|---|---|
| committer | Satoshi Tagomori <tagomoris@gmail.com> | 2025-09-29 01:15:38 +0900 |
| commit | f9ea85dd41f66f50447e55123e826726574cb418 (patch) | |
| tree | dba48564ad406e2609bf7eb158fca3c05ab35de4 | |
| parent | 140bf4d8a035f669b24541ff71144d086588f7b5 (diff) | |
delete unused code
| -rw-r--r-- | namespace.c | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/namespace.c b/namespace.c index c655a5e947..3ace63ffc4 100644 --- a/namespace.c +++ b/namespace.c @@ -72,119 +72,6 @@ rb_main_namespace(void) return main_namespace; } -/* -static bool -namespace_ignore_builtin_primitive_methods_p(const rb_namespace_t *ns, rb_method_definition_t *def) -{ - if (!NAMESPACE_BUILTIN_P(ns)) { - return false; - } - / Primitive methods (just to call C methods) covers/hides the effective - namespaces, so ignore the methods' namespaces to expose user code's - namespace to the implementation. - / - if (def->type == VM_METHOD_TYPE_ISEQ) { - ID mid = def->original_id; - const char *path = RSTRING_PTR(pathobj_path(def->body.iseq.iseqptr->body->location.pathobj)); - if (strcmp(path, "<internal:kernel>") == 0) { - if (mid == rb_intern("class") || mid == rb_intern("clone") || - mid == rb_intern("tag") || mid == rb_intern("then") || - mid == rb_intern("yield_self") || mid == rb_intern("loop") || - mid == rb_intern("Float") || mid == rb_intern("Integer") - ) { - return true; - } - } - else if (strcmp(path, "<internal:warning>") == 0) { - if (mid == rb_intern("warn")) { - return true; - } - } - else if (strcmp(path, "<internal:marshal>") == 0) { - if (mid == rb_intern("load")) - return true; - } - } - return false; -} - -static inline const rb_namespace_t * -block_proc_namespace(const VALUE procval) -{ - rb_proc_t *proc; - - if (procval) { - GetProcPtr(procval, proc); - return proc->ns; - } - else { - return NULL; - } -} - -static const rb_namespace_t * -current_namespace(bool permit_calling_builtin) -{ - / - * TODO: move this code to vm.c or somewhere else - * when it's fully updated with VM_FRAME_FLAG_* - / - const rb_callable_method_entry_t *cme; - const rb_namespace_t *ns; - rb_execution_context_t *ec = GET_EC(); - rb_control_frame_t *cfp = ec->cfp; - rb_thread_t *th = rb_ec_thread_ptr(ec); - int calling = 1; - - if (!rb_namespace_available()) - return 0; - - if (th->namespaces && RARRAY_LEN(th->namespaces) > 0) { - // temp code to detect the context is in require/load - // TODO: this doesn't work well in optional namespaces - // calling = 0; - } - while (calling) { - const rb_namespace_t *proc_ns = NULL; - VALUE bh; - if (VM_FRAME_NS_SWITCH_P(cfp)) { - bh = rb_vm_frame_block_handler(cfp); - if (bh && vm_block_handler_type(bh) == block_handler_type_proc) { - proc_ns = block_proc_namespace(VM_BH_TO_PROC(bh)); - if (permit_calling_builtin || NAMESPACE_USER_P(proc_ns)) - return proc_ns; - } - } - cme = rb_vm_frame_method_entry(cfp); - if (cme && cme->def) { - ns = cme->def->ns; - if (ns) { - // this method is not a built-in class/module's method - // or a built-in primitive (Ruby) method - if (!namespace_ignore_builtin_primitive_methods_p(ns, cme->def)) { - if (permit_calling_builtin || (proc_ns && NAMESPACE_USER_P(proc_ns))) - return ns; - } - } - cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); - } - else { - calling = 0; - } - } - // not in namespace-marked method calls - ns = th->ns; - if (ns) { - return ns; - } - if (!main_namespace) { - // Namespaces are not ready to be created - return root_namespace; - } - return main_namespace; -} -*/ - const rb_namespace_t * rb_current_namespace(void) { @@ -204,27 +91,6 @@ rb_current_namespace(void) const rb_namespace_t * rb_loading_namespace(void) { - /* - VALUE namespace; - long len; - VALUE require_stack = GET_VM()->require_stack; - - if (!rb_namespace_available()) - return 0; - - if (!require_stack) { - return current_namespace(false); - } - if ((len = RARRAY_LEN(require_stack)) == 0) { - return current_namespace(false); - } - - if (!RB_TYPE_P(require_stack, T_ARRAY)) - rb_bug("require_stack is not an array: %s", rb_type_str(BUILTIN_TYPE(require_stack))); - - namespace = RARRAY_AREF(require_stack, len-1); - return rb_get_namespace_t(namespace); - */ if (!main_namespace) return root_namespace; |
