summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-05 08:33:16 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-05 08:33:16 +0000
commit4a7d313e4a263f5c2f2f42dd573fa612f0d0c0a7 (patch)
tree73ab1abcb8d1ee1ae09dd2e0a18c6c619c611905
parentea201e7eb0f52c1803a3c811f1f912fc254b58cc (diff)
* eval.c (proc_eq): compare Procs using blocktag equality.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--ToDo1
-rw-r--r--eval.c117
3 files changed, 84 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index 71cf2f2..f92c22f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Mar 5 17:25:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_eq): compare Procs using blocktag equality.
+
Mon Mar 5 17:19:56 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* win32/win32.c (gettimeofday): use GetLocalTime() instead of ftime()
@@ -7,6 +11,12 @@ Sun Mar 4 17:01:09 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* string.c (trnext): support backslash escape in String#tr.
+Sat Mar 3 16:15:16 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): push cbase if ruby_cbase != ruby_class, for
+ example in the case NODE_DEFN/NODE_DEFS are called within
+ module_eval.
+
Wed Feb 28 11:02:41 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_delete_bang): delete! should take at least 1
diff --git a/ToDo b/ToDo
index 476e559..6af861a 100644
--- a/ToDo
+++ b/ToDo
@@ -82,6 +82,7 @@ Extension Libraries
* ptk.rb pTk wrapper that is compatible to tk.rb
* Berkeley DB extension
* BitVector
+* thread-safe fcgi
Ruby Libraries
diff --git a/eval.c b/eval.c
index fd02b54..37c8efc 100644
--- a/eval.c
+++ b/eval.c
@@ -1457,52 +1457,56 @@ ev_const_get(cref, id)
}
cbase = cbase->nd_next;
}
+#if 1
+ return rb_const_get(ruby_class, id);
+#else
return rb_const_get(cref->nd_clss, id);
+#endif
}
-static VALUE
-ev_const_set(cref, id, val)
- NODE *cref;
- ID id;
- VALUE val;
-{
- NODE *cbase = cref;
-
- while (cbase && cbase->nd_clss != rb_cObject) {
- struct RClass *klass = RCLASS(cbase->nd_clss);
-
- if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) {
- st_insert(klass->iv_tbl, id, val);
- return val;
- }
- cbase = cbase->nd_next;
- }
- rb_const_assign(cbase->nd_clss, id, val);
- return val;
-}
-
-static VALUE
-rb_mod_nesting()
-{
- NODE *cbase = RNODE(ruby_frame->cbase);
- VALUE ary = rb_ary_new();
-
- while (cbase && cbase->nd_clss != rb_cObject) {
- rb_ary_push(ary, cbase->nd_clss);
- cbase = cbase->nd_next;
- }
- return ary;
-}
-
-static VALUE
-rb_mod_s_constants()
-{
- NODE *cbase = RNODE(ruby_frame->cbase);
- VALUE ary = rb_ary_new();
-
- while (cbase && cbase->nd_clss != rb_cObject) {
- rb_mod_const_at(cbase->nd_clss, ary);
- cbase = cbase->nd_next;
+ static VALUE
+ ev_const_set(cref, id, val)
+ NODE *cref;
+ ID id;
+ VALUE val;
+ {
+ NODE *cbase = cref;
+
+ while (cbase && cbase->nd_clss != rb_cObject) {
+ struct RClass *klass = RCLASS(cbase->nd_clss);
+
+ if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) {
+ st_insert(klass->iv_tbl, id, val);
+ return val;
+ }
+ cbase = cbase->nd_next;
+ }
+ rb_const_assign(cbase->nd_clss, id, val);
+ return val;
+ }
+
+ static VALUE
+ rb_mod_nesting()
+ {
+ NODE *cbase = RNODE(ruby_frame->cbase);
+ VALUE ary = rb_ary_new();
+
+ while (cbase && cbase->nd_clss != rb_cObject) {
+ rb_ary_push(ary, cbase->nd_clss);
+ cbase = cbase->nd_next;
+ }
+ return ary;
+ }
+
+ static VALUE
+ rb_mod_s_constants()
+ {
+ NODE *cbase = RNODE(ruby_frame->cbase);
+ VALUE ary = rb_ary_new();
+
+ while (cbase && cbase->nd_clss != rb_cObject) {
+ rb_mod_const_at(cbase->nd_clss, ary);
+ cbase = cbase->nd_next;
}
rb_mod_const_of(ruby_cbase, ary);
@@ -2942,6 +2946,11 @@ rb_eval(self, n)
rb_warn("redefining `%s' may cause serious problem",
rb_id2name(node->nd_mid));
}
+ if (node->nd_defn->nd_rval &&
+ ((NODE*)node->nd_defn->nd_rval)->nd_clss != ruby_class) {
+ node->nd_defn->nd_rval =
+ (VALUE)rb_node_newnode(NODE_CREF,ruby_class,0, node->nd_defn->nd_rval);
+ }
rb_frozen_class_p(ruby_class);
body = search_method(ruby_class, node->nd_mid, &origin);
if (body){
@@ -3004,6 +3013,11 @@ rb_eval(self, n)
rb_class2name(CLASS_OF(recv)));
}
+ if (node->nd_defn->nd_rval &&
+ ((NODE*)node->nd_defn->nd_rval)->nd_clss != ruby_class) {
+ node->nd_defn->nd_rval =
+ (VALUE)rb_node_newnode(NODE_CREF,ruby_class,0, node->nd_defn->nd_rval);
+ }
if (OBJ_FROZEN(recv)) rb_error_frozen("object");
klass = rb_singleton_class(recv);
if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) {
@@ -4982,8 +4996,8 @@ yield_under_i(self)
VALUE result;
int state;
- block = *ruby_block;
/* copy the block to avoid modifying global data. */
+ block = *ruby_block;
block.frame.cbase = ruby_frame->cbase;
ruby_block = &block;
@@ -6335,6 +6349,20 @@ proc_arity(proc)
}
static VALUE
+proc_eq(self, other)
+ VALUE self, other;
+{
+ struct BLOCK *data, *data2;
+
+ if (TYPE(other) != T_DATA) return Qfalse;
+ if (RDATA(other)->dmark != blk_mark) Qfalse;
+ Data_Get_Struct(self, struct BLOCK, data);
+ Data_Get_Struct(other, struct BLOCK, data2);
+ if (data->tag == data2->tag) return Qtrue;
+ return Qfalse;
+}
+
+static VALUE
block_pass(self, node)
VALUE self;
NODE *node;
@@ -6751,6 +6779,7 @@ Init_Proc()
rb_define_method(rb_cProc, "call", proc_call, -2);
rb_define_method(rb_cProc, "arity", proc_arity, 0);
rb_define_method(rb_cProc, "[]", proc_call, -2);
+ rb_define_method(rb_cProc, "==", proc_eq, 1);
rb_define_global_function("proc", rb_f_lambda, 0);
rb_define_global_function("lambda", rb_f_lambda, 0);
rb_define_global_function("binding", rb_f_binding, 0);