mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* tool/transcode-tblgen.rb: make infos arrays and BYTE_LOOKUPs into
single array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4bec0938a1
commit
6c835ee50a
2 changed files with 36 additions and 19 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Sep 2 02:05:14 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* tool/transcode-tblgen.rb: make infos arrays and BYTE_LOOKUPs into
|
||||||
|
single array.
|
||||||
|
|
||||||
Tue Sep 2 01:47:44 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
Tue Sep 2 01:47:44 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
* common.mk (clean-golf): added.
|
* common.mk (clean-golf): added.
|
||||||
|
|
|
@ -2,6 +2,8 @@ require 'optparse'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
|
NUM_ELEM_BYTELOOKUP = 2
|
||||||
|
|
||||||
C_ESC = {
|
C_ESC = {
|
||||||
"\\" => "\\\\",
|
"\\" => "\\\\",
|
||||||
'"' => '\"',
|
'"' => '\"',
|
||||||
|
@ -284,7 +286,7 @@ class ActionMap
|
||||||
infos = infos.map {|info| generate_info(info) }
|
infos = infos.map {|info| generate_info(info) }
|
||||||
maxlen = infos.map {|info| info.length }.max
|
maxlen = infos.map {|info| info.length }.max
|
||||||
columns = maxlen <= 16 ? 4 : 2
|
columns = maxlen <= 16 ? 4 : 2
|
||||||
code = "{\n"
|
code = ""
|
||||||
0.step(infos.length-1, columns) {|i|
|
0.step(infos.length-1, columns) {|i|
|
||||||
code << " "
|
code << " "
|
||||||
is = infos[i,columns]
|
is = infos[i,columns]
|
||||||
|
@ -293,7 +295,6 @@ class ActionMap
|
||||||
}
|
}
|
||||||
code << "\n"
|
code << "\n"
|
||||||
}
|
}
|
||||||
code << "}"
|
|
||||||
code
|
code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -341,29 +342,40 @@ End
|
||||||
bytes_code.sub!(/\[\d+\]/) { "[#{size}]" }
|
bytes_code.sub!(/\[\d+\]/) { "[#{size}]" }
|
||||||
end
|
end
|
||||||
|
|
||||||
if n = InfosMemo[infos]
|
if words_code.empty?
|
||||||
infos_name = n
|
words_code << <<"End"
|
||||||
infos_code = ''
|
|
||||||
else
|
|
||||||
infos_name = "#{name}_infos"
|
|
||||||
infos_code = <<"End"
|
|
||||||
static const uintptr_t
|
static const uintptr_t
|
||||||
#{infos_name}[#{infos.length}] = #{format_infos(infos)};
|
word_array[0] = {
|
||||||
\#define #{infos_name} ((uintptr_t)#{infos_name})
|
};
|
||||||
End
|
End
|
||||||
InfosMemo[infos] = infos_name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
r = infos_code + <<"End"
|
if n = InfosMemo[infos]
|
||||||
static const BYTE_LOOKUP
|
infos_name = n
|
||||||
#{name} = {
|
else
|
||||||
(uintptr_t)#{offsets_name},
|
infos_name = "#{name}_infos"
|
||||||
#{infos_name}
|
InfosMemo[infos] = infos_name
|
||||||
};
|
|
||||||
\#define #{name} ((uintptr_t)#{name})
|
|
||||||
|
|
||||||
|
size = words_code[/\[\d+\]/][1...-1].to_i
|
||||||
|
words_code.sub!(/^(\};\n\z)/) {
|
||||||
|
"\#define #{infos_name} (((uintptr_t)word_array)+sizeof(uintptr_t)*#{size})\n" +
|
||||||
|
format_infos(infos) + "\n" +
|
||||||
|
$1
|
||||||
|
}
|
||||||
|
size += infos.length
|
||||||
|
words_code.sub!(/\[\d+\]/) { "[#{size}]" }
|
||||||
|
end
|
||||||
|
|
||||||
|
size = words_code[/\[\d+\]/][1...-1].to_i
|
||||||
|
words_code.sub!(/^(\};\n\z)/) {
|
||||||
|
"\#define #{name} ((uintptr_t)(word_array+#{size}))\n" +
|
||||||
|
<<"End" + "\n" + $1
|
||||||
|
(uintptr_t)#{offsets_name},
|
||||||
|
#{infos_name},
|
||||||
End
|
End
|
||||||
words_code << r
|
}
|
||||||
|
size += NUM_ELEM_BYTELOOKUP
|
||||||
|
words_code.sub!(/\[\d+\]/) { "[#{size}]" }
|
||||||
end
|
end
|
||||||
|
|
||||||
PreMemo = {}
|
PreMemo = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue