Project

General

Profile

Bug #5002 » ripper.vcall.diff

adgar (Michael Edgar), 07/09/2011 12:24 PM

View differences:

parse.y (working copy)
#define get_value(val) ripper_get_value(val)
static VALUE assignable_gen(struct parser_params*,VALUE);
#define assignable(lhs,node) assignable_gen(parser, (lhs))
static int id_is_var_gen(struct parser_params *parser, ID id);
#define id_is_var(id) id_is_var_gen(parser, (id))
#endif /* !RIPPER */
static ID formal_argument_gen(struct parser_params*, ID);
......
/*%%%*/
if (!($$ = gettable($1))) $$ = NEW_BEGIN(0);
/*%
$$ = dispatch1(var_ref, $1);
if (id_is_var(get_id($1))) {
$$ = dispatch1(var_ref, $1);
} else {
$$ = dispatch1(vcall, $1);
}
%*/
}
;
......
return t;
}
#ifndef RIPPER
#ifdef RIPPER
static int
id_is_var_gen(struct parser_params *parser, ID id)
{
if (id == keyword_self || id == keyword_nil || id == keyword_true || id == keyword_false ||
id == keyword__FILE__ || id == keyword__LINE__ || id == keyword__ENCODING__ ||
is_global_id(id) || is_instance_id(id) || is_const_id(id) || is_class_id(id)) {
return 1;
}
else if (is_local_id(id)) {
if (dyna_in_block() && dvar_defined(id)) return 1;
if (local_id(id)) return 1;
/* method call without arguments */
return 0;
}
compile_error(PARSER_ARG "identifier %s is not valid to get", rb_id2name(id));
return 0;
}
#else /* !RIPPER */
static NODE*
node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
{
(1-1/3)