summaryrefslogtreecommitdiff
path: root/tool/transcode-tblgen.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-01 13:21:06 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-01 13:21:06 +0000
commit339dfc32a7854104729f8a334b64d272550781f9 (patch)
tree76587803dd5b9e267a81df36e62f50df2098bf2c /tool/transcode-tblgen.rb
parent03ec9b1aac4281490de9912a93892e30af5a8158 (diff)
* tool/transcode-tblgen.rb: make offsets arrays into single array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/transcode-tblgen.rb')
-rw-r--r--tool/transcode-tblgen.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb
index ecacd93..507b56f 100644
--- a/tool/transcode-tblgen.rb
+++ b/tool/transcode-tblgen.rb
@@ -236,7 +236,7 @@ class ActionMap
def format_offsets(min, max, offsets)
offsets = offsets[min..max]
- code = "{ %d, %d,\n" % [min, max]
+ code = "%d, %d,\n" % [min, max]
0.step(offsets.length-1,16) {|i|
code << " "
code << offsets[i,8].map {|off| "%3d," % off.to_s }.join('')
@@ -246,7 +246,6 @@ class ActionMap
end
code << "\n"
}
- code << '}'
code
end
@@ -322,15 +321,24 @@ class ActionMap
offsets_key = [min, max, offsets[min..max]]
if n = OffsetsMemo[offsets_key]
offsets_name = n
- offsets_code = ''
else
offsets_name = "#{name}_offsets"
- offsets_code = <<"End"
+ OffsetsMemo[offsets_key] = offsets_name
+ if bytes_code.empty?
+ bytes_code << <<"End"
static const unsigned char
-#{offsets_name}[#{2+max-min+1}] = #{format_offsets(min,max,offsets)};
+byte_array[0] = {
+};
End
- OffsetsMemo[offsets_key] = offsets_name
- bytes_code << offsets_code
+ end
+ size = bytes_code[/\[\d+\]/][1...-1].to_i
+ bytes_code.sub!(/^(\};\n\z)/) {
+ "\#define #{offsets_name} (byte_array+#{size})\n" +
+ format_offsets(min,max,offsets) + "\n" +
+ $1
+ }
+ size += 2+max-min+1
+ bytes_code.sub!(/\[\d+\]/) { "[#{size}]" }
end
if n = InfosMemo[infos]