* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / tool / asm_parse.rb
blobf3d7f73c993e22aefcbaa24c7896dc0ab32ded07
1 stat = {}
3 while line = ARGF.gets
4   if /\[start\] (\w+)/ =~ line
5     name = $1
6     puts '--------------------------------------------------------------'
7     puts line
8     size = 0
9     len  = 0
10     
11     while line = ARGF.gets
12       if /\[start\] (\w+)/ =~ line
13         puts "\t; # length: #{len}, size: #{size}"
14         puts "\t; # !!"
15         stat[name] = [len, size]
16         #
17         name = $1
18         puts '--------------------------------------------------------------'
19         puts line
20         size = 0
21         len  = 0
22         next
23       end
25       unless /(\ALM)|(\ALB)|(\A\.)|(\A\/)/ =~ line
26         puts line
27         if /\[length = (\d+)\]/ =~ line
28           len  += $1.to_i
29           size += 1
30         end
31       end
32       
33       
34       if /__NEXT_INSN__/ !~ line && /\[end  \] (\w+)/ =~ line
35         ename = $1
36         if name != ename
37           puts "!! start with #{name}, but end with #{ename}"
38         end
39         stat[ename] = [len, size]
40         puts "\t; # length: #{len}, size: #{size}"
41         break
42       end
43     end
44   end
45 end
47 stat.sort_by{|a, b| -b[0] * 1000 - a[0]}.each{|a, b|
48   puts "#{a}\t#{b.join("\t")}"
50 puts "total length :\t#{stat.inject(0){|r, e| r+e[1][0]}}"
51 puts "total size   :\t#{stat.inject(0){|r, e| r+e[1][1]}}"