2008-10-19 16:12:53 +04:00
|
|
|
%# -*- c -*-
|
|
|
|
/* DO NOT EDIT THIS FILE DIRECTLY */
|
|
|
|
/**********************************************************************
|
|
|
|
|
2008-12-09 10:14:13 +03:00
|
|
|
id.h -
|
2008-10-19 16:12:53 +04:00
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Sun Oct 19 21:12:51 2008
|
|
|
|
|
|
|
|
Copyright (C) 2007 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
<%
|
|
|
|
require 'optparse'
|
2012-08-17 12:35:12 +04:00
|
|
|
|
2012-08-31 09:31:20 +04:00
|
|
|
op_id_offset = 128
|
2012-03-14 05:35:06 +04:00
|
|
|
|
2012-08-31 09:31:20 +04:00
|
|
|
token_op_ids = %w[
|
|
|
|
tDOT2 tDOT3 tUPLUS tUMINUS tPOW tDSTAR tCMP tLSHFT tRSHFT
|
|
|
|
tLEQ tGEQ tEQ tEQQ tNEQ tMATCH tNMATCH tAREF tASET
|
|
|
|
tCOLON2 tCOLON3
|
|
|
|
]
|
|
|
|
|
2012-12-21 11:38:07 +04:00
|
|
|
defs = File.join(File.dirname(File.dirname(erb.filename)), "defs/id.def")
|
2012-12-21 11:38:03 +04:00
|
|
|
ids = eval(File.read(defs), binding, defs)
|
|
|
|
types = ids.keys.grep(/^[A-Z]/)
|
2008-10-19 16:12:53 +04:00
|
|
|
%>
|
|
|
|
#ifndef RUBY_ID_H
|
|
|
|
#define RUBY_ID_H
|
|
|
|
|
2013-09-20 08:53:08 +04:00
|
|
|
enum ruby_id_types {
|
2014-03-26 08:57:47 +04:00
|
|
|
RUBY_ID_STATIC_SYM = 0x01,
|
2013-09-20 08:53:08 +04:00
|
|
|
RUBY_ID_LOCAL = 0x00,
|
2014-03-26 08:57:47 +04:00
|
|
|
RUBY_ID_INSTANCE = (0x01<<1),
|
|
|
|
RUBY_ID_GLOBAL = (0x03<<1),
|
|
|
|
RUBY_ID_ATTRSET = (0x04<<1),
|
|
|
|
RUBY_ID_CONST = (0x05<<1),
|
|
|
|
RUBY_ID_CLASS = (0x06<<1),
|
|
|
|
RUBY_ID_JUNK = (0x07<<1),
|
2013-09-20 08:53:08 +04:00
|
|
|
RUBY_ID_INTERNAL = RUBY_ID_JUNK,
|
2014-03-26 08:57:47 +04:00
|
|
|
RUBY_ID_SCOPE_SHIFT = 4,
|
|
|
|
RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
|
2013-09-20 08:53:08 +04:00
|
|
|
};
|
|
|
|
|
2014-03-26 08:57:47 +04:00
|
|
|
#define ID_STATIC_SYM RUBY_ID_STATIC_SYM
|
2013-09-20 08:53:08 +04:00
|
|
|
#define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
|
|
|
|
#define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
|
|
|
|
#define ID_LOCAL RUBY_ID_LOCAL
|
|
|
|
#define ID_INSTANCE RUBY_ID_INSTANCE
|
|
|
|
#define ID_GLOBAL RUBY_ID_GLOBAL
|
|
|
|
#define ID_ATTRSET RUBY_ID_ATTRSET
|
|
|
|
#define ID_CONST RUBY_ID_CONST
|
|
|
|
#define ID_CLASS RUBY_ID_CLASS
|
|
|
|
#define ID_JUNK RUBY_ID_JUNK
|
|
|
|
#define ID_INTERNAL RUBY_ID_INTERNAL
|
2008-10-19 16:12:53 +04:00
|
|
|
|
2012-12-21 11:38:11 +04:00
|
|
|
#define ID2ATTRSET(id) (((id)&~ID_SCOPE_MASK)|ID_ATTRSET)
|
|
|
|
|
2008-10-19 16:12:53 +04:00
|
|
|
#define symIFUNC ID2SYM(idIFUNC)
|
|
|
|
#define symCFUNC ID2SYM(idCFUNC)
|
|
|
|
|
2012-08-31 09:31:20 +04:00
|
|
|
% token_op_ids.each_with_index do |token, index|
|
|
|
|
#define RUBY_TOKEN_<%=token[/\At(.+)\z/, 1]%> <%=op_id_offset + index%>
|
|
|
|
% end
|
|
|
|
#define RUBY_TOKEN(t) RUBY_TOKEN_##t
|
2008-12-24 23:05:12 +03:00
|
|
|
|
2008-10-19 16:12:53 +04:00
|
|
|
enum ruby_method_ids {
|
2012-08-31 09:31:20 +04:00
|
|
|
idDot2 = RUBY_TOKEN(DOT2),
|
|
|
|
idDot3 = RUBY_TOKEN(DOT3),
|
|
|
|
idUPlus = RUBY_TOKEN(UPLUS),
|
|
|
|
idUMinus = RUBY_TOKEN(UMINUS),
|
|
|
|
idPow = RUBY_TOKEN(POW),
|
|
|
|
idCmp = RUBY_TOKEN(CMP),
|
2008-10-19 16:12:53 +04:00
|
|
|
idPLUS = '+',
|
|
|
|
idMINUS = '-',
|
|
|
|
idMULT = '*',
|
|
|
|
idDIV = '/',
|
|
|
|
idMOD = '%',
|
|
|
|
idLT = '<',
|
2012-08-31 09:31:20 +04:00
|
|
|
idLTLT = RUBY_TOKEN(LSHFT),
|
|
|
|
idLE = RUBY_TOKEN(LEQ),
|
2008-10-19 16:12:53 +04:00
|
|
|
idGT = '>',
|
parse.y: optimize IDs in ripper
* parse.y: optimize ripper_intern calls, ::, **, -@, +@, <=>, >=,
<=, ==, ===, !=, =~, !~, <<, >>, and call.
* parse.y: use initialized IDs, warn and warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27 09:23:09 +03:00
|
|
|
idGTGT = RUBY_TOKEN(RSHFT),
|
2012-08-31 09:31:20 +04:00
|
|
|
idGE = RUBY_TOKEN(GEQ),
|
|
|
|
idEq = RUBY_TOKEN(EQ),
|
|
|
|
idEqq = RUBY_TOKEN(EQQ),
|
|
|
|
idNeq = RUBY_TOKEN(NEQ),
|
2008-10-19 16:12:53 +04:00
|
|
|
idNot = '!',
|
|
|
|
idBackquote = '`',
|
2012-08-31 09:31:20 +04:00
|
|
|
idEqTilde = RUBY_TOKEN(MATCH),
|
|
|
|
idNeqTilde = RUBY_TOKEN(NMATCH),
|
|
|
|
idAREF = RUBY_TOKEN(AREF),
|
|
|
|
idASET = RUBY_TOKEN(ASET),
|
parse.y: optimize IDs in ripper
* parse.y: optimize ripper_intern calls, ::, **, -@, +@, <=>, >=,
<=, ==, ===, !=, =~, !~, <<, >>, and call.
* parse.y: use initialized IDs, warn and warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27 09:23:09 +03:00
|
|
|
idCOLON2 = RUBY_TOKEN(COLON2),
|
2012-08-31 09:31:20 +04:00
|
|
|
tPRESERVED_ID_BEGIN = <%=op_id_offset + token_op_ids.size - 1%>,
|
2012-12-21 11:38:03 +04:00
|
|
|
% ids[:preserved].each do |token|
|
2012-08-17 12:35:12 +04:00
|
|
|
id<%=token%>,
|
|
|
|
% end
|
|
|
|
tPRESERVED_ID_END,
|
2012-12-21 11:38:03 +04:00
|
|
|
% ids.values_at(*types).flatten.each do |token|
|
2012-03-14 05:35:06 +04:00
|
|
|
t<%=token%>,
|
|
|
|
% end
|
2014-07-11 18:10:50 +04:00
|
|
|
tNEXT_ID,
|
2012-12-21 11:38:03 +04:00
|
|
|
% types.each do |type|
|
|
|
|
% types = ids[type] or next
|
|
|
|
% types.empty? and next
|
2014-03-26 08:57:47 +04:00
|
|
|
#define TOKEN2<%=type%>ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_<%=type%>|ID_STATIC_SYM)
|
2012-12-21 11:38:03 +04:00
|
|
|
% types.each do |token|
|
|
|
|
TOKEN2<%=type%>ID(<%=token%>),
|
|
|
|
% end
|
2012-03-14 05:35:06 +04:00
|
|
|
% end
|
2012-08-31 09:31:20 +04:00
|
|
|
tLAST_OP_ID = tPRESERVED_ID_END-1,
|
|
|
|
idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
|
2008-12-24 23:53:06 +03:00
|
|
|
};
|
2008-12-24 23:05:12 +03:00
|
|
|
|
2008-10-19 16:12:53 +04:00
|
|
|
#endif /* RUBY_ID_H */
|