mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* tool/transcode-tblgen.rb (ActionMap#generate_info): use a memo to
avoid duplication for STR1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c0bec2fae1
commit
dcdc7579c5
2 changed files with 20 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Sep 7 18:28:05 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* tool/transcode-tblgen.rb (ActionMap#generate_info): use a memo to
|
||||
avoid duplication for STR1.
|
||||
|
||||
Sun Sep 7 18:10:28 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode_data.h (STR1): defined for a string up to 255 bytes.
|
||||
|
|
|
@ -277,6 +277,8 @@ class ActionMap
|
|||
code
|
||||
end
|
||||
|
||||
StrMemo = {}
|
||||
|
||||
def generate_info(info)
|
||||
case info
|
||||
when :nomap
|
||||
|
@ -302,13 +304,19 @@ class ActionMap
|
|||
when /\A(f[0-7])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])\z/i
|
||||
"o4(0x#$1,0x#$2,0x#$3,0x#$4)"
|
||||
when /\A([0-9a-f][0-9a-f]){0,255}\z/i
|
||||
bytes = info
|
||||
len = info.length/2
|
||||
size = @bytes_code.length
|
||||
@bytes_code.insert_at_last(1 + len,
|
||||
"\#define str1_#{size} makeSTR1(#{size})\n" +
|
||||
" #{len}," + info.gsub(/../, ' 0x\&,') + "\n")
|
||||
"str1_#{size}"
|
||||
bytes = info.upcase
|
||||
if n = StrMemo[bytes]
|
||||
n
|
||||
else
|
||||
len = info.length/2
|
||||
size = @bytes_code.length
|
||||
@bytes_code.insert_at_last(1 + len,
|
||||
"\#define str1_#{size} makeSTR1(#{size})\n" +
|
||||
" #{len}," + info.gsub(/../, ' 0x\&,') + "\n")
|
||||
n = "str1_#{size}"
|
||||
StrMemo[bytes] = n
|
||||
n
|
||||
end
|
||||
when /\A\/\*BYTE_LOOKUP\*\// # pointer to BYTE_LOOKUP structure
|
||||
$'.to_s
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue