2 /* DO NOT EDIT THIS FILE DIRECTLY */
3 /**********************************************************************
8 created at: Sun Oct 19 21:12:51 2008
10 Copyright (C) 2007 Koichi Sasada
12 **********************************************************************/
16 defs = File.join(File.dirname(File.dirname(erb.filename)), "defs/id.def")
17 ids = eval(File.read(defs), binding, defs)
18 types = ids.keys.grep(/^[A-Z]/)
24 RUBY_ID_STATIC_SYM = 0x01,
26 RUBY_ID_INSTANCE = (0x01<<1),
27 RUBY_ID_GLOBAL = (0x03<<1),
28 RUBY_ID_ATTRSET = (0x04<<1),
29 RUBY_ID_CONST = (0x05<<1),
30 RUBY_ID_CLASS = (0x06<<1),
31 RUBY_ID_JUNK = (0x07<<1),
32 RUBY_ID_INTERNAL = RUBY_ID_JUNK,
33 RUBY_ID_SCOPE_SHIFT = 4,
34 RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
37 #define ID_STATIC_SYM RUBY_ID_STATIC_SYM
38 #define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
39 #define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
40 #define ID_LOCAL RUBY_ID_LOCAL
41 #define ID_INSTANCE RUBY_ID_INSTANCE
42 #define ID_GLOBAL RUBY_ID_GLOBAL
43 #define ID_ATTRSET RUBY_ID_ATTRSET
44 #define ID_CONST RUBY_ID_CONST
45 #define ID_CLASS RUBY_ID_CLASS
46 #define ID_JUNK RUBY_ID_JUNK
47 #define ID_INTERNAL RUBY_ID_INTERNAL
49 #define symIFUNC ID2SYM(idIFUNC)
50 #define symCFUNC ID2SYM(idCFUNC)
52 % index = op_id_offset
53 % ids[:token_op].each do |_id, _op, token|
55 #define RUBY_TOKEN_<%=token%> <%=index%>
58 #define RUBY_TOKEN(t) RUBY_TOKEN_##t
60 #define RUBY_TOKEN2ID_TYPE(tok, type) ((tok<<RUBY_ID_SCOPE_SHIFT)|type|RUBY_ID_STATIC_SYM)
61 % types.each do |type|
62 #define TOKEN2<%=type%>ID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_<%=type%>)
65 enum ruby_method_ids {
66 % ids[:token_op].uniq {|_, op| op}.each do |id, op, token|
67 id<%=id%> = <%=token ? "RUBY_TOKEN(#{token})" : "'#{op}'"%>,
69 tPRESERVED_ID_BEGIN = <%=index-1%>,
70 % ids[:preserved].each do |token|
74 % prev = 'tPRESERVED_ID_END'
75 % types.each do |type|
77 tTOKEN_<%=type%>_BEGIN = <%=prev%>-1,
78 % tokens.each do |token|
81 % prev = "tTOKEN_#{type}_END"
85 % types.each do |type|
87 #define DEFINE_<%=type%>ID_FROM_TOKEN(n) id##n = TOKEN2<%=type%>ID(t##n)
89 % tokens.each do |token|
90 DEFINE_<%=type%>ID_FROM_TOKEN(<%=token%>),
93 tLAST_OP_ID = tPRESERVED_ID_END-1,
94 idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
97 #endif /* RUBY_ID_H */