Permalink
Browse files

Added json dump format.

  • Loading branch information...
1 parent f0eedce commit fb8b91218cf91e37816684644fa41ed131508f2e @whitequark committed Sep 25, 2012
Showing with 16 additions and 1 deletion.
  1. +8 −1 bin/furnace-avm2
  2. +8 −0 lib/furnace-avm2/transform/ssa_transform.rb
View
@@ -24,10 +24,11 @@ require "trollop"
require "furnace-avm2"
require "thread"
require "benchmark"
+require "json"
include Furnace
-GRAPH_FORMATS = %w(none text graphviz)
+GRAPH_FORMATS = %w(none text graphviz json)
opts = Trollop::options do
version "furnace-avm2 #{AVM2::VERSION}"
@@ -137,6 +138,10 @@ loop do
File.open("method-#{body.method_idx}.dot", "w") do |dot|
dot.write cfg.to_graphviz
end
+ elsif opts[:cfg] == 'json'
+ File.open("method-#{body.method_idx}.json", "w") do |json|
+ json.write JSON.dump(cfg.to_hash)
+ end
end
puts "Method #{body.method_idx}; dominators"
@@ -145,6 +150,7 @@ loop do
"#{dominating.map(&:label).map(&:inspect).join(", ")}"
end
puts
+
=begin
puts "Method #{body.method_idx}; postdominators"
cfg.postdominators.each do |node, dominating|
@@ -153,6 +159,7 @@ loop do
end
puts
=end
+
puts "Method #{body.method_idx}; loops"
cfg.identify_loops.each do |header, body|
puts "#{header.label.inspect} => " +
@@ -23,6 +23,14 @@ def any?
@sets.any? || @gets.any? || @live.any?
end
+ def to_hash
+ {
+ sets: @sets.to_a,
+ gets: @gets.to_a,
+ live: @live.to_a,
+ }.merge(@hash)
+ end
+
def inspect
str = "| sets: #{@sets.to_a.join(", ")} gets: #{@gets.to_a.join(", ")}\n"
str << "| live: #{@live.to_a.join(", ")}"

0 comments on commit fb8b912

Please sign in to comment.