Get rid of ID_JUNK

It has been aliased as ID_INTERNAL for a long time and that alias
is much more descriptive.
This commit is contained in:
Jean Boussier 2025-07-28 11:18:54 +02:00
parent 1a68f1b199
commit d488935910
3 changed files with 33 additions and 35 deletions

View file

@ -276,7 +276,7 @@ sym_set_create(VALUE sym, void *data)
RB_OBJ_WRITE((VALUE)obj, &obj->fstr, str); RB_OBJ_WRITE((VALUE)obj, &obj->fstr, str);
int id = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); int id = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
if (id < 0) id = ID_JUNK; if (id < 0) id = ID_INTERNAL;
obj->id = id; obj->id = id;
obj->hashval = rb_str_hash(str); obj->hashval = rb_str_hash(str);
@ -291,7 +291,7 @@ sym_set_create(VALUE sym, void *data)
VALUE static_sym = static_sym_entry->sym; VALUE static_sym = static_sym_entry->sym;
if (static_sym == 0) { if (static_sym == 0) {
ID id = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN); ID id = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
if (id == (ID)-1) id = ID_JUNK; if (id == (ID)-1) id = ID_INTERNAL;
ID nid = next_id_base(); ID nid = next_id_base();
if (nid == (ID)-1) { if (nid == (ID)-1) {
@ -431,7 +431,7 @@ rb_id_attrset(ID id)
scope = id_type(id); scope = id_type(id);
switch (scope) { switch (scope) {
case ID_LOCAL: case ID_INSTANCE: case ID_GLOBAL: case ID_LOCAL: case ID_INSTANCE: case ID_GLOBAL:
case ID_CONST: case ID_CLASS: case ID_JUNK: case ID_CONST: case ID_CLASS: case ID_INTERNAL:
break; break;
case ID_ATTRSET: case ID_ATTRSET:
return id; return id;
@ -476,7 +476,7 @@ rb_id_attrset(ID id)
"attrset", "attrset",
"const", "const",
"class", "class",
"junk", "internal",
}; };
rb_name_error(id, "cannot make anonymous %.*s ID %"PRIxVALUE" attrset", rb_name_error(id, "cannot make anonymous %.*s ID %"PRIxVALUE" attrset",
(int)sizeof(id_types[0]), id_types[scope], (VALUE)id); (int)sizeof(id_types[0]), id_types[scope], (VALUE)id);
@ -602,66 +602,66 @@ enc_synmane_type_leading_chars(const char *name, long len, rb_encoding *enc, int
case '<': case '<':
switch (*++m) { switch (*++m) {
default: return (t) { stophere, ID_JUNK, 1, }; default: return (t) { stophere, ID_INTERNAL, 1, };
case '<': return (t) { stophere, ID_JUNK, 2, }; case '<': return (t) { stophere, ID_INTERNAL, 2, };
case '=': case '=':
switch (*++m) { switch (*++m) {
default: return (t) { stophere, ID_JUNK, 2, }; default: return (t) { stophere, ID_INTERNAL, 2, };
case '>': return (t) { stophere, ID_JUNK, 3, }; case '>': return (t) { stophere, ID_INTERNAL, 3, };
} }
} }
case '>': case '>':
switch (*++m) { switch (*++m) {
default: return (t) { stophere, ID_JUNK, 1, }; default: return (t) { stophere, ID_INTERNAL, 1, };
case '>': case '=': return (t) { stophere, ID_JUNK, 2, }; case '>': case '=': return (t) { stophere, ID_INTERNAL, 2, };
} }
case '=': case '=':
switch (*++m) { switch (*++m) {
default: return (t) { invalid, 0, 1, }; default: return (t) { invalid, 0, 1, };
case '~': return (t) { stophere, ID_JUNK, 2, }; case '~': return (t) { stophere, ID_INTERNAL, 2, };
case '=': case '=':
switch (*++m) { switch (*++m) {
default: return (t) { stophere, ID_JUNK, 2, }; default: return (t) { stophere, ID_INTERNAL, 2, };
case '=': return (t) { stophere, ID_JUNK, 3, }; case '=': return (t) { stophere, ID_INTERNAL, 3, };
} }
} }
case '*': case '*':
switch (*++m) { switch (*++m) {
default: return (t) { stophere, ID_JUNK, 1, }; default: return (t) { stophere, ID_INTERNAL, 1, };
case '*': return (t) { stophere, ID_JUNK, 2, }; case '*': return (t) { stophere, ID_INTERNAL, 2, };
} }
case '+': case '-': case '+': case '-':
switch (*++m) { switch (*++m) {
default: return (t) { stophere, ID_JUNK, 1, }; default: return (t) { stophere, ID_INTERNAL, 1, };
case '@': return (t) { stophere, ID_JUNK, 2, }; case '@': return (t) { stophere, ID_INTERNAL, 2, };
} }
case '|': case '^': case '&': case '/': case '%': case '~': case '`': case '|': case '^': case '&': case '/': case '%': case '~': case '`':
return (t) { stophere, ID_JUNK, 1, }; return (t) { stophere, ID_INTERNAL, 1, };
case '[': case '[':
switch (*++m) { switch (*++m) {
default: return (t) { needmore, ID_JUNK, 0, }; default: return (t) { needmore, ID_INTERNAL, 0, };
case ']': case ']':
switch (*++m) { switch (*++m) {
default: return (t) { stophere, ID_JUNK, 2, }; default: return (t) { stophere, ID_INTERNAL, 2, };
case '=': return (t) { stophere, ID_JUNK, 3, }; case '=': return (t) { stophere, ID_INTERNAL, 3, };
} }
} }
case '!': case '!':
switch (*++m) { switch (*++m) {
case '=': case '~': return (t) { stophere, ID_JUNK, 2, }; case '=': case '~': return (t) { stophere, ID_INTERNAL, 2, };
default: default:
if (allowed_attrset & (1U << ID_JUNK)) { if (allowed_attrset & (1U << ID_INTERNAL)) {
return (t) { needmore, ID_JUNK, 1, }; return (t) { needmore, ID_INTERNAL, 1, };
} }
else { else {
return (t) { stophere, ID_JUNK, 1, }; return (t) { stophere, ID_INTERNAL, 1, };
} }
} }
@ -702,7 +702,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
switch (*m) { switch (*m) {
case '!': case '?': case '!': case '?':
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1; if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
type = ID_JUNK; type = ID_INTERNAL;
++m; ++m;
if (m + 1 < e || *m != '=') break; if (m + 1 < e || *m != '=') break;
/* fall through */ /* fall through */
@ -1144,7 +1144,7 @@ rb_is_local_id(ID id)
int int
rb_is_junk_id(ID id) rb_is_junk_id(ID id)
{ {
return is_junk_id(id); return is_internal_id(id);
} }
int int

View file

@ -39,7 +39,7 @@ struct RSymbol {
#define is_attrset_id(id) ((id)==idASET||id_type(id)==ID_ATTRSET) #define is_attrset_id(id) ((id)==idASET||id_type(id)==ID_ATTRSET)
#define is_const_id(id) (id_type(id)==ID_CONST) #define is_const_id(id) (id_type(id)==ID_CONST)
#define is_class_id(id) (id_type(id)==ID_CLASS) #define is_class_id(id) (id_type(id)==ID_CLASS)
#define is_junk_id(id) (id_type(id)==ID_JUNK) #define is_internal_id(id) (id_type(id)==ID_INTERNAL)
static inline int static inline int
id_type(ID id) id_type(ID id)
@ -91,7 +91,7 @@ sym_type(VALUE sym)
#define is_attrset_sym(sym) (sym_type(sym)==ID_ATTRSET) #define is_attrset_sym(sym) (sym_type(sym)==ID_ATTRSET)
#define is_const_sym(sym) (sym_type(sym)==ID_CONST) #define is_const_sym(sym) (sym_type(sym)==ID_CONST)
#define is_class_sym(sym) (sym_type(sym)==ID_CLASS) #define is_class_sym(sym) (sym_type(sym)==ID_CLASS)
#define is_junk_sym(sym) (sym_type(sym)==ID_JUNK) #define is_internal_sym(sym) (sym_type(sym)==ID_INTERNAL)
#ifndef RIPPER #ifndef RIPPER
RUBY_FUNC_EXPORTED RUBY_FUNC_EXPORTED

View file

@ -1,5 +1,5 @@
%# -*- c -*- %# -*- c -*-
/* DO NOT EDIT THIS FILE DIRECTLY */ /* DO NOT EDIT THIS FILE DIRECTLY: source is at template/id.h.tmpl */
/********************************************************************** /**********************************************************************
id.h - id.h -
@ -19,15 +19,14 @@ types = ids.keys.grep(/^[A-Z]/)
#define RUBY_ID_H #define RUBY_ID_H
enum ruby_id_types { enum ruby_id_types {
RUBY_ID_STATIC_SYM = 0x01,
RUBY_ID_LOCAL = 0x00, RUBY_ID_LOCAL = 0x00,
RUBY_ID_STATIC_SYM = 0x01,
RUBY_ID_INSTANCE = (0x01<<1), RUBY_ID_INSTANCE = (0x01<<1),
RUBY_ID_GLOBAL = (0x03<<1), RUBY_ID_GLOBAL = (0x03<<1),
RUBY_ID_ATTRSET = (0x04<<1), RUBY_ID_ATTRSET = (0x04<<1),
RUBY_ID_CONST = (0x05<<1), RUBY_ID_CONST = (0x05<<1),
RUBY_ID_CLASS = (0x06<<1), RUBY_ID_CLASS = (0x06<<1),
RUBY_ID_JUNK = (0x07<<1), RUBY_ID_INTERNAL = (0x07<<1),
RUBY_ID_INTERNAL = RUBY_ID_JUNK,
RUBY_ID_SCOPE_SHIFT = 4, RUBY_ID_SCOPE_SHIFT = 4,
RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1) RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
}; };
@ -41,7 +40,6 @@ enum ruby_id_types {
#define ID_ATTRSET RUBY_ID_ATTRSET #define ID_ATTRSET RUBY_ID_ATTRSET
#define ID_CONST RUBY_ID_CONST #define ID_CONST RUBY_ID_CONST
#define ID_CLASS RUBY_ID_CLASS #define ID_CLASS RUBY_ID_CLASS
#define ID_JUNK RUBY_ID_JUNK
#define ID_INTERNAL RUBY_ID_INTERNAL #define ID_INTERNAL RUBY_ID_INTERNAL
#define symIFUNC ID2SYM(idIFUNC) #define symIFUNC ID2SYM(idIFUNC)