* parse.y (assignable_gen): get rid of macro collision.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-10-02 17:59:25 +00:00
parent 1a78256861
commit a0f667c33e
2 changed files with 28 additions and 25 deletions

View File

@ -1,3 +1,7 @@
Sat Oct 3 02:59:21 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (assignable_gen): get rid of macro collision.
Sat Oct 3 02:49:50 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Oct 3 02:49:50 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (ary_make_shared): should count frozen array itself. * array.c (ary_make_shared): should count frozen array itself.

49
parse.y
View File

@ -8013,77 +8013,76 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
{ {
#ifdef RIPPER #ifdef RIPPER
ID id = get_id(lhs); ID id = get_id(lhs);
# define RETURN(x) return get_value(lhs) # define assignable_result(x) get_value(lhs)
# define ERROR(x) dispatch1(assign_error, lhs) # define parser_yyerror(x) dispatch1(assign_error, lhs)
#else #else
# define RETURN(x) return x # define assignable_result(x) x
# define ERROR(x) yyerror(x)
#endif #endif
if (!id) RETURN(0); if (!id) return assignable_result(0);
if (id == keyword_self) { if (id == keyword_self) {
ERROR("Can't change the value of self"); yyerror("Can't change the value of self");
} }
else if (id == keyword_nil) { else if (id == keyword_nil) {
ERROR("Can't assign to nil"); yyerror("Can't assign to nil");
} }
else if (id == keyword_true) { else if (id == keyword_true) {
ERROR("Can't assign to true"); yyerror("Can't assign to true");
} }
else if (id == keyword_false) { else if (id == keyword_false) {
ERROR("Can't assign to false"); yyerror("Can't assign to false");
} }
else if (id == keyword__FILE__) { else if (id == keyword__FILE__) {
ERROR("Can't assign to __FILE__"); yyerror("Can't assign to __FILE__");
} }
else if (id == keyword__LINE__) { else if (id == keyword__LINE__) {
ERROR("Can't assign to __LINE__"); yyerror("Can't assign to __LINE__");
} }
else if (id == keyword__ENCODING__) { else if (id == keyword__ENCODING__) {
ERROR("Can't assign to __ENCODING__"); yyerror("Can't assign to __ENCODING__");
} }
else if (is_local_id(id)) { else if (is_local_id(id)) {
if (dyna_in_block()) { if (dyna_in_block()) {
if (dvar_curr(id)) { if (dvar_curr(id)) {
RETURN(NEW_DASGN_CURR(id, val)); return assignable_result(NEW_DASGN_CURR(id, val));
} }
else if (dvar_defined(id)) { else if (dvar_defined(id)) {
RETURN(NEW_DASGN(id, val)); return assignable_result(NEW_DASGN(id, val));
} }
else if (local_id(id)) { else if (local_id(id)) {
RETURN(NEW_LASGN(id, val)); return assignable_result(NEW_LASGN(id, val));
} }
else { else {
dyna_var(id); dyna_var(id);
RETURN(NEW_DASGN_CURR(id, val)); return assignable_result(NEW_DASGN_CURR(id, val));
} }
} }
else { else {
if (!local_id(id)) { if (!local_id(id)) {
local_var(id); local_var(id);
} }
RETURN(NEW_LASGN(id, val)); return assignable_result(NEW_LASGN(id, val));
} }
} }
else if (is_global_id(id)) { else if (is_global_id(id)) {
RETURN(NEW_GASGN(id, val)); return assignable_result(NEW_GASGN(id, val));
} }
else if (is_instance_id(id)) { else if (is_instance_id(id)) {
RETURN(NEW_IASGN(id, val)); return assignable_result(NEW_IASGN(id, val));
} }
else if (is_const_id(id)) { else if (is_const_id(id)) {
if (!in_def && !in_single) if (!in_def && !in_single)
RETURN(NEW_CDECL(id, val, 0)); return assignable_result(NEW_CDECL(id, val, 0));
ERROR("dynamic constant assignment"); yyerror("dynamic constant assignment");
} }
else if (is_class_id(id)) { else if (is_class_id(id)) {
RETURN(NEW_CVASGN(id, val)); return assignable_result(NEW_CVASGN(id, val));
} }
else { else {
compile_error(PARSER_ARG "identifier %s is not valid to set", rb_id2name(id)); compile_error(PARSER_ARG "identifier %s is not valid to set", rb_id2name(id));
} }
RETURN(0); return assignable_result(0);
#undef RETURN #undef assignable_result
#undef ERROR #undef parser_yyerror
} }
static ID static ID