diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-11-17 07:30:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-11-17 07:30:37 +0000 |
commit | 8e48dc16e97a783a69f0972b4882ad2faae561ea (patch) | |
tree | c25927a4f286e4ed5f3c7637076332e99287b089 /parse.y | |
parent | 943e99e62746388456955729e9f8417f3df5f8b5 (diff) |
19991117
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 43 |
1 files changed, 26 insertions, 17 deletions
@@ -26,14 +26,14 @@ #define ID_INSTANCE 0x02 #define ID_GLOBAL 0x03 #define ID_ATTRSET 0x04 -#define ID_CONST 0x05 +#define ID_SHARED 0x05 -#define is_id_notop(id) ((id)>LAST_TOKEN) -#define is_local_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL) -#define is_global_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL) -#define is_instance_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE) -#define is_attrset_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET) -#define is_const_id(id) (is_id_notop(id)&&((id)&ID_SCOPE_MASK)==ID_CONST) +#define is_notop_id(id) ((id)>LAST_TOKEN) +#define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL) +#define is_global_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL) +#define is_instance_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE) +#define is_attrset_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET) +#define is_shared_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_SHARED) NODE *ruby_eval_tree_begin = 0; NODE *ruby_eval_tree = 0; @@ -1787,10 +1787,10 @@ yycompile(f) int n; if (!ruby_in_eval && rb_safe_level() == 0 && - rb_const_defined(rb_cObject, rb_intern("LINES__"))) { + rb_shvar_defined(rb_cObject, rb_intern("LINES__"))) { VALUE hash, fname; - hash = rb_const_get(rb_cObject, rb_intern("LINES__")); + hash = rb_shvar_get(rb_cObject, rb_intern("LINES__")); if (TYPE(hash) == T_HASH) { fname = rb_str_new2(f); ruby_debug_lines = rb_hash_aref(hash, fname); @@ -3715,7 +3715,7 @@ gettable(id) else if (is_instance_id(id)) { return NEW_IVAR(id); } - else if (is_const_id(id)) { + else if (is_shared_id(id)) { return NEW_CVAR(id); } rb_bug("invalid id for gettable"); @@ -3766,10 +3766,11 @@ assignable(id, val) else if (is_instance_id(id)) { lhs = NEW_IASGN(id, val); } - else if (is_const_id(id)) { + else if (is_shared_id(id)) { if (cur_mid || in_single) - yyerror("dynamic constant assignment"); - lhs = NEW_CASGN(id, val); + lhs = NEW_CASGN(id, val); + else + lhs = NEW_CDECL(id, val); } else { rb_bug("bad id for variable"); @@ -3854,8 +3855,9 @@ node_assign(lhs, rhs) case NODE_LASGN: case NODE_DASGN: case NODE_DASGN_PUSH: - case NODE_CASGN: case NODE_MASGN: + case NODE_CASGN: + case NODE_CDECL: lhs->nd_value = rhs; break; @@ -4494,7 +4496,7 @@ rb_intern(name) id = ID_ATTRSET; } else if (ISUPPER(name[0])) { - id = ID_CONST; + id = ID_SHARED; } else { id = ID_LOCAL; @@ -4547,14 +4549,21 @@ rb_id2name(id) } int -rb_is_const_id(id) +rb_is_shared_id(id) ID id; { - if (is_const_id(id)) return Qtrue; + if (is_shared_id(id)) return Qtrue; return Qfalse; } int +rb_is_const_id(id) + ID id; +{ + return rb_is_shared_id(id); +} + +int rb_is_instance_id(id) ID id; { |