summaryrefslogtreecommitdiff
path: root/symbol.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-14 07:23:08 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-14 07:23:08 (GMT)
commit3e69b074c5ad87778fac4d7974fe1e5fc11d5ed3 (patch)
tree383e5d90d8841b425a753ed220d060444aaffa6f /symbol.h
parent5617e317713b55d544fb493d9346d2330c60c727 (diff)
symbol.c: immortal IDs
* symbol.c (global_symbols): make IDs immortal always, instead of treating dynamic symbols as IDs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 58e03c0..d624a46 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