typeprof 0.21.11 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -31
- data/bin/typeprof +5 -0
- data/doc/doc.ja.md +134 -0
- data/doc/doc.md +136 -0
- data/lib/typeprof/cli/cli.rb +180 -0
- data/lib/typeprof/cli.rb +2 -133
- data/lib/typeprof/code_range.rb +112 -0
- data/lib/typeprof/core/ast/base.rb +263 -0
- data/lib/typeprof/core/ast/call.rb +251 -0
- data/lib/typeprof/core/ast/const.rb +126 -0
- data/lib/typeprof/core/ast/control.rb +432 -0
- data/lib/typeprof/core/ast/meta.rb +150 -0
- data/lib/typeprof/core/ast/method.rb +335 -0
- data/lib/typeprof/core/ast/misc.rb +263 -0
- data/lib/typeprof/core/ast/module.rb +123 -0
- data/lib/typeprof/core/ast/pattern.rb +140 -0
- data/lib/typeprof/core/ast/sig_decl.rb +471 -0
- data/lib/typeprof/core/ast/sig_type.rb +663 -0
- data/lib/typeprof/core/ast/value.rb +319 -0
- data/lib/typeprof/core/ast/variable.rb +315 -0
- data/lib/typeprof/core/ast.rb +472 -0
- data/lib/typeprof/core/builtin.rb +146 -0
- data/lib/typeprof/core/env/method.rb +137 -0
- data/lib/typeprof/core/env/method_entity.rb +55 -0
- data/lib/typeprof/core/env/module_entity.rb +408 -0
- data/lib/typeprof/core/env/static_read.rb +155 -0
- data/lib/typeprof/core/env/type_alias_entity.rb +27 -0
- data/lib/typeprof/core/env/value_entity.rb +32 -0
- data/lib/typeprof/core/env.rb +360 -0
- data/lib/typeprof/core/graph/box.rb +991 -0
- data/lib/typeprof/core/graph/change_set.rb +224 -0
- data/lib/typeprof/core/graph/filter.rb +155 -0
- data/lib/typeprof/core/graph/vertex.rb +222 -0
- data/lib/typeprof/core/graph.rb +3 -0
- data/lib/typeprof/core/service.rb +522 -0
- data/lib/typeprof/core/type.rb +348 -0
- data/lib/typeprof/core/util.rb +81 -0
- data/lib/typeprof/core.rb +32 -0
- data/lib/typeprof/diagnostic.rb +35 -0
- data/lib/typeprof/lsp/messages.rb +430 -0
- data/lib/typeprof/lsp/server.rb +177 -0
- data/lib/typeprof/lsp/text.rb +69 -0
- data/lib/typeprof/lsp/util.rb +61 -0
- data/lib/typeprof/lsp.rb +4 -907
- data/lib/typeprof/version.rb +1 -1
- data/lib/typeprof.rb +4 -18
- data/typeprof.gemspec +5 -7
- metadata +48 -35
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/main.yml +0 -39
- data/.gitignore +0 -9
- data/Gemfile +0 -17
- data/Gemfile.lock +0 -41
- data/Rakefile +0 -10
- data/exe/typeprof +0 -10
- data/lib/typeprof/analyzer.rb +0 -2598
- data/lib/typeprof/arguments.rb +0 -414
- data/lib/typeprof/block.rb +0 -176
- data/lib/typeprof/builtin.rb +0 -893
- data/lib/typeprof/code-range.rb +0 -177
- data/lib/typeprof/config.rb +0 -158
- data/lib/typeprof/container-type.rb +0 -912
- data/lib/typeprof/export.rb +0 -589
- data/lib/typeprof/import.rb +0 -852
- data/lib/typeprof/insns-def.rb +0 -65
- data/lib/typeprof/iseq.rb +0 -864
- data/lib/typeprof/method.rb +0 -355
- data/lib/typeprof/type.rb +0 -1140
- data/lib/typeprof/utils.rb +0 -212
- data/tools/coverage.rb +0 -14
- data/tools/setup-insns-def.rb +0 -30
- data/typeprof-lsp +0 -3
data/lib/typeprof/utils.rb
DELETED
@@ -1,212 +0,0 @@
|
|
1
|
-
module TypeProf
|
2
|
-
module Utils
|
3
|
-
def self.array_update(ary, idx, elem)
|
4
|
-
idx %= ary.size
|
5
|
-
ary[0...idx] + [elem] + ary[idx+1..-1]
|
6
|
-
end
|
7
|
-
|
8
|
-
module StructuralEquality
|
9
|
-
def self.included(klass)
|
10
|
-
klass.instance_eval do
|
11
|
-
def new(*args)
|
12
|
-
(Thread.current[:table] ||= {})[[self] + args] ||= super
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Set
|
19
|
-
include StructuralEquality
|
20
|
-
|
21
|
-
attr_reader :tbl
|
22
|
-
|
23
|
-
def self.[](*values)
|
24
|
-
tbl = {}
|
25
|
-
values.each do |v|
|
26
|
-
tbl[v] = true
|
27
|
-
end
|
28
|
-
new(tbl)
|
29
|
-
end
|
30
|
-
|
31
|
-
def initialize(tbl)
|
32
|
-
@tbl = tbl
|
33
|
-
@tbl.freeze
|
34
|
-
end
|
35
|
-
|
36
|
-
def each(&blk)
|
37
|
-
@tbl.each_key(&blk)
|
38
|
-
end
|
39
|
-
|
40
|
-
include Enumerable
|
41
|
-
|
42
|
-
def sum(other)
|
43
|
-
if @tbl.size == 0
|
44
|
-
other
|
45
|
-
elsif other.tbl.size == 0
|
46
|
-
self
|
47
|
-
else
|
48
|
-
Set.new(@tbl.merge(other.tbl))
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def add(new_val)
|
53
|
-
tbl = @tbl.dup
|
54
|
-
tbl[new_val] = true
|
55
|
-
Set.new(tbl)
|
56
|
-
end
|
57
|
-
|
58
|
-
def size
|
59
|
-
@tbl.size
|
60
|
-
end
|
61
|
-
|
62
|
-
def map(&blk)
|
63
|
-
tbl = {}
|
64
|
-
each do |elem|
|
65
|
-
v = yield(elem)
|
66
|
-
tbl[v] = true
|
67
|
-
end
|
68
|
-
Set.new(tbl)
|
69
|
-
end
|
70
|
-
|
71
|
-
def inspect
|
72
|
-
s = []
|
73
|
-
each {|v| s << v.inspect }
|
74
|
-
"{#{ s.join(", ") }}"
|
75
|
-
end
|
76
|
-
|
77
|
-
def include?(elem)
|
78
|
-
@tbl[elem]
|
79
|
-
end
|
80
|
-
|
81
|
-
def intersection(other)
|
82
|
-
tbl = {}
|
83
|
-
h = 0
|
84
|
-
each do |elem|
|
85
|
-
if other.include?(elem)
|
86
|
-
tbl << elem
|
87
|
-
h ^= elem.hash
|
88
|
-
end
|
89
|
-
end
|
90
|
-
Set.new(tbl, h)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
class MutableSet
|
95
|
-
def initialize(*values)
|
96
|
-
@hash = {}
|
97
|
-
values.each {|v| @hash[v] = v }
|
98
|
-
end
|
99
|
-
|
100
|
-
def each(&blk)
|
101
|
-
@hash.each_key(&blk)
|
102
|
-
end
|
103
|
-
|
104
|
-
include Enumerable
|
105
|
-
|
106
|
-
def <<(v)
|
107
|
-
@hash[v] = true
|
108
|
-
end
|
109
|
-
|
110
|
-
def [](v)
|
111
|
-
@hash[v]
|
112
|
-
end
|
113
|
-
|
114
|
-
def delete(v)
|
115
|
-
@hash.delete(v)
|
116
|
-
end
|
117
|
-
|
118
|
-
def inspect
|
119
|
-
s = []
|
120
|
-
each {|v| s << v.inspect }
|
121
|
-
"{#{ s.join(", ") }}"
|
122
|
-
end
|
123
|
-
|
124
|
-
def size
|
125
|
-
@hash.size
|
126
|
-
end
|
127
|
-
|
128
|
-
def to_set
|
129
|
-
Set[*@hash.keys]
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
class HashWrapper
|
134
|
-
include StructuralEquality
|
135
|
-
|
136
|
-
def initialize(hash)
|
137
|
-
@internal_hash = hash.freeze
|
138
|
-
end
|
139
|
-
|
140
|
-
attr_reader :internal_hash
|
141
|
-
end
|
142
|
-
|
143
|
-
class WorkList
|
144
|
-
def initialize
|
145
|
-
@heap = []
|
146
|
-
@set = MutableSet.new
|
147
|
-
end
|
148
|
-
|
149
|
-
def insert(key, val)
|
150
|
-
i = @heap.size
|
151
|
-
@heap << [key, val]
|
152
|
-
while i > 0 && (@heap[i][0] <=> @heap[i / 2][0]) < 0
|
153
|
-
@heap[i], @heap[i / 2] = @heap[i / 2], @heap[i]
|
154
|
-
i /= 2
|
155
|
-
end
|
156
|
-
@set << val
|
157
|
-
end
|
158
|
-
|
159
|
-
def member?(val)
|
160
|
-
@set[val]
|
161
|
-
end
|
162
|
-
|
163
|
-
def deletemin
|
164
|
-
return nil if @heap.empty?
|
165
|
-
val = @heap[0][1]
|
166
|
-
@set.delete(val)
|
167
|
-
if @heap.size == 1
|
168
|
-
@heap.pop
|
169
|
-
return val
|
170
|
-
end
|
171
|
-
@heap[0] = @heap.pop
|
172
|
-
i = 0
|
173
|
-
while (j = i * 2 + 1) < @heap.size
|
174
|
-
j += 1 if j + 1 < @heap.size && (@heap[j][0] <=> @heap[j + 1][0]) >= 0
|
175
|
-
break if (@heap[i][0] <=> @heap[j][0]) < 0
|
176
|
-
@heap[i], @heap[j] = @heap[j], @heap[i]
|
177
|
-
i = j
|
178
|
-
end
|
179
|
-
return val
|
180
|
-
end
|
181
|
-
|
182
|
-
def size
|
183
|
-
@heap.size
|
184
|
-
end
|
185
|
-
|
186
|
-
def empty?
|
187
|
-
@heap.empty?
|
188
|
-
end
|
189
|
-
|
190
|
-
def inspect
|
191
|
-
"#<#{ self.class }:#{ @heap.map {|_key, val| val }.inspect }>"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
class CancelToken
|
196
|
-
def cancelled?
|
197
|
-
return false
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
class TimerCancelToken < CancelToken
|
202
|
-
def initialize(max_sec)
|
203
|
-
@max_sec = max_sec
|
204
|
-
@start_time = Time.now
|
205
|
-
end
|
206
|
-
|
207
|
-
def cancelled?
|
208
|
-
@max_sec && Time.now - @start_time >= @max_sec
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|
data/tools/coverage.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "coverage"
|
2
|
-
require "coverage/helpers"
|
3
|
-
|
4
|
-
cov = Coverage::Helpers.load("coverage.dump")
|
5
|
-
cov.delete("<compiled>")
|
6
|
-
cov2 = {}
|
7
|
-
cov.each do |path, data|
|
8
|
-
path = path.sub(/^exe\/..\//, "")
|
9
|
-
data2 = Coverage.line_stub(path)
|
10
|
-
data.each_with_index {|v, i| data2[i] = v if v }
|
11
|
-
cov2[path] = data2
|
12
|
-
end
|
13
|
-
File.write("coverage.info", Coverage::Helpers.to_lcov_info(cov2))
|
14
|
-
system("genhtml", "-o", "coverage", "coverage.info")
|
data/tools/setup-insns-def.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require "pp"
|
2
|
-
|
3
|
-
unless ARGV[0]
|
4
|
-
puts "usage: #$0 /path/to/ruby/trunk/insns.def"
|
5
|
-
exit
|
6
|
-
end
|
7
|
-
|
8
|
-
r = %r(
|
9
|
-
^DEFINE_INSN\n
|
10
|
-
(?<name>\w+)\n
|
11
|
-
\((?<operands>.*)\)\n
|
12
|
-
\((?<inputs>.*)\)\n
|
13
|
-
\((?<outputs>.*)\)\n
|
14
|
-
(?://(?<inc>.*)\n)?
|
15
|
-
)x
|
16
|
-
|
17
|
-
INSN_TABLE = {}
|
18
|
-
Insn = Struct.new(:operands, :inputs, :outputs)
|
19
|
-
File.read(ARGV[0]).scan(r) do
|
20
|
-
name, operands, _inputs, _outputs, _inc =
|
21
|
-
$~[:name], $~[:operands], $~[:inputs], $~[:outputs], $~[:inc]
|
22
|
-
next if name.start_with?("opt_")
|
23
|
-
next if name == "bitblt" || name == "answer"
|
24
|
-
operands = operands.split(",").map {|s| s.strip }.map do |s|
|
25
|
-
s.split(" ").map {|s| s.strip }[0]
|
26
|
-
end
|
27
|
-
INSN_TABLE[name.to_sym] = operands
|
28
|
-
end
|
29
|
-
target = File.join(__dir__, "../lib/typeprof/insns-def.rb")
|
30
|
-
File.write(target, "TypeProf::INSN_TABLE = " + INSN_TABLE.pretty_inspect)
|
data/typeprof-lsp
DELETED