furnace 0.3.1 → 0.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +4 -0
  3. data/Gemfile +1 -2
  4. data/{LICENSE → LICENSE.MIT} +14 -14
  5. data/Rakefile +1 -5
  6. data/furnace.gemspec +7 -3
  7. data/lib/furnace/ast/node.rb +14 -0
  8. data/lib/furnace/ast/processor.rb +7 -7
  9. data/lib/furnace/ssa/argument.rb +23 -0
  10. data/lib/furnace/ssa/basic_block.rb +117 -0
  11. data/lib/furnace/ssa/builder.rb +100 -0
  12. data/lib/furnace/ssa/constant.rb +43 -0
  13. data/lib/furnace/ssa/function.rb +191 -0
  14. data/lib/furnace/ssa/generic_instruction.rb +14 -0
  15. data/lib/furnace/ssa/generic_type.rb +16 -0
  16. data/lib/furnace/ssa/instruction.rb +92 -0
  17. data/lib/furnace/ssa/instruction_syntax.rb +109 -0
  18. data/lib/furnace/ssa/instructions/branch.rb +11 -0
  19. data/lib/furnace/ssa/instructions/phi.rb +63 -0
  20. data/lib/furnace/ssa/instructions/return.rb +11 -0
  21. data/lib/furnace/ssa/module.rb +52 -0
  22. data/lib/furnace/ssa/named_value.rb +25 -0
  23. data/lib/furnace/ssa/pretty_printer.rb +113 -0
  24. data/lib/furnace/ssa/terminator_instruction.rb +24 -0
  25. data/lib/furnace/ssa/type.rb +27 -0
  26. data/lib/furnace/ssa/types/basic_block.rb +11 -0
  27. data/lib/furnace/ssa/types/function.rb +11 -0
  28. data/lib/furnace/ssa/types/void.rb +15 -0
  29. data/lib/furnace/ssa/user.rb +84 -0
  30. data/lib/furnace/ssa/value.rb +62 -0
  31. data/lib/furnace/ssa.rb +66 -0
  32. data/lib/furnace/transform/iterative.rb +27 -0
  33. data/lib/furnace/transform/pipeline.rb +3 -3
  34. data/lib/furnace/version.rb +1 -1
  35. data/lib/furnace.rb +3 -3
  36. data/test/ast_test.rb +32 -3
  37. data/test/ssa_test.rb +1129 -0
  38. data/test/test_helper.rb +17 -28
  39. data/test/transform_test.rb +74 -0
  40. metadata +136 -58
  41. data/lib/furnace/cfg/algorithms.rb +0 -193
  42. data/lib/furnace/cfg/graph.rb +0 -99
  43. data/lib/furnace/cfg/node.rb +0 -78
  44. data/lib/furnace/cfg.rb +0 -7
  45. data/lib/furnace/transform/iterative_process.rb +0 -26
@@ -1,78 +0,0 @@
1
- module Furnace::CFG
2
- class Node
3
- attr_reader :cfg, :label
4
-
5
- attr_accessor :target_labels, :exception_label
6
- attr_accessor :instructions, :control_transfer_instruction
7
-
8
- attr_accessor :metadata
9
-
10
- alias :insns :instructions
11
- alias :insns= :instructions=
12
- alias :cti :control_transfer_instruction
13
- alias :cti= :control_transfer_instruction=
14
-
15
- def initialize(cfg, label=nil, insns=[], cti=nil,
16
- target_labels=[], exception_label=nil,
17
- metadata={})
18
- @cfg, @label = cfg, label
19
- @metadata = metadata
20
-
21
- @instructions = insns
22
- @control_transfer_instruction = cti
23
-
24
- @target_labels = target_labels
25
- @exception_label = exception_label
26
- end
27
-
28
- def target_labels
29
- @target_labels
30
- end
31
-
32
- def targets
33
- @target_labels.map do |label|
34
- @cfg.find_node label
35
- end.freeze
36
- end
37
-
38
- def source_labels
39
- sources.map &:label
40
- end
41
-
42
- def sources
43
- @cfg.sources_for(self)
44
- end
45
-
46
- def exception
47
- @cfg.find_node @exception_label if @exception_label
48
- end
49
-
50
- def exception_source_labels
51
- exception_sources.map &:label
52
- end
53
-
54
- def exception_sources
55
- @cfg.sources_for(self, true)
56
- end
57
-
58
- def exits?
59
- targets == [@cfg.exit]
60
- end
61
-
62
- def ==(other)
63
- other.is_a?(Node) && self.label == other.label
64
- end
65
-
66
- def inspect
67
- if @label && @instructions
68
- "<#{@label}:#{@instructions.join ", "}>"
69
- elsif @label
70
- "<#{@label}>"
71
- elsif @instructions
72
- "<!unlabeled:#{@instructions.join ", "}>"
73
- else
74
- "<!exit#{metadata}>"
75
- end
76
- end
77
- end
78
- end
data/lib/furnace/cfg.rb DELETED
@@ -1,7 +0,0 @@
1
- require "set"
2
-
3
- module Furnace
4
- require_relative "cfg/node"
5
- require_relative "cfg/algorithms"
6
- require_relative "cfg/graph"
7
- end
@@ -1,26 +0,0 @@
1
- module Furnace
2
- module Transform
3
- class IterativeProcess
4
- def initialize(stages)
5
- @stages = stages
6
- end
7
-
8
- def transform(*sequence)
9
- loop do
10
- changed = false
11
-
12
- @stages.each do |stage|
13
- return sequence if stage.nil?
14
-
15
- if new_sequence = stage.transform(*sequence)
16
- changed = true
17
- sequence = new_sequence
18
- end
19
- end
20
-
21
- return sequence unless changed
22
- end
23
- end
24
- end
25
- end
26
- end