aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.h
diff options
context:
space:
mode:
Diffstat (limited to 'symbol.h')
-rw-r--r--symbol.h33
1 files changed, 24 insertions, 9 deletions
diff --git a/symbol.h b/symbol.h
index 5c52b9742b..001d6de1f8 100644
--- a/symbol.h
+++ b/symbol.h
@@ -32,15 +32,6 @@ struct RSymbol {
#define RSYMBOL(obj) (R_CAST(RSymbol)(obj))
-static inline int
-id_type(ID id)
-{
- if (id<=tLAST_OP_ID) {
- return -1;
- }
- return (int)(id&ID_SCOPE_MASK);
-}
-
#define is_notop_id(id) ((id)>tLAST_OP_ID)
#define is_local_id(id) (id_type(id)==ID_LOCAL)
#define is_global_id(id) (id_type(id)==ID_GLOBAL)
@@ -51,6 +42,30 @@ id_type(ID id)
#define is_junk_id(id) (id_type(id)==ID_JUNK)
static inline int
+id_type(ID id)
+{
+ if (is_notop_id(id)) {
+ return (int)(id&ID_SCOPE_MASK);
+ }
+ else {
+ return -1;
+ }
+}
+
+typedef uint32_t rb_id_serial_t;
+
+static inline rb_id_serial_t
+rb_id_to_serial(ID id)
+{
+ if (is_notop_id(id)) {
+ return (rb_id_serial_t)(id >> ID_SCOPE_SHIFT);
+ }
+ else {
+ return (rb_id_serial_t)id;
+ }
+}
+
+static inline int
sym_type(VALUE sym)
{
ID id;