summaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 07:38:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 07:38:03 +0000
commit298694a2fdf4451163299d61a49a15fe49ab598a (patch)
treee58e7ee0155c1043c0da27a2e9c30699f8668a1c /template
parente8794bf2151bf2427e9a69f86cd818c9ed24d0fa (diff)
id.def: other scope ID
* defs/id.def: support for other scope IDs, ID_{INSTANCE,GLOBAL,CONST,CLASS}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'template')
-rw-r--r--template/id.c.tmpl5
-rw-r--r--template/id.h.tmpl19
2 files changed, 13 insertions, 11 deletions
diff --git a/template/id.c.tmpl b/template/id.c.tmpl
index 4f54f8b..4a272a9 100644
--- a/template/id.c.tmpl
+++ b/template/id.c.tmpl
@@ -11,9 +11,8 @@
**********************************************************************/
<%
-predefined_ids = nil
defs = File.join(File.dirname(erb.filename), "../defs/id.def")
-eval(File.read(defs), binding, defs)
+ids = eval(File.read(defs), binding, defs)
%>
static void
Init_id(void)
@@ -22,7 +21,7 @@ Init_id(void)
#define rb_intern(str) rb_intern_const(str)
rb_encoding *enc = rb_usascii_encoding();
-% predefined_ids.each_pair do |token, name|
+% ids[:predefined].each do |token, name|
REGISTER_SYMID(id<%=token%>, "<%=name%>");
% end
}
diff --git a/template/id.h.tmpl b/template/id.h.tmpl
index b918bb8..8df17b3 100644
--- a/template/id.h.tmpl
+++ b/template/id.h.tmpl
@@ -21,10 +21,9 @@ token_op_ids = %w[
tCOLON2 tCOLON3
]
-preserved_ids = nil
-attr_ids = nil
defs = File.join(File.dirname(erb.filename), "../defs/id.def")
-eval(File.read(defs), binding, defs)
+ids = eval(File.read(defs), binding, defs)
+types = ids.keys.grep(/^[A-Z]/)
%>
#ifndef RUBY_ID_H
#define RUBY_ID_H
@@ -75,16 +74,20 @@ enum ruby_method_ids {
idAREF = RUBY_TOKEN(AREF),
idASET = RUBY_TOKEN(ASET),
tPRESERVED_ID_BEGIN = <%=op_id_offset + token_op_ids.size - 1%>,
-% preserved_ids.each do |token|
+% ids[:preserved].each do |token|
id<%=token%>,
% end
tPRESERVED_ID_END,
-% attr_ids.each do |token|
+% ids.values_at(*types).flatten.each do |token|
t<%=token%>,
% end
-#define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
-% attr_ids.each do |token|
- TOKEN2ID(<%=token%>),
+% types.each do |type|
+% types = ids[type] or next
+% types.empty? and next
+#define TOKEN2<%=type%>ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_<%=type%>)
+% types.each do |token|
+ TOKEN2<%=type%>ID(<%=token%>),
+% end
% end
tLAST_OP_ID = tPRESERVED_ID_END-1,
idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT