summaryrefslogtreecommitdiff
path: root/symbol.h
diff options
context:
space:
mode:
Diffstat (limited to 'symbol.h')
-rw-r--r--symbol.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/symbol.h b/symbol.h
index 58e03c043e..d624a46d20 100644
--- a/symbol.h
+++ b/symbol.h
@@ -17,7 +17,7 @@
struct RSymbol {
struct RBasic basic;
VALUE fstr;
- ID type;
+ ID id;
};
#define RSYMBOL(obj) (R_CAST(RSymbol)(obj))
@@ -28,13 +28,7 @@ id_type(ID id)
if (id<=tLAST_OP_ID) {
return -1;
}
- if (id&ID_STATIC_SYM) {
- return (int)((id)&ID_SCOPE_MASK);
- }
- else {
- VALUE dsym = (VALUE)id;
- return (int)(RSYMBOL(dsym)->type);
- }
+ return (int)(id&ID_SCOPE_MASK);
}
#define is_notop_id(id) ((id)>tLAST_OP_ID)
@@ -46,6 +40,30 @@ id_type(ID id)
#define is_class_id(id) (id_type(id)==ID_CLASS)
#define is_junk_id(id) (id_type(id)==ID_JUNK)
+static inline int
+sym_type(VALUE sym)
+{
+ ID id;
+ if (STATIC_SYM_P(sym)) {
+ id = RSHIFT(sym, RUBY_SPECIAL_SHIFT);
+ if (id<=tLAST_OP_ID) {
+ return -1;
+ }
+ }
+ else {
+ id = RSYMBOL(sym)->id;
+ }
+ return (int)(id&ID_SCOPE_MASK);
+}
+
+#define is_local_sym(sym) (sym_type(sym)==SYM_LOCAL)
+#define is_global_sym(sym) (sym_type(sym)==SYM_GLOBAL)
+#define is_instance_sym(sym) (sym_type(sym)==SYM_INSTANCE)
+#define is_attrset_sym(sym) (sym_type(sym)==SYM_ATTRSET)
+#define is_const_sym(sym) (sym_type(sym)==SYM_CONST)
+#define is_class_sym(sym) (sym_type(sym)==SYM_CLASS)
+#define is_junk_sym(sym) (sym_type(sym)==SYM_JUNK)
+
RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e - 0x20 + 31) / 32];
static inline int