Skip to content

Commit f9ea85d

Browse files
committed
delete unused code
1 parent 140bf4d commit f9ea85d

File tree

1 file changed

+0
-134
lines changed

1 file changed

+0
-134
lines changed

namespace.c

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -72,119 +72,6 @@ rb_main_namespace(void)
7272
return main_namespace;
7373
}
7474

75-
/*
76-
static bool
77-
namespace_ignore_builtin_primitive_methods_p(const rb_namespace_t *ns, rb_method_definition_t *def)
78-
{
79-
if (!NAMESPACE_BUILTIN_P(ns)) {
80-
return false;
81-
}
82-
/ Primitive methods (just to call C methods) covers/hides the effective
83-
namespaces, so ignore the methods' namespaces to expose user code's
84-
namespace to the implementation.
85-
/
86-
if (def->type == VM_METHOD_TYPE_ISEQ) {
87-
ID mid = def->original_id;
88-
const char *path = RSTRING_PTR(pathobj_path(def->body.iseq.iseqptr->body->location.pathobj));
89-
if (strcmp(path, "<internal:kernel>") == 0) {
90-
if (mid == rb_intern("class") || mid == rb_intern("clone") ||
91-
mid == rb_intern("tag") || mid == rb_intern("then") ||
92-
mid == rb_intern("yield_self") || mid == rb_intern("loop") ||
93-
mid == rb_intern("Float") || mid == rb_intern("Integer")
94-
) {
95-
return true;
96-
}
97-
}
98-
else if (strcmp(path, "<internal:warning>") == 0) {
99-
if (mid == rb_intern("warn")) {
100-
return true;
101-
}
102-
}
103-
else if (strcmp(path, "<internal:marshal>") == 0) {
104-
if (mid == rb_intern("load"))
105-
return true;
106-
}
107-
}
108-
return false;
109-
}
110-
111-
static inline const rb_namespace_t *
112-
block_proc_namespace(const VALUE procval)
113-
{
114-
rb_proc_t *proc;
115-
116-
if (procval) {
117-
GetProcPtr(procval, proc);
118-
return proc->ns;
119-
}
120-
else {
121-
return NULL;
122-
}
123-
}
124-
125-
static const rb_namespace_t *
126-
current_namespace(bool permit_calling_builtin)
127-
{
128-
/
129-
* TODO: move this code to vm.c or somewhere else
130-
* when it's fully updated with VM_FRAME_FLAG_*
131-
/
132-
const rb_callable_method_entry_t *cme;
133-
const rb_namespace_t *ns;
134-
rb_execution_context_t *ec = GET_EC();
135-
rb_control_frame_t *cfp = ec->cfp;
136-
rb_thread_t *th = rb_ec_thread_ptr(ec);
137-
int calling = 1;
138-
139-
if (!rb_namespace_available())
140-
return 0;
141-
142-
if (th->namespaces && RARRAY_LEN(th->namespaces) > 0) {
143-
// temp code to detect the context is in require/load
144-
// TODO: this doesn't work well in optional namespaces
145-
// calling = 0;
146-
}
147-
while (calling) {
148-
const rb_namespace_t *proc_ns = NULL;
149-
VALUE bh;
150-
if (VM_FRAME_NS_SWITCH_P(cfp)) {
151-
bh = rb_vm_frame_block_handler(cfp);
152-
if (bh && vm_block_handler_type(bh) == block_handler_type_proc) {
153-
proc_ns = block_proc_namespace(VM_BH_TO_PROC(bh));
154-
if (permit_calling_builtin || NAMESPACE_USER_P(proc_ns))
155-
return proc_ns;
156-
}
157-
}
158-
cme = rb_vm_frame_method_entry(cfp);
159-
if (cme && cme->def) {
160-
ns = cme->def->ns;
161-
if (ns) {
162-
// this method is not a built-in class/module's method
163-
// or a built-in primitive (Ruby) method
164-
if (!namespace_ignore_builtin_primitive_methods_p(ns, cme->def)) {
165-
if (permit_calling_builtin || (proc_ns && NAMESPACE_USER_P(proc_ns)))
166-
return ns;
167-
}
168-
}
169-
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
170-
}
171-
else {
172-
calling = 0;
173-
}
174-
}
175-
// not in namespace-marked method calls
176-
ns = th->ns;
177-
if (ns) {
178-
return ns;
179-
}
180-
if (!main_namespace) {
181-
// Namespaces are not ready to be created
182-
return root_namespace;
183-
}
184-
return main_namespace;
185-
}
186-
*/
187-
18875
const rb_namespace_t *
18976
rb_current_namespace(void)
19077
{
@@ -204,27 +91,6 @@ rb_current_namespace(void)
20491
const rb_namespace_t *
20592
rb_loading_namespace(void)
20693
{
207-
/*
208-
VALUE namespace;
209-
long len;
210-
VALUE require_stack = GET_VM()->require_stack;
211-
212-
if (!rb_namespace_available())
213-
return 0;
214-
215-
if (!require_stack) {
216-
return current_namespace(false);
217-
}
218-
if ((len = RARRAY_LEN(require_stack)) == 0) {
219-
return current_namespace(false);
220-
}
221-
222-
if (!RB_TYPE_P(require_stack, T_ARRAY))
223-
rb_bug("require_stack is not an array: %s", rb_type_str(BUILTIN_TYPE(require_stack)));
224-
225-
namespace = RARRAY_AREF(require_stack, len-1);
226-
return rb_get_namespace_t(namespace);
227-
*/
22894
if (!main_namespace)
22995
return root_namespace;
23096

0 commit comments

Comments
 (0)