summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y43
1 files changed, 26 insertions, 17 deletions
diff --git a/parse.y b/parse.y
index 435221d8d8..6368a646d4 100644
--- a/parse.y
+++ b/parse.y
@@ -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;
{