mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* common.mk (srcs): removed ID_H_TARGET.
* tool/generic_erb.rb: always overwrites if no if-change option. * template/id.h.tmpl: shows which token differs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b014f1bc02
commit
de85d6e92e
5 changed files with 196 additions and 41 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Sun Oct 19 21:12:51 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* common.mk (srcs): removed ID_H_TARGET.
|
||||||
|
|
||||||
|
* tool/generic_erb.rb: always overwrites if no if-change option.
|
||||||
|
|
||||||
|
* template/id.h.tmpl: shows which token differs.
|
||||||
|
|
||||||
Sun Oct 19 18:15:15 2008 Martin Duerst <duerst@it.aoyama.ac.jp>
|
Sun Oct 19 18:15:15 2008 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* enc/trans/single_byte.trans: adding WINDOWS-wwww encodings
|
* enc/trans/single_byte.trans: adding WINDOWS-wwww encodings
|
||||||
|
|
|
@ -625,7 +625,7 @@ vmtc.inc: $(srcdir)/template/vmtc.inc.tmpl
|
||||||
|
|
||||||
vm.inc: $(srcdir)/template/vm.inc.tmpl
|
vm.inc: $(srcdir)/template/vm.inc.tmpl
|
||||||
|
|
||||||
srcs: {$(VPATH)}parse.c $(ID_H_TARGET) {$(VPATH)}lex.c {$(VPATH)}newline.c $(srcdir)/ext/ripper/ripper.c srcs-enc
|
srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c {$(VPATH)}newline.c $(srcdir)/ext/ripper/ripper.c srcs-enc
|
||||||
|
|
||||||
srcs-enc: $(ENC_MK)
|
srcs-enc: $(ENC_MK)
|
||||||
$(MAKE) -f $(ENC_MK) RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(MFLAGS) srcs
|
$(MAKE) -f $(ENC_MK) RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(MFLAGS) srcs
|
||||||
|
|
98
id.h
98
id.h
|
@ -1,3 +1,4 @@
|
||||||
|
/* DO NOT EDIT THIS FILE DIRECTLY */
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
||||||
id.h -
|
id.h -
|
||||||
|
@ -64,39 +65,70 @@ enum ruby_method_ids {
|
||||||
id_core_define_singleton_method = 374,
|
id_core_define_singleton_method = 374,
|
||||||
id_core_set_postexe = 375,
|
id_core_set_postexe = 375,
|
||||||
tLAST_TOKEN = 376,
|
tLAST_TOKEN = 376,
|
||||||
#elif tUPLUS != 321 || \
|
#elif tUPLUS != 321
|
||||||
tUMINUS != 322 || \
|
#error tUPLUS differs
|
||||||
tPOW != 323 || \
|
#elif tUMINUS != 322
|
||||||
tCMP != 324 || \
|
#error tUMINUS differs
|
||||||
tEQ != 325 || \
|
#elif tPOW != 323
|
||||||
tEQQ != 326 || \
|
#error tPOW differs
|
||||||
tNEQ != 327 || \
|
#elif tCMP != 324
|
||||||
tGEQ != 328 || \
|
#error tCMP differs
|
||||||
tLEQ != 329 || \
|
#elif tEQ != 325
|
||||||
tANDOP != 330 || \
|
#error tEQ differs
|
||||||
tOROP != 331 || \
|
#elif tEQQ != 326
|
||||||
tMATCH != 332 || \
|
#error tEQQ differs
|
||||||
tNMATCH != 333 || \
|
#elif tNEQ != 327
|
||||||
tDOT2 != 334 || \
|
#error tNEQ differs
|
||||||
tDOT3 != 335 || \
|
#elif tGEQ != 328
|
||||||
tAREF != 336 || \
|
#error tGEQ differs
|
||||||
tASET != 337 || \
|
#elif tLEQ != 329
|
||||||
tLSHFT != 338 || \
|
#error tLEQ differs
|
||||||
tRSHFT != 339 || \
|
#elif tANDOP != 330
|
||||||
tLAMBDA != 352 || \
|
#error tANDOP differs
|
||||||
idNULL != 365 || \
|
#elif tOROP != 331
|
||||||
idRespond_to != 366 || \
|
#error tOROP differs
|
||||||
idIFUNC != 367 || \
|
#elif tMATCH != 332
|
||||||
idCFUNC != 368 || \
|
#error tMATCH differs
|
||||||
idThrowState != 369 || \
|
#elif tNMATCH != 333
|
||||||
id_core_set_method_alias != 370 || \
|
#error tNMATCH differs
|
||||||
id_core_set_variable_alias != 371 || \
|
#elif tDOT2 != 334
|
||||||
id_core_undef_method != 372 || \
|
#error tDOT2 differs
|
||||||
id_core_define_method != 373 || \
|
#elif tDOT3 != 335
|
||||||
id_core_define_singleton_method != 374 || \
|
#error tDOT3 differs
|
||||||
id_core_set_postexe != 375 || \
|
#elif tAREF != 336
|
||||||
tLAST_TOKEN != 376
|
#error tAREF differs
|
||||||
#error id.h is out of date.
|
#elif tASET != 337
|
||||||
|
#error tASET differs
|
||||||
|
#elif tLSHFT != 338
|
||||||
|
#error tLSHFT differs
|
||||||
|
#elif tRSHFT != 339
|
||||||
|
#error tRSHFT differs
|
||||||
|
#elif tLAMBDA != 352
|
||||||
|
#error tLAMBDA differs
|
||||||
|
#elif idNULL != 365
|
||||||
|
#error idNULL differs
|
||||||
|
#elif idRespond_to != 366
|
||||||
|
#error idRespond_to differs
|
||||||
|
#elif idIFUNC != 367
|
||||||
|
#error idIFUNC differs
|
||||||
|
#elif idCFUNC != 368
|
||||||
|
#error idCFUNC differs
|
||||||
|
#elif idThrowState != 369
|
||||||
|
#error idThrowState differs
|
||||||
|
#elif id_core_set_method_alias != 370
|
||||||
|
#error id_core_set_method_alias differs
|
||||||
|
#elif id_core_set_variable_alias != 371
|
||||||
|
#error id_core_set_variable_alias differs
|
||||||
|
#elif id_core_undef_method != 372
|
||||||
|
#error id_core_undef_method differs
|
||||||
|
#elif id_core_define_method != 373
|
||||||
|
#error id_core_define_method differs
|
||||||
|
#elif id_core_define_singleton_method != 374
|
||||||
|
#error id_core_define_singleton_method differs
|
||||||
|
#elif id_core_set_postexe != 375
|
||||||
|
#error id_core_set_postexe differs
|
||||||
|
#elif tLAST_TOKEN != 376
|
||||||
|
#error tLAST_TOKEN differs
|
||||||
#endif
|
#endif
|
||||||
idPLUS = '+',
|
idPLUS = '+',
|
||||||
idMINUS = '-',
|
idMINUS = '-',
|
||||||
|
|
117
template/id.h.tmpl
Normal file
117
template/id.h.tmpl
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
%# -*- c -*-
|
||||||
|
/* DO NOT EDIT THIS FILE DIRECTLY */
|
||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
id.h -
|
||||||
|
|
||||||
|
$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
|
||||||
|
%>
|
||||||
|
#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
|
||||||
|
|
||||||
|
#define symIFUNC ID2SYM(idIFUNC)
|
||||||
|
#define symCFUNC ID2SYM(idCFUNC)
|
||||||
|
|
||||||
|
enum ruby_method_ids {
|
||||||
|
#ifndef tLAST_TOKEN
|
||||||
|
% tokens.each do |token, value|
|
||||||
|
<%=token%> = <%=value%>,
|
||||||
|
% end
|
||||||
|
% tokens.map do |token, value|
|
||||||
|
#elif <%=token%> != <%=value%>
|
||||||
|
#error <%=token%> differs
|
||||||
|
% end
|
||||||
|
#endif
|
||||||
|
idPLUS = '+',
|
||||||
|
idMINUS = '-',
|
||||||
|
idMULT = '*',
|
||||||
|
idDIV = '/',
|
||||||
|
idMOD = '%',
|
||||||
|
idLT = '<',
|
||||||
|
idLTLT = tLSHFT,
|
||||||
|
idLE = tLEQ,
|
||||||
|
idGT = '>',
|
||||||
|
idGE = tGEQ,
|
||||||
|
idEq = tEQ,
|
||||||
|
idEqq = tEQQ,
|
||||||
|
idNeq = tNEQ,
|
||||||
|
idNot = '!',
|
||||||
|
idBackquote = '`',
|
||||||
|
idEqTilde = tMATCH,
|
||||||
|
idAREF = tAREF,
|
||||||
|
idASET = tASET,
|
||||||
|
idLAST_TOKEN = tLAST_TOKEN >> ID_SCOPE_SHIFT,
|
||||||
|
tIntern,
|
||||||
|
tMethodMissing,
|
||||||
|
tLength,
|
||||||
|
tGets,
|
||||||
|
tSucc,
|
||||||
|
tEach,
|
||||||
|
tLambda,
|
||||||
|
tSend,
|
||||||
|
t__send__,
|
||||||
|
tInitialize,
|
||||||
|
#if SUPPORT_JOKE
|
||||||
|
tBitblt,
|
||||||
|
tAnswer,
|
||||||
|
#endif
|
||||||
|
tLAST_ID,
|
||||||
|
#define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
||||||
|
TOKEN2ID(Intern),
|
||||||
|
TOKEN2ID(MethodMissing),
|
||||||
|
TOKEN2ID(Length),
|
||||||
|
TOKEN2ID(Gets),
|
||||||
|
TOKEN2ID(Succ),
|
||||||
|
TOKEN2ID(Each),
|
||||||
|
TOKEN2ID(Lambda),
|
||||||
|
TOKEN2ID(Send),
|
||||||
|
TOKEN2ID(__send__),
|
||||||
|
TOKEN2ID(Initialize),
|
||||||
|
#if SUPPORT_JOKE
|
||||||
|
TOKEN2ID(Bitblt),
|
||||||
|
TOKEN2ID(Answer),
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* RUBY_ID_H */
|
|
@ -16,14 +16,12 @@ erb = ERB.new(File.read(template), nil, '%')
|
||||||
erb.filename = template
|
erb.filename = template
|
||||||
result = erb.result
|
result = erb.result
|
||||||
if output
|
if output
|
||||||
if ifchange
|
if ifchange and (IO.read(output) rescue nil) == result
|
||||||
if (IO.read(output) rescue nil) == result
|
|
||||||
puts "#{output} unchanged"
|
puts "#{output} unchanged"
|
||||||
else
|
else
|
||||||
open(output, "wb") {|f| f.print result}
|
open(output, "wb") {|f| f.print result}
|
||||||
puts "#{output} updated"
|
puts "#{output} updated"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if timestamp
|
if timestamp
|
||||||
if timestamp == true
|
if timestamp == true
|
||||||
dir, base = File.split(output)
|
dir, base = File.split(output)
|
||||||
|
|
Loading…
Reference in a new issue