summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y52
1 files changed, 31 insertions, 21 deletions
diff --git a/parse.y b/parse.y
index 8a31a74158d..f5e79c18e74 100644
--- a/parse.y
+++ b/parse.y
@@ -8785,7 +8785,11 @@ rb_id_attrset(ID id)
}
else {
int scope = (int)(id & ID_SCOPE_MASK);
- if (scope != ID_LOCAL && scope != ID_CONST) {
+ switch (scope) {
+ case ID_LOCAL: case ID_INSTANCE: case ID_GLOBAL:
+ case ID_CONST: case ID_CLASS: case ID_JUNK:
+ break;
+ default:
rb_bug("rb_id_attrset: %s ID - %"PRIdVALUE, id_type_names[scope],
(VALUE)id);
@@ -10415,24 +10419,25 @@ intern_str(VALUE str)
}
}
}
-
- if (m[last] == '=') {
- /* attribute assignment */
- id = rb_intern3(name, last, enc);
- if (id > tLAST_OP_ID && !is_attrset_id(id)) {
- enc = rb_enc_get(rb_id2str(id));
- id = rb_id_attrset(id);
- goto id_register;
- }
- id = ID_ATTRSET;
+ break;
+ }
+ if (name[last] == '=') {
+ /* attribute assignment */
+ id = rb_intern3(name, last, enc);
+ if (id > tLAST_OP_ID && !is_attrset_id(id)) {
+ enc = rb_enc_get(rb_id2str(id));
+ id = rb_id_attrset(id);
+ goto id_register;
}
- else if (rb_enc_isupper(m[0], enc)) {
+ id = ID_ATTRSET;
+ }
+ else if (id == 0) {
+ if (rb_enc_isupper(m[0], enc)) {
id = ID_CONST;
- }
+ }
else {
id = ID_LOCAL;
}
- break;
}
if (!rb_enc_isdigit(*m, enc)) {
while (m <= name + last && is_identchar(m, e, enc)) {
@@ -10444,7 +10449,7 @@ intern_str(VALUE str)
}
}
}
- if (m - name < len) id = ID_JUNK;
+ if (id != ID_ATTRSET && m - name < len) id = ID_JUNK;
if (sym_check_asciionly(str)) symenc = rb_usascii_encoding();
new_id:
if (symenc != enc) rb_enc_associate(str, symenc);
@@ -10527,16 +10532,21 @@ rb_id2str(ID id)
}
if (is_attrset_id(id)) {
- ID id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL;
+ ID id_stem = (id & ~ID_SCOPE_MASK);
VALUE str;
- while (!(str = rb_id2str(id2))) {
- if (!is_local_id(id2)) return 0;
- id2 = (id & ~ID_SCOPE_MASK) | ID_CONST;
- }
+ do {
+ if (!!(str = rb_id2str(id_stem | ID_LOCAL))) break;
+ if (!!(str = rb_id2str(id_stem | ID_CONST))) break;
+ if (!!(str = rb_id2str(id_stem | ID_INSTANCE))) break;
+ if (!!(str = rb_id2str(id_stem | ID_GLOBAL))) break;
+ if (!!(str = rb_id2str(id_stem | ID_CLASS))) break;
+ if (!!(str = rb_id2str(id_stem | ID_JUNK))) break;
+ return 0;
+ } while (0);
str = rb_str_dup(str);
rb_str_cat(str, "=", 1);
- rb_intern_str(str);
+ register_symid_str(id, str);
if (st_lookup(global_symbols.id_str, id, &data)) {
VALUE str = (VALUE)data;
if (RBASIC(str)->klass == 0)