2008-10-19 08:12:53 -04:00
|
|
|
%# -*- c -*-
|
|
|
|
/* DO NOT EDIT THIS FILE DIRECTLY */
|
|
|
|
/**********************************************************************
|
|
|
|
|
2008-12-09 02:14:13 -05:00
|
|
|
id.h -
|
2008-10-19 08:12:53 -04:00
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Sun Oct 19 21:12:51 2008
|
|
|
|
|
|
|
|
Copyright (C) 2007 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
<%
|
|
|
|
require 'optparse'
|
|
|
|
vpath = ["."]
|
|
|
|
input = nil
|
|
|
|
opt = OptionParser.new do |o|
|
|
|
|
o.on('-v', '--vpath=DIR') {|dirs| vpath.concat dirs.split(File::PATH_SEPARATOR)}
|
|
|
|
input, = o.order!(ARGV)
|
|
|
|
end or abort opt.opt_s
|
|
|
|
|
|
|
|
tokens = nil
|
|
|
|
vpath.find do |dir|
|
|
|
|
begin
|
|
|
|
if line = File.read(File.join(dir, input))[/^\s*enum\s+yytokentype\s*\{([^{}]*)\s*\};/m, 1]
|
|
|
|
tokens = line.scan(/\b(t(?:LAST_TOKEN|U(?:PLUS|MINUS)|POW|CMP|EQQ?|[NGL]EQ|(?:AND|OR)OP|N?MATCH|DOT\d|AREF|ASET|[LR]SHFT|LAMBDA)|id\w+)\s*=\s*(\d+),?/m)
|
|
|
|
end
|
|
|
|
rescue Errno::ENOENT
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
2012-03-13 21:35:06 -04:00
|
|
|
|
|
|
|
method_ids = %w[
|
|
|
|
Intern
|
|
|
|
MethodMissing
|
|
|
|
Length
|
|
|
|
Size
|
|
|
|
Gets
|
|
|
|
Succ
|
|
|
|
Each
|
|
|
|
Lambda
|
|
|
|
Send
|
|
|
|
__send__
|
|
|
|
Initialize
|
|
|
|
UScore
|
|
|
|
]
|
2008-10-19 08:12:53 -04:00
|
|
|
%>
|
|
|
|
#ifndef RUBY_ID_H
|
|
|
|
#define RUBY_ID_H
|
|
|
|
|
|
|
|
#define ID_SCOPE_SHIFT 3
|
|
|
|
#define ID_SCOPE_MASK 0x07
|
|
|
|
#define ID_LOCAL 0x00
|
|
|
|
#define ID_INSTANCE 0x01
|
|
|
|
#define ID_GLOBAL 0x03
|
|
|
|
#define ID_ATTRSET 0x04
|
|
|
|
#define ID_CONST 0x05
|
|
|
|
#define ID_CLASS 0x06
|
|
|
|
#define ID_JUNK 0x07
|
|
|
|
#define ID_INTERNAL ID_JUNK
|
|
|
|
|
|
|
|
#ifdef USE_PARSE_H
|
|
|
|
#include "parse.h"
|
|
|
|
#endif
|
|
|
|
|
2010-12-12 06:49:32 -05:00
|
|
|
#include "vm_opts.h" /* for SUPPORT_JOKE */
|
|
|
|
|
2008-10-19 08:12:53 -04:00
|
|
|
#define symIFUNC ID2SYM(idIFUNC)
|
|
|
|
#define symCFUNC ID2SYM(idCFUNC)
|
|
|
|
|
2008-12-24 15:05:12 -05:00
|
|
|
#if !defined tLAST_TOKEN && defined YYTOKENTYPE
|
|
|
|
#define tLAST_TOKEN tLAST_TOKEN
|
|
|
|
#endif
|
|
|
|
|
2008-10-19 08:12:53 -04:00
|
|
|
enum ruby_method_ids {
|
2008-12-24 15:05:12 -05:00
|
|
|
#ifndef tLAST_TOKEN
|
2008-10-19 08:12:53 -04:00
|
|
|
% tokens.each do |token, value|
|
|
|
|
<%=token%> = <%=value%>,
|
|
|
|
% end
|
|
|
|
#endif
|
2009-05-21 09:17:54 -04:00
|
|
|
idDot2 = tDOT2,
|
|
|
|
idDot3 = tDOT3,
|
|
|
|
idUPlus = tUPLUS,
|
|
|
|
idUMinus = tUMINUS,
|
|
|
|
idPow = tPOW,
|
|
|
|
idCmp = tCMP,
|
2008-10-19 08:12:53 -04:00
|
|
|
idPLUS = '+',
|
|
|
|
idMINUS = '-',
|
|
|
|
idMULT = '*',
|
|
|
|
idDIV = '/',
|
|
|
|
idMOD = '%',
|
|
|
|
idLT = '<',
|
|
|
|
idLTLT = tLSHFT,
|
|
|
|
idLE = tLEQ,
|
|
|
|
idGT = '>',
|
|
|
|
idGE = tGEQ,
|
|
|
|
idEq = tEQ,
|
|
|
|
idEqq = tEQQ,
|
|
|
|
idNeq = tNEQ,
|
|
|
|
idNot = '!',
|
|
|
|
idBackquote = '`',
|
|
|
|
idEqTilde = tMATCH,
|
2009-05-21 09:17:54 -04:00
|
|
|
idNeqTilde = tNMATCH,
|
2008-10-19 08:12:53 -04:00
|
|
|
idAREF = tAREF,
|
|
|
|
idASET = tASET,
|
|
|
|
idLAST_TOKEN = tLAST_TOKEN >> ID_SCOPE_SHIFT,
|
2012-03-13 21:35:06 -04:00
|
|
|
% method_ids.each do |token|
|
|
|
|
t<%=token%>,
|
|
|
|
% end
|
2010-12-12 06:49:32 -05:00
|
|
|
#if SUPPORT_JOKE
|
2008-10-19 08:12:53 -04:00
|
|
|
tBitblt,
|
|
|
|
tAnswer,
|
|
|
|
#endif
|
|
|
|
tLAST_ID,
|
|
|
|
#define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
2010-12-12 06:49:32 -05:00
|
|
|
#if SUPPORT_JOKE
|
2008-10-24 08:50:35 -04:00
|
|
|
TOKEN2ID(Bitblt),
|
|
|
|
TOKEN2ID(Answer),
|
|
|
|
#endif
|
2012-03-13 21:35:06 -04:00
|
|
|
% method_ids.each do |token|
|
|
|
|
TOKEN2ID(<%=token%>),
|
|
|
|
% end
|
2010-06-20 03:17:46 -04:00
|
|
|
TOKEN2ID(LAST_ID)
|
2008-10-19 08:12:53 -04:00
|
|
|
};
|
|
|
|
|
2008-12-24 15:05:12 -05:00
|
|
|
#ifdef tLAST_TOKEN
|
2008-12-24 15:53:06 -05:00
|
|
|
struct ruby_method_ids_check {
|
2008-12-24 15:05:12 -05:00
|
|
|
#define ruby_method_id_check_for(name, value) \
|
2011-01-26 08:45:42 -05:00
|
|
|
int checking_for_##name[name == (value) ? 1 : -1]
|
2008-12-24 15:05:12 -05:00
|
|
|
% tokens.map do |token, value|
|
|
|
|
ruby_method_id_check_for(<%=token%>, <%=value%>);
|
|
|
|
% end
|
2008-12-24 15:53:06 -05:00
|
|
|
};
|
2008-12-24 15:05:12 -05:00
|
|
|
#endif
|
|
|
|
|
2008-10-19 08:12:53 -04:00
|
|
|
#endif /* RUBY_ID_H */
|