| 753 |
753 |
rb_raise(rb_eArgError, "argument needs to be symbol or string");
|
| 754 |
754 |
}
|
|
755 |
ruby_set_current_source();
|
| 755 |
756 |
len = strlen(name)+2;
|
| 756 |
757 |
buf = ALLOCA_N(char,len);
|
| ... | ... | |
| 1204 |
1205 |
#define SET_CURRENT_SOURCE() ((void)0)
|
| 1205 |
1206 |
#endif
|
|
1207 |
#define SET_CURRENT_NODE(node) (ruby_current_node = (node), SET_CURRENT_SOURCE())
|
| 1206 |
1208 |
|
| 1207 |
1209 |
void
|
| ... | ... | |
| 1753 |
1755 |
ruby_sourcefile = rb_source_filename("(eval)");
|
| 1754 |
1756 |
v = eval(ruby_top_self, rb_str_new2(str), Qnil, 0, 0);
|
| 1755 |
|
ruby_current_node = oldsrc;
|
|
1757 |
SET_CURRENT_NODE(oldsrc);
|
| 1756 |
1758 |
|
| 1757 |
1759 |
return v;
|
| ... | ... | |
| 2297 |
2299 |
NODE *rval;
|
| 2298 |
2300 |
{
|
| 2299 |
|
NODE *copy = NEW_NODE(NODE_SCOPE,0,rval,node->nd_next);
|
|
2301 |
NODE *copy = (ruby_set_current_source(), NEW_NODE(NODE_SCOPE,0,rval,node->nd_next));
|
| 2300 |
2302 |
|
| 2301 |
2303 |
if (node->nd_tbl) {
|
| ... | ... | |
| 2818 |
2820 |
|
| 2819 |
2821 |
tracing = 0;
|
| 2820 |
|
ruby_current_node = node_save;
|
| 2821 |
|
SET_CURRENT_SOURCE();
|
|
2822 |
SET_CURRENT_NODE(node_save);
|
| 2822 |
2823 |
if (state) JUMP_TAG(state);
|
| 2823 |
2824 |
}
|
| ... | ... | |
| 3016 |
3017 |
if (!node) RETURN(Qnil);
|
| 3017 |
3018 |
|
| 3018 |
|
ruby_current_node = node;
|
|
3019 |
SET_CURRENT_NODE(node);
|
|
3020 |
|
| 3019 |
3021 |
switch (nd_type(node)) {
|
| 3020 |
3022 |
case NODE_BLOCK:
|
| ... | ... | |
| 3290 |
3292 |
recv = rb_eval(self, node->nd_iter);
|
| 3291 |
3293 |
END_CALLARGS;
|
| 3292 |
|
ruby_current_node = node;
|
| 3293 |
|
SET_CURRENT_SOURCE();
|
|
3294 |
SET_CURRENT_NODE(node);
|
| 3294 |
3295 |
result = rb_call(CLASS_OF(recv),recv,each,0,0,0,self);
|
| 3295 |
3296 |
}
|
| ... | ... | |
| 3350 |
3351 |
if (node->nd_head) {
|
| 3351 |
3352 |
result = rb_eval(self, node->nd_head);
|
| 3352 |
|
ruby_current_node = node;
|
|
3353 |
SET_CURRENT_NODE(node);
|
| 3353 |
3354 |
}
|
| 3354 |
3355 |
else {
|
| 3355 |
3356 |
result = Qundef; /* no arg */
|
| 3356 |
3357 |
}
|
| 3357 |
|
SET_CURRENT_SOURCE();
|
| 3358 |
3358 |
result = rb_yield_0(result, 0, 0, 0, node->nd_state);
|
| 3359 |
3359 |
break;
|
| ... | ... | |
| 3387 |
3387 |
rescuing = -1;
|
| 3388 |
3388 |
while (resq) {
|
| 3389 |
|
ruby_current_node = resq;
|
|
3389 |
SET_CURRENT_NODE(resq);
|
| 3390 |
3390 |
if (handle_rescue(self, resq)) {
|
| 3391 |
3391 |
state = 0;
|
| ... | ... | |
| 3533 |
3533 |
END_CALLARGS;
|
| 3534 |
3534 |
|
| 3535 |
|
ruby_current_node = node;
|
| 3536 |
|
SET_CURRENT_SOURCE();
|
|
3535 |
SET_CURRENT_NODE(node);
|
| 3537 |
3536 |
rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,scope,self);
|
| 3538 |
3537 |
result = argv[argc-1];
|
| ... | ... | |
| 3551 |
3550 |
END_CALLARGS;
|
| 3552 |
3551 |
|
| 3553 |
|
ruby_current_node = node;
|
| 3554 |
|
SET_CURRENT_SOURCE();
|
|
3552 |
SET_CURRENT_NODE(node);
|
| 3555 |
3553 |
result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0,self);
|
| 3556 |
3554 |
}
|
| ... | ... | |
| 3566 |
3564 |
END_CALLARGS;
|
| 3567 |
3565 |
|
| 3568 |
|
ruby_current_node = node;
|
| 3569 |
|
SET_CURRENT_SOURCE();
|
|
3566 |
SET_CURRENT_NODE(node);
|
| 3570 |
3567 |
result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1,self);
|
| 3571 |
3568 |
}
|
| ... | ... | |
| 3573 |
3570 |
|
| 3574 |
3571 |
case NODE_VCALL:
|
| 3575 |
|
SET_CURRENT_SOURCE();
|
| 3576 |
3572 |
result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2,self);
|
| 3577 |
3573 |
break;
|
| ... | ... | |
| 3624 |
3620 |
SETUP_ARGS(node->nd_args);
|
| 3625 |
3621 |
END_CALLARGS;
|
| 3626 |
|
ruby_current_node = node;
|
|
3622 |
SET_CURRENT_NODE(node);
|
| 3627 |
3623 |
}
|
| 3628 |
3624 |
|
| 3629 |
|
SET_CURRENT_SOURCE();
|
| 3630 |
3625 |
result = rb_call_super(argc, argv);
|
| 3631 |
3626 |
}
|
| ... | ... | |
| 5103 |
5098 |
rb_warn("multiple values for a block parameter (%d for 1)\n\tfrom %s:%d",
|
| 5104 |
5099 |
len, cnode->nd_file, nd_line(cnode));
|
| 5105 |
|
ruby_current_node = cnode;
|
|
5100 |
SET_CURRENT_NODE(cnode);
|
| 5106 |
5101 |
}
|
| 5107 |
5102 |
}
|
| ... | ... | |
| 5124 |
5119 |
goto pop_state;
|
| 5125 |
5120 |
}
|
| 5126 |
|
ruby_current_node = node;
|
|
5121 |
SET_CURRENT_NODE(node);
|
| 5127 |
5122 |
|
| 5128 |
5123 |
PUSH_ITER(block->iter);
|
| ... | ... | |
| 5228 |
5223 |
break;
|
| 5229 |
5224 |
}
|
| 5230 |
|
ruby_current_node = cnode;
|
|
5225 |
SET_CURRENT_NODE(cnode);
|
| 5231 |
5226 |
return result;
|
| 5232 |
5227 |
}
|
| ... | ... | |
| 5367 |
5362 |
int pcall;
|
| 5368 |
5363 |
{
|
| 5369 |
|
ruby_current_node = lhs;
|
|
5364 |
SET_CURRENT_NODE(lhs);
|
| 5370 |
5365 |
if (val == Qundef) {
|
| 5371 |
5366 |
rb_warning("assigning void value");
|
| ... | ... | |
| 5434 |
5429 |
if (!lhs->nd_args) {
|
| 5435 |
5430 |
/* attr set */
|
| 5436 |
|
ruby_current_node = lhs;
|
| 5437 |
|
SET_CURRENT_SOURCE();
|
|
5431 |
SET_CURRENT_NODE(lhs);
|
| 5438 |
5432 |
rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, scope, self);
|
| 5439 |
5433 |
}
|
| ... | ... | |
| 5444 |
5438 |
args = rb_eval(self, lhs->nd_args);
|
| 5445 |
5439 |
rb_ary_push(args, val);
|
| 5446 |
|
ruby_current_node = lhs;
|
| 5447 |
|
SET_CURRENT_SOURCE();
|
|
5440 |
SET_CURRENT_NODE(lhs);
|
| 5448 |
5441 |
rb_call(CLASS_OF(recv), recv, lhs->nd_mid,
|
| 5449 |
5442 |
RARRAY(args)->len, RARRAY(args)->ptr, scope, self);
|
| ... | ... | |
| 5764 |
5757 |
}
|
| 5765 |
5758 |
|
| 5766 |
|
ruby_current_node = cnode;
|
|
5759 |
SET_CURRENT_NODE(cnode);
|
| 5767 |
5760 |
{
|
| 5768 |
5761 |
int n = 0;
|
| ... | ... | |
| 10094 |
10087 |
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
|
| 10095 |
10088 |
}
|
|
10089 |
ruby_set_current_source();
|
| 10096 |
10090 |
if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) {
|
| 10097 |
10091 |
node = NEW_DMETHOD(method_unbind(body));
|
| ... | ... | |
| 10126 |
10120 |
|
| 10127 |
10121 |
/*
|
|
10122 |
* call-seq:
|
|
10123 |
* prc.source_location => [String, Fixnum]
|
|
10124 |
*
|
|
10125 |
* returns the ruby source filename and line number containing this proc
|
|
10126 |
* or nil if this proc was not defined in ruby (i.e. native)
|
|
10127 |
*/
|
|
10128 |
|
|
10129 |
VALUE
|
|
10130 |
rb_proc_location(VALUE self)
|
|
10131 |
{
|
|
10132 |
struct BLOCK *data;
|
|
10133 |
NODE *node;
|
|
10134 |
|
|
10135 |
Data_Get_Struct(self, struct BLOCK, data);
|
|
10136 |
if ((node = data->frame.node) || (node = data->body)) {
|
|
10137 |
const char *filename = node->nd_file;
|
|
10138 |
int lineno = nd_line(node);
|
|
10139 |
if (filename) {
|
|
10140 |
return rb_assoc_new(rb_str_new2(filename), INT2FIX(lineno));
|
|
10141 |
}
|
|
10142 |
}
|
|
10143 |
return Qnil;
|
|
10144 |
}
|
|
10145 |
|
|
10146 |
/*
|
|
10147 |
* call-seq:
|
|
10148 |
* meth.source_location => [String, Fixnum]
|
|
10149 |
*
|
|
10150 |
* returns the ruby source filename and line number containing this method
|
|
10151 |
* or nil if this method was not defined in ruby (i.e. native)
|
|
10152 |
*/
|
|
10153 |
|
|
10154 |
VALUE
|
|
10155 |
rb_method_location(VALUE method)
|
|
10156 |
{
|
|
10157 |
struct METHOD *data;
|
|
10158 |
NODE *node;
|
|
10159 |
|
|
10160 |
Data_Get_Struct(method, struct METHOD, data);
|
|
10161 |
if (node = data->body) {
|
|
10162 |
const char *filename = node->nd_file;
|
|
10163 |
int lineno = nd_line(node);
|
|
10164 |
if (filename) {
|
|
10165 |
return rb_assoc_new(rb_str_new2(filename), INT2FIX(lineno));
|
|
10166 |
}
|
|
10167 |
}
|
|
10168 |
return Qnil;
|
|
10169 |
}
|
|
10170 |
|
|
10171 |
/*
|
| 10128 |
10172 |
* <code>Proc</code> objects are blocks of code that have been bound to
|
| 10129 |
10173 |
* a set of local variables. Once bound, the code may be called in
|
| ... | ... | |
| 10177 |
10221 |
rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
|
| 10178 |
10222 |
rb_define_method(rb_cProc, "binding", proc_binding, 0);
|
|
10223 |
rb_define_method(rb_cProc, "source_location", rb_proc_location, 0);
|
| 10179 |
10224 |
|
| 10180 |
10225 |
rb_define_global_function("proc", proc_lambda, 0);
|
| ... | ... | |
| 10197 |
10242 |
rb_define_method(rb_cMethod, "unbind", method_unbind, 0);
|
| 10198 |
10243 |
rb_define_method(rb_mKernel, "method", rb_obj_method, 1);
|
|
10244 |
rb_define_method(rb_cMethod, "source_location", rb_method_location, 0);
|
| 10199 |
10245 |
|
| 10200 |
10246 |
rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject);
|
| ... | ... | |
| 10209 |
10255 |
rb_define_method(rb_cUnboundMethod, "owner", method_owner, 0);
|
| 10210 |
10256 |
rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1);
|
|
10257 |
rb_define_method(rb_cUnboundMethod, "source_location", rb_method_location, 0);
|
| 10211 |
10258 |
rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1);
|
| 10212 |
10259 |
}
|