19 # define SYMBOL_DEBUG 0 22 #define SYMBOL_PINNED_P(sym) (RSYMBOL(sym)->id&~ID_SCOPE_MASK) 24 #define STATIC_SYM2ID(sym) RSHIFT((unsigned long)(sym), RUBY_SPECIAL_SHIFT) 28 #define REGISTER_SYMID(id, name) register_static_symid((id), (name), strlen(name), enc) 31 #define is_identchar(p,e,enc) (ISALNUM((unsigned char)*(p)) || (*(p)) == '_' || !ISASCII(*(p))) 33 #define op_tbl_count numberof(op_tbl) 35 #define op_tbl_len(i) (!op_tbl[i].name[1] ? 1 : !op_tbl[i].name[2] ? 2 : 3) 43 for (i =
'!'; i <=
'~'; ++i) {
148 (
int)
sizeof(id_types[0]), id_types[scope], (
VALUE)
id);
168 if (m >= e)
return 0;
172 else if (*m ==
'-') {
173 if (++m >= e)
return 0;
184 }
while (m < e &&
ISDIGIT(*m));
186 return m == e ? mb + 1 : 0;
201 #define IDSET_ATTRSET_FOR_SYNTAX ((1U<<ID_LOCAL)|(1U<<ID_CONST)) 202 #define IDSET_ATTRSET_FOR_INTERN (~(~0U<<(1<<ID_SCOPE_SHIFT)) & ~(1U<<ID_ATTRSET)) 207 const char *m =
name;
208 const char *e = m +
len;
212 if (!m || len <= 0)
return -1;
232 case '<': ++m;
break;
233 case '=':
if (*++m ==
'>') ++m;
break;
240 case '>':
case '=': ++m;
break;
246 case '~': ++m;
break;
247 case '=':
if (*++m ==
'=') ++m;
break;
253 if (*++m ==
'*') ++m;
257 if (*++m ==
'@') ++m;
260 case '|':
case '^':
case '&':
case '/':
case '%':
case '~':
case '`':
265 if (m[1] !=
']')
goto id;
267 if (*++m ==
'=') ++m;
273 case '=':
case '~': ++m;
break;
275 if (allowed_attrset & (1
U <<
ID_JUNK))
goto id;
284 if (len > 1 && *(e-1) ==
'=') {
297 if (m + 1 < e || *m !=
'=')
break;
300 if (!(allowed_attrset & (1
U << type)))
return -1;
307 return m == e ? type : -1;
388 register_sym_update_callback, (
st_data_t)sym);
449 must_be_dynamic_symbol(
VALUE x)
459 rb_bug(
"wrong argument: inappropriate Symbol (%p)", (
void *)x);
482 RSYMBOL(dsym)->hashval = RSHIFT((
long)hashval, 1);
572 if (next_serial == 0) {
750 if (
RBASIC(str)->klass == 0)
1018 #undef rb_sym_intern_cstr 1019 #undef rb_sym_intern_ascii_cstr RUBY_EXTERN VALUE rb_cString
const char * rb_builtin_class_name(VALUE x)
int rb_is_instance_id(ID id)
ID rb_intern2(const char *name, long len)
static int rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset)
ID rb_check_id(volatile VALUE *namep)
Returns ID for the given name if it is interned already, or 0.
ID rb_make_internal_id(void)
static ID register_static_symid_str(ID, VALUE)
VALUE rb_ary_entry(VALUE ary, long offset)
static void register_sym(VALUE str, VALUE sym)
static void Init_id(void)
static rb_id_serial_t rb_id_to_serial(ID id)
void rb_bug(const char *fmt,...)
size_t strlen(const char *)
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc)
static VALUE lookup_str_sym(const VALUE str)
#define IDSET_ATTRSET_FOR_SYNTAX
unsigned int UINT8 __attribute__((__mode__(__QI__)))
static void Init_op_tbl(void)
#define is_const_sym(sym)
int rb_is_class_name(VALUE name)
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc)
int rb_is_attrset_sym(VALUE sym)
VALUE rb_str_cat(VALUE, const char *, long)
VALUE rb_sym_intern_ascii(const char *ptr, long len)
#define is_local_sym(sym)
static void set_id_entry(rb_id_serial_t num, VALUE str, VALUE sym)
int rb_is_const_id(ID id)
static const struct @116 op_tbl[]
VALUE rb_ary_push(VALUE ary, VALUE item)
ID rb_intern3(const char *name, long len, rb_encoding *enc)
int rb_is_local_name(VALUE name)
VALUE rb_ary_tmp_new(long capa)
int rb_enc_str_coderange(VALUE)
int rb_is_global_sym(VALUE sym)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
int rb_objspace_garbage_object_p(VALUE obj)
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
st_index_t rb_str_hash(VALUE)
static ID attrsetname_to_attr_id(VALUE name)
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg)
static ID rb_id_serial_to_id(rb_id_serial_t num)
int rb_enc_symname_p(const char *name, rb_encoding *enc)
enum ruby_id_types id_types
int rb_is_method_name(VALUE name)
VALUE rb_check_symbol(volatile VALUE *namep)
#define ENC_CODERANGE_7BIT
void rb_name_error_str(VALUE str, const char *fmt,...)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
void rb_name_error(ID id, const char *fmt,...)
static VALUE dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding *const enc, const ID type)
#define is_attrset_sym(sym)
int rb_is_junk_sym(VALUE sym)
#define RBASIC_SET_CLASS_RAW(obj, cls)
#define RB_TYPE_P(obj, type)
#define is_identchar(p, e, enc)
VALUE rb_sym_all_symbols(void)
int rb_is_junk_name(VALUE name)
#define is_global_sym(sym)
static void unregister_sym(VALUE str, VALUE sym)
int rb_is_const_name(VALUE name)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static ID lookup_str_id(VALUE str)
static int is_special_global_name(const char *m, const char *e, rb_encoding *enc)
int rb_is_class_id(ID id)
int rb_is_global_name(VALUE name)
#define st_init_table_with_size
VALUE rb_hash_delete_entry(VALUE hash, VALUE key)
static VALUE dsymbol_check(const VALUE sym)
#define SYMBOL_PINNED_P(sym)
void rb_ary_store(VALUE ary, long idx, VALUE val)
#define is_instance_sym(sym)
char ary[RSTRING_EMBED_LEN_MAX+1]
int rb_is_class_sym(VALUE sym)
void rb_gc_register_mark_object(VALUE obj)
#define ENC_CODERANGE_BROKEN
#define is_attrset_id(id)
#define RUBY_DTRACE_CREATE_HOOK(name, arg)
int rb_is_local_sym(VALUE sym)
int rb_str_hash_cmp(VALUE, VALUE)
static const struct st_hash_type symhash
const char * rb_id2name(ID id)
int rb_is_instance_name(VALUE name)
VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
static ID intern_str(VALUE str, int mutable)
#define STATIC_SYM2ID(sym)
static int sym_check_asciionly(VALUE str)
void rb_fatal(const char *fmt,...)
VALUE rb_sym2str(VALUE sym)
ID rb_intern(const char *name)
rb_encoding * rb_usascii_encoding(void)
int rb_symname_p(const char *name)
VALUE rb_obj_hide(VALUE obj)
#define IDSET_ATTRSET_FOR_INTERN
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
VALUE rb_sym_intern_ascii_cstr(const char *ptr)
static ID next_id_base(void)
#define rb_enc_asciicompat(enc)
VALUE rb_str_ellipsize(VALUE, long)
Shortens str and adds three dots, an ellipsis, if it is longer than len characters.
void rb_gc_free_dsymbol(VALUE sym)
FUNC_MINIMIZED(VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc))
int rb_is_global_id(ID id)
static struct symbols global_symbols
int rb_is_const_sym(VALUE sym)
static VALUE get_id_entry(rb_id_serial_t num, const enum id_entry_type t)
register unsigned int len
int rb_enc_symname2_p(const char *name, long len, rb_encoding *enc)
rb_encoding * rb_enc_get(VALUE obj)
VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc)
VALUE rb_ident_hash_new(void)
int rb_is_instance_sym(VALUE sym)
static int symbols_i(st_data_t key, st_data_t value, st_data_t arg)
static int rb_str_symname_type(VALUE name, unsigned int allowed_attrset)
#define is_instance_id(id)
VALUE rb_str_intern(VALUE str)
STATIC_ASSERT(op_tbl_name_size, sizeof(op_tbl[0].name)==3)
VALUE rb_newobj_of(VALUE klass, VALUE flags)
VALUE rb_check_string_type(VALUE)
int rb_is_attrset_name(VALUE name)
ID rb_intern_str(VALUE str)
#define STATIC_ID2SYM(id)
size_t rb_sym_immortal_count(void)
static int is_global_name_punct(const int c)
static int id_type(ID id)
int rb_is_local_id(ID id)
#define is_class_sym(sym)
static VALUE lookup_id_str(ID id)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
int rb_is_attrset_id(ID id)
#define StringValuePtr(v)
VALUE rb_str_new_frozen(VALUE)
static ID attrsetname_to_attr(VALUE name)
rb_encoding * rb_ascii8bit_encoding(void)
static ID register_static_symid(ID, const char *, long, rb_encoding *)
RUBY_EXTERN VALUE rb_cSymbol
WARN_UNUSED_RESULT(static VALUE dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding *const enc, const ID type))
#define RB_OBJ_WRITE(a, slot, b)