Project

General

Profile

Feature #2013 ยป unary_star_op_svn.diff

jeremye (Jeremy Evans), 08/30/2009 02:53 PM

View differences:

insns.def (working copy)
(VALUE ary)
(VALUE obj)
{
VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_a");
VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "*@");
if (NIL_P(tmp)) {
tmp = rb_ary_new3(1, ary);
}
object.c (working copy)
VALUE rb_cTrueClass;
VALUE rb_cFalseClass;
static ID id_eq, id_eql, id_match, id_inspect, id_init_copy;
static ID id_eq, id_eql, id_to_a, id_match, id_inspect, id_init_copy;
/*
* call-seq:
......
return RTEST(result) ? Qfalse : Qtrue;
}
/*
* call-seq:
* a = *obj => obj.to_a or [obj]
*
* Returns obj.to_a if obj responds_to? to_a, otherwise
* the obj wrapped in an array.
*/
VALUE
rb_obj_splat(VALUE obj)
{
VALUE ary;
if (rb_respond_to(obj, id_to_a))
ary = rb_funcall(obj, id_to_a, 0);
else {
ary = rb_ary_new3(1, obj);
}
return ary;
}
VALUE
rb_class_real(VALUE cl)
{
if (cl == 0)
......
rb_define_method(rb_cBasicObject, "equal?", rb_obj_equal, 1);
rb_define_method(rb_cBasicObject, "!", rb_obj_not, 0);
rb_define_method(rb_cBasicObject, "!=", rb_obj_not_equal, 1);
rb_define_method(rb_cBasicObject, "*@", rb_obj_splat, 0);
rb_define_private_method(rb_cBasicObject, "singleton_method_added", rb_obj_dummy, 1);
rb_define_private_method(rb_cBasicObject, "singleton_method_removed", rb_obj_dummy, 1);
......
id_eq = rb_intern("==");
id_eql = rb_intern("eql?");
id_to_a = rb_intern("to_a");
id_match = rb_intern("=~");
id_inspect = rb_intern("inspect");
id_init_copy = rb_intern("initialize_copy");
parse.y (working copy)
%nonassoc id_core_define_singleton_method
%nonassoc id_core_set_postexe
%token tUSTAR /* unary* */
%token tLAST_TOKEN
%%
......
| '-' { ifndef_ripper($$ = '-'); }
| '*' { ifndef_ripper($$ = '*'); }
| tSTAR { ifndef_ripper($$ = '*'); }
| tUSTAR { ifndef_ripper($$ = tUSTAR); }
| '/' { ifndef_ripper($$ = '/'); }
| '%' { ifndef_ripper($$ = '%'); }
| tPOW { ifndef_ripper($$ = tPOW); }
......
c = tPOW;
}
else {
if ((lex_state == EXPR_FNAME || lex_state == EXPR_DOT) &&
(c == '@')) {
lex_state = EXPR_ARG;
return tUSTAR;
}
if (c == '=') {
set_yylval_id('*');
lex_state = EXPR_BEG;
......
{tLSHFT, "<<"},
{tRSHFT, ">>"},
{tCOLON2, "::"},
{tUSTAR, "*@"},
};
#define op_tbl_count (sizeof(op_tbl) / sizeof(op_tbl[0]))
id.h (working copy)
id_core_define_method = 372,
id_core_define_singleton_method = 373,
id_core_set_postexe = 374,
tLAST_TOKEN = 375,
tLAST_TOKEN = 376,
#endif
idDot2 = tDOT2,
idDot3 = tDOT3,
......
ruby_method_id_check_for(id_core_define_method, 372);
ruby_method_id_check_for(id_core_define_singleton_method, 373);
ruby_method_id_check_for(id_core_set_postexe, 374);
ruby_method_id_check_for(tLAST_TOKEN, 375);
ruby_method_id_check_for(tLAST_TOKEN, 376);
};
#endif
vm_insnhelper.c (working copy)
VALUE ary = *(cfp->sp - 1);
VALUE *ptr;
int i;
VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "to_a");
VALUE tmp = rb_check_convert_type(ary, T_ARRAY, "Array", "*@");
if (NIL_P(tmp)) {
/* do nothing */
    (1-1/1)