summaryrefslogtreecommitdiff
path: root/tool/transcode-tblgen.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-01 17:06:07 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-01 17:06:07 +0000
commit6c835ee50ae152daf75d4bd3a63570b7480b1c89 (patch)
treef3b02be605544c0d9fc7e576812facd7af701ef7 /tool/transcode-tblgen.rb
parent4bec0938a1072f850b8026fd49a733814a5f63cc (diff)
* 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
Diffstat (limited to 'tool/transcode-tblgen.rb')
-rw-r--r--tool/transcode-tblgen.rb44
1 files changed, 28 insertions, 16 deletions
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb
index cdeb27f..4702600 100644
--- a/tool/transcode-tblgen.rb
+++ b/tool/transcode-tblgen.rb
@@ -2,6 +2,8 @@ require 'optparse'
require 'erb'
require 'fileutils'
+NUM_ELEM_BYTELOOKUP = 2
+
C_ESC = {
"\\" => "\\\\",
'"' => '\"',
@@ -284,7 +286,7 @@ class ActionMap
infos = infos.map {|info| generate_info(info) }
maxlen = infos.map {|info| info.length }.max
columns = maxlen <= 16 ? 4 : 2
- code = "{\n"
+ code = ""
0.step(infos.length-1, columns) {|i|
code << " "
is = infos[i,columns]
@@ -293,7 +295,6 @@ class ActionMap
}
code << "\n"
}
- code << "}"
code
end
@@ -341,29 +342,40 @@ End
bytes_code.sub!(/\[\d+\]/) { "[#{size}]" }
end
+ if words_code.empty?
+ words_code << <<"End"
+static const uintptr_t
+word_array[0] = {
+};
+End
+ end
+
if n = InfosMemo[infos]
infos_name = n
- infos_code = ''
else
infos_name = "#{name}_infos"
- infos_code = <<"End"
-static const uintptr_t
-#{infos_name}[#{infos.length}] = #{format_infos(infos)};
-\#define #{infos_name} ((uintptr_t)#{infos_name})
-End
InfosMemo[infos] = infos_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
- r = infos_code + <<"End"
-static const BYTE_LOOKUP
-#{name} = {
+ 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}
-};
-\#define #{name} ((uintptr_t)#{name})
-
+ #{infos_name},
End
- words_code << r
+ }
+ size += NUM_ELEM_BYTELOOKUP
+ words_code.sub!(/\[\d+\]/) { "[#{size}]" }
end
PreMemo = {}