furnace 0.4.0.beta.1 → 0.4.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +6 -0
- data/INSTRUMENT.md +250 -0
- data/Rakefile +1 -1
- data/lib/furnace.rb +10 -6
- data/lib/furnace/ast/node.rb +15 -1
- data/lib/furnace/awesome_printer.rb +121 -0
- data/lib/furnace/context.rb +0 -0
- data/lib/furnace/ssa.rb +7 -25
- data/lib/furnace/ssa/argument.rb +14 -10
- data/lib/furnace/ssa/basic_block.rb +70 -25
- data/lib/furnace/ssa/builder.rb +11 -7
- data/lib/furnace/ssa/constant.rb +19 -11
- data/lib/furnace/ssa/event_stream.rb +145 -0
- data/lib/furnace/ssa/function.rb +78 -57
- data/lib/furnace/ssa/generic_instruction.rb +12 -5
- data/lib/furnace/ssa/instruction.rb +50 -35
- data/lib/furnace/ssa/instruction_syntax.rb +9 -25
- data/lib/furnace/ssa/instructions/branch.rb +2 -2
- data/lib/furnace/ssa/instructions/phi.rb +12 -10
- data/lib/furnace/ssa/instructions/return.rb +3 -3
- data/lib/furnace/ssa/instructions/return_value.rb +11 -0
- data/lib/furnace/ssa/instrumentation.rb +33 -0
- data/lib/furnace/ssa/module.rb +5 -1
- data/lib/furnace/ssa/named_value.rb +31 -10
- data/lib/furnace/ssa/terminator_instruction.rb +6 -6
- data/lib/furnace/ssa/types/basic_block.rb +4 -8
- data/lib/furnace/ssa/types/function.rb +4 -8
- data/lib/furnace/ssa/user.rb +14 -15
- data/lib/furnace/ssa/value.rb +9 -5
- data/lib/furnace/transform/iterative.rb +20 -4
- data/lib/furnace/type.rb +9 -0
- data/lib/furnace/type/bottom.rb +11 -0
- data/lib/furnace/type/top.rb +72 -0
- data/lib/furnace/type/value.rb +13 -0
- data/lib/furnace/type/variable.rb +61 -0
- data/lib/furnace/version.rb +1 -1
- data/test/{test_helper.rb → helper.rb} +28 -3
- data/test/{ast_test.rb → test_ast.rb} +13 -1
- data/test/test_awesome_printer.rb +148 -0
- data/test/{ssa_test.rb → test_ssa.rb} +276 -315
- data/test/{transform_test.rb → test_transform.rb} +2 -2
- data/test/test_type.rb +138 -0
- metadata +83 -105
- data/lib/furnace/graphviz.rb +0 -49
- data/lib/furnace/ssa/generic_type.rb +0 -16
- data/lib/furnace/ssa/pretty_printer.rb +0 -113
- data/lib/furnace/ssa/type.rb +0 -27
- data/lib/furnace/ssa/types/void.rb +0 -15
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'ansi'
|
2
|
-
|
3
|
-
module Furnace
|
4
|
-
class SSA::PrettyPrinter
|
5
|
-
@colorize = true
|
6
|
-
|
7
|
-
class << self
|
8
|
-
attr_accessor :colorize
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(colorize=self.class.colorize)
|
12
|
-
@colorize = colorize
|
13
|
-
@buffer = ""
|
14
|
-
@need_space = false
|
15
|
-
|
16
|
-
yield self if block_given?
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_s
|
20
|
-
@buffer
|
21
|
-
end
|
22
|
-
|
23
|
-
alias to_str to_s
|
24
|
-
|
25
|
-
def ==(other)
|
26
|
-
to_s == other
|
27
|
-
end
|
28
|
-
|
29
|
-
def =~(other)
|
30
|
-
to_s =~ other
|
31
|
-
end
|
32
|
-
|
33
|
-
def <<(what)
|
34
|
-
@buffer << what
|
35
|
-
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
def text(*what)
|
40
|
-
what = what.map(&:to_s)
|
41
|
-
return if what.all?(&:empty?)
|
42
|
-
|
43
|
-
ensure_space do
|
44
|
-
self << what.join
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def newline
|
49
|
-
@need_space = false
|
50
|
-
|
51
|
-
self << "\n"
|
52
|
-
end
|
53
|
-
|
54
|
-
def name(what)
|
55
|
-
text '%', what
|
56
|
-
end
|
57
|
-
|
58
|
-
def type(what)
|
59
|
-
text with_ansi(:green) { Furnace::SSA.inspect_type(what) }
|
60
|
-
end
|
61
|
-
|
62
|
-
def keyword(what)
|
63
|
-
text with_ansi(:bright, :white) { what.to_s }
|
64
|
-
end
|
65
|
-
|
66
|
-
def keyword_invalid(what)
|
67
|
-
if @colorize
|
68
|
-
text with_ansi(:bright, :red) { what.to_s }
|
69
|
-
else
|
70
|
-
text "!#{what}".to_s
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def objects(objects, separator=",", printer=:pretty_print)
|
75
|
-
objects.each_with_index do |object, index|
|
76
|
-
object.send(printer, self)
|
77
|
-
|
78
|
-
self << separator if index < objects.count - 1
|
79
|
-
end
|
80
|
-
|
81
|
-
self
|
82
|
-
end
|
83
|
-
|
84
|
-
def values(values, separator=",")
|
85
|
-
objects(values, separator, :inspect_as_value)
|
86
|
-
end
|
87
|
-
|
88
|
-
protected
|
89
|
-
|
90
|
-
def with_ansi(*colors)
|
91
|
-
string = yield
|
92
|
-
|
93
|
-
if @colorize
|
94
|
-
ANSI::Code.ansi(yield, *colors)
|
95
|
-
else
|
96
|
-
yield
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def ensure_space(need_space_after=true)
|
101
|
-
if @need_space
|
102
|
-
self << " "
|
103
|
-
@need_space = false
|
104
|
-
end
|
105
|
-
|
106
|
-
yield
|
107
|
-
|
108
|
-
@need_space = need_space_after
|
109
|
-
|
110
|
-
self
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
data/lib/furnace/ssa/type.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Furnace
|
2
|
-
class SSA::Type
|
3
|
-
def to_type
|
4
|
-
self
|
5
|
-
end
|
6
|
-
|
7
|
-
def monotype?
|
8
|
-
true
|
9
|
-
end
|
10
|
-
|
11
|
-
def ==(other)
|
12
|
-
other.instance_of?(self.class)
|
13
|
-
end
|
14
|
-
|
15
|
-
def hash
|
16
|
-
[self.class].hash
|
17
|
-
end
|
18
|
-
|
19
|
-
def eql?(other)
|
20
|
-
self == other
|
21
|
-
end
|
22
|
-
|
23
|
-
def subtype_of?(other)
|
24
|
-
self == other
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|