summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-05-29 05:20:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-05-29 05:20:39 +0000
commit4ab1577db3bb1358af5fd387a59c541621f5df1e (patch)
tree568c351a894d8dfe24458b342b4e79d8df5444b2 /eval.c
parent99551555c8c957aca4ad01a776252acf3aa37775 (diff)
* parse.y: yyparse #defines moved from intern.h
* ruby.c (proc_options): access prefixed "ruby_yydebug". * applied modifies to pacify some of gcc -Wall warnings. * parse.y (arg): no more ugly hack for "**", so that "-2**2" to be parsed as "(-2)**2", whereas "- 2**2" or "-(2)**2" to be parsed as "-(2**2)". * parse.y (yylex): '-2' to be literal fixnum. [new] * time.c (time_succ): new method for Range support. * time.c (time_arg): nil test against v[6] (usec). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 3f793f18c5..a2c048022d 100644
--- a/eval.c
+++ b/eval.c
@@ -3075,6 +3075,7 @@ rb_eval(self, n)
ruby_errinfo = Qnil;
ruby_sourceline = nd_line(node);
ruby_in_eval++;
+ rb_dvar_push(0, 0);
list->nd_head = compile(list->nd_head->nd_lit,
ruby_sourcefile,
ruby_sourceline);
@@ -6627,7 +6628,7 @@ proc_to_s(self, other)
Data_Get_Struct(self, struct BLOCK, data);
str = rb_str_new(0, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:nul */
- sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", cname, data->tag);
+ sprintf(RSTRING(str)->ptr, "#<%s:0x%p>", cname, data->tag);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(self)) OBJ_TAINT(str);
@@ -6642,6 +6643,28 @@ proc_to_proc(proc)
}
static VALUE
+proc_binding(proc)
+ VALUE proc;
+{
+ struct BLOCK *orig, *data;
+ VALUE bind;
+
+ Data_Get_Struct(proc, struct BLOCK, orig);
+ bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
+ MEMCPY(data, orig, struct BLOCK, 1);
+ frame_dup(&data->frame);
+
+ if (data->iter) {
+ blk_copy_prev(data);
+ }
+ else {
+ data->prev = 0;
+ }
+
+ return bind;
+}
+
+static VALUE
block_pass(self, node)
VALUE self;
NODE *node;
@@ -7149,6 +7172,7 @@ Init_Proc()
rb_define_method(rb_cProc, "==", proc_eq, 1);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
+ rb_define_method(rb_cProc, "binding", proc_binding, 0);
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);