summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rw-r--r--tool/transcode-tblgen.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb
index 2eb4a01565..64d184c512 100644
--- a/tool/transcode-tblgen.rb
+++ b/tool/transcode-tblgen.rb
@@ -157,27 +157,28 @@ end
class ArrayCode
def initialize(type, name)
- @code = <<"End"
-static const #{type}
-#{name}[0] = {
-};
-End
+ @type = type
+ @name = name
+ @len = 0;
+ @content = ''
end
def length
- @code[/\[\d+\]/][1...-1].to_i
+ @len
end
def insert_at_last(num, str)
newnum = self.length + num
- @code.sub!(/^(\};\n\z)/) {
- str + $1
- }
- @code.sub!(/\[\d+\]/) { "[#{newnum}]" }
+ @content << str
+ @len += num
end
def to_s
- @code.dup
+ <<"End"
+static const #{@type}
+#{@name}[#{@len}] = {
+#{@content}};
+End
end
end