summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-06 15:31:26 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-06 15:31:26 +0000
commitaa92750f27e519c225d9bb50e59ed063857e0c04 (patch)
treeb52c2b9114e9af08bd0805ef2ff52988fe2976bf /eval.c
parent2cefbe9fb2297147c034086ff3b1b2dd9a9f5545 (diff)
* process.c (proc_setgroups): [ruby-dev:25081]
* re.c (rb_reg_eqq): document fix. [ruby-talk:122541] * io.c (io_fread): take VALUE argument. * ext/socket/socket.c (sock_connect): use rb_str_new4(). [ruby-dev:25052] * eval.c (rb_yield_0): [ruby-dev:25051] * io.c (io_write): remove rb_str_locktmp(). [ruby-dev:25050] * io.c (io_fwrite): takes VALUE string as an argument. [ruby-dev:25050] * ext/socket/socket.c (sock_connect): remove rb_str_locktmp(). [ruby-dev:25050] * ext/socket/socket.c (udp_connect): [ruby-dev:25045] * ext/socket/socket.c (udp_bind): ditto. * ext/socket/socket.c (udp_send): ditto. * ext/socket/socket.c (bsock_send): ditto. * ext/socket/socket.c (s_recvfrom): ditto. * hash.c (rb_hash_hash): should provide "hash" method where "eql?" is redefined. [ruby-talk:122482] * ext/socket/socket.c (bsock_setsockopt): [ruby-dev:25039] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index 896e549b626..1643c45062e 100644
--- a/eval.c
+++ b/eval.c
@@ -694,6 +694,7 @@ struct BLOCK {
#define BLOCK_D_SCOPE 1
#define BLOCK_LAMBDA 2
+#define BLOCK_FROM_METHOD 4
static struct BLOCK *ruby_block;
static unsigned long block_unique = 0;
@@ -1006,8 +1007,7 @@ static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
#define YIELD_LAMBDA_CALL 1
#define YIELD_PROC_CALL 2
-#define YIELD_PROC_BLOCK 4
-#define YIELD_PUBLIC_DEF 8
+#define YIELD_PUBLIC_DEF 4
#define YIELD_FUNC_AVALUE 1
#define YIELD_FUNC_SVALUE 2
@@ -4576,6 +4576,12 @@ static VALUE bmcall _((VALUE, VALUE));
static VALUE method_arity _((VALUE));
static VALUE
+kk()
+{
+ return rb_proc_new(rb_yield, Qnil);
+}
+
+static VALUE
rb_yield_0(val, self, klass, flags, avalue)
VALUE val, self, klass; /* OK */
int flags, avalue;
@@ -4721,7 +4727,7 @@ rb_yield_0(val, self, klass, flags, avalue)
if (val == Qundef && node->nd_state != YIELD_FUNC_SVALUE)
val = Qnil;
}
- if ((flags&YIELD_PROC_BLOCK) && RTEST(block->block_obj)) {
+ if ((block->flags&BLOCK_FROM_METHOD) && RTEST(block->block_obj)) {
struct BLOCK *data, _block;
Data_Get_Struct(block->block_obj, struct BLOCK, data);
_block = *data;
@@ -8200,10 +8206,8 @@ proc_invoke(proc, args, self, klass)
if (klass != ruby_frame->last_class)
klass = rb_obj_class(proc);
bvar = rb_block_proc();
- pcall |= YIELD_PROC_BLOCK;
}
-
PUSH_VARS();
ruby_wrapper = data->wrapper;
ruby_dyna_vars = data->dyna_vars;
@@ -9197,6 +9201,7 @@ method_proc(method)
bdata->body->nd_file = mdata->body->nd_file;
nd_set_line(bdata->body, nd_line(mdata->body));
bdata->body->nd_state = YIELD_FUNC_SVALUE;
+ bdata->flags |= BLOCK_FROM_METHOD;
return proc;
}
@@ -9367,6 +9372,8 @@ Init_Proc()
rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
rb_define_method(rb_cProc, "binding", proc_binding, 0);
+ rb_define_global_function("kk", kk, 0);
+
rb_define_global_function("proc", rb_block_proc, 0);
rb_define_global_function("lambda", proc_lambda, 0);