summaryrefslogtreecommitdiff
path: root/symbol.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-09 08:07:32 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-09 08:07:32 (GMT)
commit94ce481263d0eb09ed366b42d8b3afddbd471e16 (patch)
treee4d7b90bdeccaa079f25423ab73b1c2927b50944 /symbol.h
parentd299250afa2c559db3f7ef6ba777ccb1b795c00d (diff)
symbol.c, symbol.h: split from parse.y
* symbol.c, symbol.h: Symbol class implementation and internals, split from parse.y. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.h')
-rw-r--r--symbol.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/symbol.h b/symbol.h
new file mode 100644
index 0000000..b801fbf
--- /dev/null
+++ b/symbol.h
@@ -0,0 +1,56 @@
+/**********************************************************************
+
+ symbol.h -
+
+ $Author$
+ created at: Tue Jul 8 15:49:54 JST 2014
+
+ Copyright (C) 2014 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#ifndef RUBY_SYMBOL_H
+#define RUBY_SYMBOL_H 1
+
+#include "id.h"
+
+#define ID_DYNAMIC_SYM_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_TOKEN)
+#define STATIC_SYM2ID(sym) RSHIFT((unsigned long)(sym), RUBY_SPECIAL_SHIFT)
+#define STATIC_ID2SYM(id) (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG)
+
+static inline int
+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);
+ }
+}
+
+#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)
+#define is_instance_id(id) (id_type(id)==ID_INSTANCE)
+#define is_attrset_id(id) (id_type(id)==ID_ATTRSET)
+#define is_const_id(id) (id_type(id)==ID_CONST)
+#define is_class_id(id) (id_type(id)==ID_CLASS)
+#define is_junk_id(id) (id_type(id)==ID_JUNK)
+
+RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e - 0x20 + 31) / 32];
+
+static inline int
+is_global_name_punct(const int c)
+{
+ if (c <= 0x20 || 0x7e < c) return 0;
+ return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
+}
+
+ID rb_intern_cstr_without_pindown(const char *, long, rb_encoding *);
+
+#endif