ruby-changes:7521
From: akr <ko1@a...>
Date: Tue, 2 Sep 2008 02:06:44 +0900 (JST)
Subject: [ruby-changes:7521] Ruby:r19042 (trunk): * tool/transcode-tblgen.rb: make infos arrays and BYTE_LOOKUPs into
akr 2008-09-02 02:06:07 +0900 (Tue, 02 Sep 2008) New Revision: 19042 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19042 Log: * tool/transcode-tblgen.rb: make infos arrays and BYTE_LOOKUPs into single array. Modified files: trunk/ChangeLog trunk/tool/transcode-tblgen.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19041) +++ ChangeLog (revision 19042) @@ -1,3 +1,8 @@ +Tue Sep 2 02:05:14 2008 Tanaka Akira <akr@f...> + + * tool/transcode-tblgen.rb: make infos arrays and BYTE_LOOKUPs into + single array. + Tue Sep 2 01:47:44 2008 Yuki Sonoda (Yugui) <yugui@y...> * common.mk (clean-golf): added. Index: tool/transcode-tblgen.rb =================================================================== --- tool/transcode-tblgen.rb (revision 19041) +++ tool/transcode-tblgen.rb (revision 19042) @@ -2,6 +2,8 @@ require 'erb' require 'fileutils' +NUM_ELEM_BYTELOOKUP = 2 + C_ESC = { "\\" => "\\\\", '"' => '\"', @@ -284,7 +286,7 @@ 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 @@ } code << "\n" } - code << "}" code end @@ -341,29 +342,40 @@ 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 = {} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/