* tool/transcode-tblgen.rb (ArrayCode): less string substitutions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
933eb07996
commit
1625494feb
@ -1,3 +1,7 @@
|
|||||||
|
Mon Sep 8 18:15:59 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* tool/transcode-tblgen.rb (ArrayCode): less string substitutions.
|
||||||
|
|
||||||
Mon Sep 8 18:13:13 2008 Tanaka Akira <akr@fsij.org>
|
Mon Sep 8 18:13:13 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* vm.c (rb_mRubyVMFrozenCore): registered for GC.
|
* vm.c (rb_mRubyVMFrozenCore): registered for GC.
|
||||||
|
@ -157,27 +157,28 @@ end
|
|||||||
|
|
||||||
class ArrayCode
|
class ArrayCode
|
||||||
def initialize(type, name)
|
def initialize(type, name)
|
||||||
@code = <<"End"
|
@type = type
|
||||||
static const #{type}
|
@name = name
|
||||||
#{name}[0] = {
|
@len = 0;
|
||||||
};
|
@content = ''
|
||||||
End
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def length
|
def length
|
||||||
@code[/\[\d+\]/][1...-1].to_i
|
@len
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_at_last(num, str)
|
def insert_at_last(num, str)
|
||||||
newnum = self.length + num
|
newnum = self.length + num
|
||||||
@code.sub!(/^(\};\n\z)/) {
|
@content << str
|
||||||
str + $1
|
@len += num
|
||||||
}
|
|
||||||
@code.sub!(/\[\d+\]/) { "[#{newnum}]" }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
@code.dup
|
<<"End"
|
||||||
|
static const #{@type}
|
||||||
|
#{@name}[#{@len}] = {
|
||||||
|
#{@content}};
|
||||||
|
End
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user