typeprof 0.7.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -5
- data/lib/typeprof/analyzer.rb +211 -98
- data/lib/typeprof/arguments.rb +2 -0
- data/lib/typeprof/block.rb +40 -2
- data/lib/typeprof/builtin.rb +301 -99
- data/lib/typeprof/cli.rb +2 -0
- data/lib/typeprof/config.rb +14 -2
- data/lib/typeprof/container-type.rb +5 -4
- data/lib/typeprof/export.rb +116 -65
- data/lib/typeprof/import.rb +68 -41
- data/lib/typeprof/iseq.rb +46 -11
- data/lib/typeprof/method.rb +47 -23
- data/lib/typeprof/type.rb +96 -18
- data/lib/typeprof/version.rb +1 -1
- data/smoke/alias.rb +5 -4
- data/smoke/alias2.rb +6 -4
- data/smoke/any1.rb +2 -1
- data/smoke/any2.rb +3 -2
- data/smoke/arguments.rb +3 -2
- data/smoke/arguments2.rb +11 -10
- data/smoke/array-each.rb +2 -1
- data/smoke/array-each2.rb +2 -1
- data/smoke/array-each3.rb +2 -1
- data/smoke/array-ltlt.rb +2 -1
- data/smoke/array-ltlt2.rb +2 -1
- data/smoke/array-map.rb +2 -1
- data/smoke/array-map2.rb +2 -1
- data/smoke/array-map3.rb +4 -3
- data/smoke/array-mul.rb +3 -2
- data/smoke/array-plus1.rb +2 -1
- data/smoke/array-plus2.rb +3 -2
- data/smoke/array-pop.rb +2 -1
- data/smoke/array-range-aref.rb +12 -11
- data/smoke/array-replace.rb +2 -1
- data/smoke/array-s-aref.rb +2 -1
- data/smoke/array1.rb +6 -5
- data/smoke/array10.rb +2 -1
- data/smoke/array11.rb +2 -1
- data/smoke/array12.rb +4 -3
- data/smoke/array13.rb +5 -4
- data/smoke/array14.rb +2 -1
- data/smoke/array15.rb +16 -0
- data/smoke/array2.rb +4 -3
- data/smoke/array3.rb +5 -4
- data/smoke/array4.rb +2 -1
- data/smoke/array5.rb +2 -1
- data/smoke/array6.rb +4 -2
- data/smoke/array7.rb +2 -1
- data/smoke/array8.rb +1 -1
- data/smoke/array9.rb +2 -1
- data/smoke/attr-module.rb +27 -0
- data/smoke/attr-vis.rb +43 -0
- data/smoke/attr-vis.rbs +4 -0
- data/smoke/attr.rb +5 -5
- data/smoke/autoload.rb +2 -1
- data/smoke/backtrace.rb +4 -3
- data/smoke/block-ambiguous.rb +9 -8
- data/smoke/block-args1-rest.rb +13 -11
- data/smoke/block-args1.rb +11 -10
- data/smoke/block-args2-rest.rb +13 -11
- data/smoke/block-args2.rb +11 -10
- data/smoke/block-args3-rest.rb +15 -13
- data/smoke/block-args3.rb +13 -12
- data/smoke/block-blockarg.rb +5 -4
- data/smoke/block-kwarg.rb +11 -10
- data/smoke/block1.rb +2 -1
- data/smoke/block10.rb +2 -1
- data/smoke/block11.rb +6 -5
- data/smoke/block12.rb +3 -2
- data/smoke/block14.rb +3 -2
- data/smoke/block2.rb +2 -1
- data/smoke/block3.rb +3 -3
- data/smoke/block4.rb +3 -2
- data/smoke/block5.rb +4 -2
- data/smoke/block6.rb +3 -2
- data/smoke/block7.rb +2 -1
- data/smoke/block8.rb +4 -3
- data/smoke/block9.rb +2 -1
- data/smoke/block_given.rb +37 -0
- data/smoke/blown.rb +2 -1
- data/smoke/break1.rb +3 -2
- data/smoke/break2.rb +2 -1
- data/smoke/break3.rb +13 -0
- data/smoke/case.rb +2 -1
- data/smoke/case2.rb +2 -1
- data/smoke/case3.rb +17 -0
- data/smoke/class-hierarchy.rb +5 -5
- data/smoke/class-hierarchy2.rb +3 -3
- data/smoke/class-new.rb +15 -0
- data/smoke/class_instance_var.rb +1 -1
- data/smoke/class_method.rb +2 -2
- data/smoke/class_method2.rb +2 -2
- data/smoke/class_method3.rb +4 -2
- data/smoke/constant1.rb +6 -6
- data/smoke/constant2.rb +6 -4
- data/smoke/constant3.rb +2 -1
- data/smoke/constant4.rb +2 -1
- data/smoke/context-sensitive1.rb +2 -1
- data/smoke/cvar.rb +7 -5
- data/smoke/cvar2.rb +2 -2
- data/smoke/define_method.rb +2 -2
- data/smoke/define_method2.rb +2 -2
- data/smoke/define_method3.rb +14 -0
- data/smoke/define_method3.rbs +3 -0
- data/smoke/define_method4.rb +15 -0
- data/smoke/define_method4.rbs +3 -0
- data/smoke/define_method5.rb +12 -0
- data/smoke/define_method6.rb +19 -0
- data/smoke/demo.rb +7 -6
- data/smoke/demo1.rb +2 -1
- data/smoke/demo10.rb +3 -2
- data/smoke/demo11.rb +2 -1
- data/smoke/demo2.rb +2 -1
- data/smoke/demo3.rb +2 -1
- data/smoke/demo4.rb +3 -3
- data/smoke/demo5.rb +1 -1
- data/smoke/demo6.rb +4 -3
- data/smoke/demo7.rb +2 -1
- data/smoke/demo8.rb +3 -2
- data/smoke/demo9.rb +4 -2
- data/smoke/dummy-execution1.rb +3 -2
- data/smoke/dummy-execution2.rb +2 -2
- data/smoke/dummy_element.rb +14 -0
- data/smoke/ensure1.rb +3 -2
- data/smoke/enum_for.rb +15 -0
- data/smoke/enum_for2.rb +17 -0
- data/smoke/enumerator.rb +3 -2
- data/smoke/expandarray1.rb +2 -1
- data/smoke/expandarray2.rb +2 -1
- data/smoke/fib.rb +2 -2
- data/smoke/flip-flop.rb +28 -0
- data/smoke/flow1.rb +2 -1
- data/smoke/flow10.rb +17 -0
- data/smoke/flow2.rb +2 -1
- data/smoke/flow3.rb +2 -1
- data/smoke/flow5.rb +2 -1
- data/smoke/flow6.rb +2 -1
- data/smoke/flow7.rb +2 -1
- data/smoke/flow8.rb +2 -1
- data/smoke/flow9.rb +12 -0
- data/smoke/freeze.rb +2 -1
- data/smoke/function.rb +3 -2
- data/smoke/gvar.rb +3 -2
- data/smoke/gvar2.rb +4 -3
- data/smoke/hash-bot.rb +12 -0
- data/smoke/hash-fetch.rb +4 -3
- data/smoke/hash-merge-bang.rb +2 -1
- data/smoke/hash1.rb +3 -2
- data/smoke/hash2.rb +2 -1
- data/smoke/hash3.rb +2 -1
- data/smoke/hash4.rb +2 -1
- data/smoke/hash5.rb +1 -1
- data/smoke/inheritance.rb +4 -4
- data/smoke/inheritance2.rb +2 -2
- data/smoke/initialize.rb +7 -5
- data/smoke/instance_eval.rb +2 -2
- data/smoke/instance_eval2.rb +10 -0
- data/smoke/instance_eval3.rb +25 -0
- data/smoke/int_times.rb +2 -1
- data/smoke/integer.rb +2 -1
- data/smoke/ivar.rb +6 -4
- data/smoke/ivar2.rb +4 -4
- data/smoke/ivar3.rb +4 -3
- data/smoke/ivar4.rb +21 -0
- data/smoke/kernel-class.rb +2 -1
- data/smoke/keyword1.rb +2 -1
- data/smoke/keyword2.rb +2 -1
- data/smoke/keyword3.rb +2 -1
- data/smoke/keyword4.rb +2 -1
- data/smoke/keyword5.rb +2 -1
- data/smoke/kwrest.rb +3 -2
- data/smoke/kwsplat1.rb +5 -4
- data/smoke/kwsplat2.rb +2 -1
- data/smoke/lit-complex.rb +10 -0
- data/smoke/lit-encoding.rb +10 -0
- data/smoke/manual-rbs.rb +6 -4
- data/smoke/manual-rbs2.rb +2 -1
- data/smoke/manual-rbs3.rb +3 -2
- data/smoke/masgn1.rb +2 -1
- data/smoke/masgn2.rb +3 -2
- data/smoke/masgn3.rb +2 -1
- data/smoke/method_in_branch.rb +4 -3
- data/smoke/method_missing.rb +5 -4
- data/smoke/module1.rb +2 -2
- data/smoke/module2.rb +1 -1
- data/smoke/module3.rb +3 -3
- data/smoke/module4.rb +3 -2
- data/smoke/module5.rb +17 -0
- data/smoke/module6.rb +40 -0
- data/smoke/module_function1.rb +4 -3
- data/smoke/module_function2.rb +4 -3
- data/smoke/multiple-include.rb +2 -1
- data/smoke/multiple-superclass.rb +1 -1
- data/smoke/next1.rb +3 -2
- data/smoke/next2.rb +2 -1
- data/smoke/object-send1.rb +4 -3
- data/smoke/object-send2.rb +10 -0
- data/smoke/object-send3.rb +18 -0
- data/smoke/once.rb +2 -1
- data/smoke/optional1.rb +2 -1
- data/smoke/optional2.rb +2 -1
- data/smoke/optional3.rb +2 -1
- data/smoke/parameterizedd-self.rb +4 -2
- data/smoke/parameterizedd-self2.rb +1 -1
- data/smoke/pathname1.rb +2 -1
- data/smoke/pathname2.rb +2 -1
- data/smoke/pattern-match1.rb +2 -1
- data/smoke/pattern-match2.rb +2 -1
- data/smoke/prepend1.rb +33 -0
- data/smoke/prepend2.rb +10 -0
- data/smoke/prepend2.rbs +9 -0
- data/smoke/primitive_method.rb +19 -0
- data/smoke/printf.rb +2 -2
- data/smoke/proc.rb +3 -2
- data/smoke/proc2.rb +2 -1
- data/smoke/proc3.rb +2 -1
- data/smoke/proc4.rb +2 -1
- data/smoke/proc5.rb +19 -0
- data/smoke/public.rb +38 -0
- data/smoke/range.rb +2 -1
- data/smoke/rbs-alias.rb +2 -1
- data/smoke/rbs-attr.rb +6 -5
- data/smoke/rbs-attr2.rb +1 -1
- data/smoke/rbs-extend.rb +2 -1
- data/smoke/rbs-interface.rb +5 -4
- data/smoke/rbs-module.rb +26 -0
- data/smoke/rbs-module.rbs +4 -0
- data/smoke/rbs-opt-and-rest.rb +10 -0
- data/smoke/rbs-opt-and-rest.rbs +3 -0
- data/smoke/rbs-proc1.rb +2 -1
- data/smoke/rbs-proc2.rb +3 -2
- data/smoke/rbs-proc3.rb +2 -1
- data/smoke/rbs-record.rb +3 -2
- data/smoke/rbs-tyvar.rb +3 -2
- data/smoke/rbs-tyvar2.rb +3 -2
- data/smoke/rbs-tyvar3.rb +3 -2
- data/smoke/rbs-tyvar4.rb +4 -3
- data/smoke/rbs-tyvar5.rb +2 -1
- data/smoke/rbs-tyvar6.rb +4 -3
- data/smoke/rbs-tyvar7.rb +2 -1
- data/smoke/rbs-vars.rb +7 -6
- data/smoke/redo1.rb +3 -2
- data/smoke/redo2.rb +3 -2
- data/smoke/req-keyword.rb +2 -1
- data/smoke/rescue1.rb +3 -2
- data/smoke/rescue2.rb +3 -2
- data/smoke/rescue3.rb +20 -0
- data/smoke/rescue4.rb +17 -0
- data/smoke/respond_to.rb +2 -1
- data/smoke/rest-farg.rb +2 -1
- data/smoke/rest1.rb +3 -2
- data/smoke/rest2.rb +2 -1
- data/smoke/rest3.rb +7 -6
- data/smoke/rest4.rb +3 -2
- data/smoke/rest5.rb +2 -1
- data/smoke/rest6.rb +2 -1
- data/smoke/retry1.rb +3 -2
- data/smoke/return.rb +2 -1
- data/smoke/simple.rb +12 -0
- data/smoke/singleton_method.rb +1 -1
- data/smoke/step.rb +4 -3
- data/smoke/string-split.rb +2 -1
- data/smoke/struct-keyword_init.rb +10 -0
- data/smoke/struct.rb +1 -1
- data/smoke/struct2.rb +5 -4
- data/smoke/struct3.rb +2 -2
- data/smoke/struct4.rb +7 -0
- data/smoke/struct5.rb +16 -0
- data/smoke/struct6.rb +15 -0
- data/smoke/struct7.rb +17 -0
- data/smoke/stub-keyword.rb +10 -0
- data/smoke/super1.rb +5 -4
- data/smoke/super2.rb +1 -1
- data/smoke/super3.rb +4 -3
- data/smoke/super4.rb +7 -5
- data/smoke/super5.rb +6 -4
- data/smoke/svar1.rb +2 -1
- data/smoke/symbol-proc-attr.rb +22 -0
- data/smoke/symbol-proc-attr2.rb +15 -0
- data/smoke/symbol-proc-bot.rb +13 -0
- data/smoke/symbol-proc.rb +4 -3
- data/smoke/tap1.rb +3 -2
- data/smoke/toplevel.rb +2 -1
- data/smoke/two-map.rb +3 -2
- data/smoke/type_var.rb +4 -3
- data/smoke/typed_method.rb +2 -1
- data/smoke/uninitialize-var.rb +2 -1
- data/smoke/union-recv.rb +2 -2
- data/smoke/user-demo.rb +3 -3
- data/smoke/wrong-extend.rb +3 -2
- data/smoke/wrong-include.rb +3 -2
- data/smoke/wrong-include2.rb +17 -0
- data/typeprof.gemspec +1 -1
- metadata +57 -5
- data/tools/stackprof-wrapper.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d68099e4f5d60a45f949d6bfc3a47e8b7d3b7ba66a0794f25f5fe61628de1d1
|
4
|
+
data.tar.gz: 22792d1acb9b16a4150f1afbaf29d59987bf29772908b23075e6668df81a4309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42faa4e3b5c64fd5976e66067bf13339c530785914caad77bc0a405939bc914e9adf78bfbd0aea57a829cb21aed3c6dfc09f8f57def85b09312facd82d33b5a9
|
7
|
+
data.tar.gz: bc6f115fbf1d5292286f04f09d745cfb0c13688a71fdae730d0cfdd903ad8f9f3f9019e532c37b4cf23fe41f39c9a1683f92f28af68716ddf7e625a0efca33f8
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
typeprof (0.
|
5
|
-
rbs (>= 0.
|
4
|
+
typeprof (0.10.0)
|
5
|
+
rbs (>= 0.20.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -11,17 +11,20 @@ GEM
|
|
11
11
|
docile (1.3.2)
|
12
12
|
power_assert (1.2.0)
|
13
13
|
rake (13.0.1)
|
14
|
-
rbs (0.
|
15
|
-
simplecov (0.
|
14
|
+
rbs (0.20.1)
|
15
|
+
simplecov (0.20.0)
|
16
16
|
docile (~> 1.1)
|
17
17
|
simplecov-html (~> 0.11)
|
18
|
+
simplecov_json_formatter (~> 0.1)
|
18
19
|
simplecov-html (0.12.3)
|
20
|
+
simplecov_json_formatter (0.1.2)
|
19
21
|
stackprof (0.2.16)
|
20
22
|
test-unit (3.3.7)
|
21
23
|
power_assert
|
22
24
|
|
23
25
|
PLATFORMS
|
24
26
|
ruby
|
27
|
+
x86_64-linux
|
25
28
|
|
26
29
|
DEPENDENCIES
|
27
30
|
coverage-helpers
|
@@ -33,4 +36,4 @@ DEPENDENCIES
|
|
33
36
|
typeprof!
|
34
37
|
|
35
38
|
BUNDLED WITH
|
36
|
-
2.2.
|
39
|
+
2.2.1
|
data/lib/typeprof/analyzer.rb
CHANGED
@@ -34,6 +34,14 @@ module TypeProf
|
|
34
34
|
end
|
35
35
|
|
36
36
|
attr_reader :iseq, :cref, :mid
|
37
|
+
|
38
|
+
def source_location(pc)
|
39
|
+
if @iseq
|
40
|
+
@iseq.source_location(pc)
|
41
|
+
else
|
42
|
+
"<builtin>"
|
43
|
+
end
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
class TypedContext
|
@@ -45,6 +53,14 @@ module TypeProf
|
|
45
53
|
end
|
46
54
|
|
47
55
|
attr_reader :caller_ep, :mid
|
56
|
+
|
57
|
+
def source_location(_pc)
|
58
|
+
if @caller_ep
|
59
|
+
@caller_ep.source_location
|
60
|
+
else
|
61
|
+
"<typed-context:#{ @mid }>"
|
62
|
+
end
|
63
|
+
end
|
48
64
|
end
|
49
65
|
|
50
66
|
class ExecutionPoint
|
@@ -71,36 +87,33 @@ module TypeProf
|
|
71
87
|
end
|
72
88
|
|
73
89
|
def source_location
|
74
|
-
|
75
|
-
if iseq
|
76
|
-
iseq.source_location(@pc)
|
77
|
-
else
|
78
|
-
"<builtin>"
|
79
|
-
end
|
90
|
+
@ctx.source_location(@pc)
|
80
91
|
end
|
81
92
|
end
|
82
93
|
|
83
94
|
class StaticEnv
|
84
95
|
include Utils::StructuralEquality
|
85
96
|
|
86
|
-
def initialize(recv_ty, blk_ty, mod_func)
|
97
|
+
def initialize(recv_ty, blk_ty, mod_func, pub_meth)
|
87
98
|
@recv_ty = recv_ty
|
88
99
|
@blk_ty = blk_ty
|
89
100
|
@mod_func = mod_func
|
101
|
+
@pub_meth = pub_meth
|
90
102
|
|
91
103
|
return if recv_ty == :top #OK
|
92
104
|
recv_ty.each_child_global do |ty|
|
93
|
-
raise ty.inspect if !ty.is_a?(Type::Instance) && !ty.is_a?(Type::Class) && ty != Type.any
|
105
|
+
raise ty.inspect if !ty.is_a?(Type::Instance) && !ty.is_a?(Type::Class) && !ty.is_a?(Type::Symbol) && ty != Type.any
|
94
106
|
end
|
95
107
|
end
|
96
108
|
|
97
|
-
attr_reader :recv_ty, :blk_ty, :mod_func
|
109
|
+
attr_reader :recv_ty, :blk_ty, :mod_func, :pub_meth
|
98
110
|
|
99
111
|
def merge(other)
|
100
112
|
recv_ty = @recv_ty.union(other.recv_ty)
|
101
113
|
blk_ty = @blk_ty.union(other.blk_ty)
|
102
114
|
mod_func = @mod_func & other.mod_func # ??
|
103
|
-
|
115
|
+
pub_meth = @pub_meth & other.pub_meth # ??
|
116
|
+
StaticEnv.new(recv_ty, blk_ty, mod_func, pub_meth)
|
104
117
|
end
|
105
118
|
end
|
106
119
|
|
@@ -195,12 +208,22 @@ module TypeProf
|
|
195
208
|
end
|
196
209
|
|
197
210
|
def enable_module_function
|
198
|
-
senv = StaticEnv.new(@static_env.recv_ty, @static_env.blk_ty, true)
|
211
|
+
senv = StaticEnv.new(@static_env.recv_ty, @static_env.blk_ty, true, @static_env.pub_meth)
|
212
|
+
Env.new(senv, @locals, @stack, @type_params)
|
213
|
+
end
|
214
|
+
|
215
|
+
def method_public_set(flag)
|
216
|
+
senv = StaticEnv.new(@static_env.recv_ty, @static_env.blk_ty, @static_env.mod_func, flag)
|
199
217
|
Env.new(senv, @locals, @stack, @type_params)
|
200
218
|
end
|
201
219
|
|
202
220
|
def replace_recv_ty(ty)
|
203
|
-
senv = StaticEnv.new(ty, @static_env.blk_ty, @static_env.mod_func)
|
221
|
+
senv = StaticEnv.new(ty, @static_env.blk_ty, @static_env.mod_func, @static_env.pub_meth)
|
222
|
+
Env.new(senv, @locals, @stack, @type_params)
|
223
|
+
end
|
224
|
+
|
225
|
+
def replace_blk_ty(ty)
|
226
|
+
senv = StaticEnv.new(@static_env.recv_ty, ty, @static_env.mod_func, @static_env.pub_meth)
|
204
227
|
Env.new(senv, @locals, @stack, @type_params)
|
205
228
|
end
|
206
229
|
|
@@ -277,7 +300,10 @@ module TypeProf
|
|
277
300
|
def initialize(kind, name, absolute_path)
|
278
301
|
raise unless name.is_a?(Array)
|
279
302
|
@kind = kind
|
280
|
-
@modules = {
|
303
|
+
@modules = {
|
304
|
+
:before => { true => [], false => [] }, # before = include/extend
|
305
|
+
:after => { true => [], false => [] }, # after = prepend
|
306
|
+
}
|
281
307
|
@name = name
|
282
308
|
@consts = {}
|
283
309
|
@methods = {}
|
@@ -290,13 +316,13 @@ module TypeProf
|
|
290
316
|
attr_reader :kind, :modules, :consts, :methods, :ivars, :cvars, :absolute_path
|
291
317
|
attr_accessor :name, :klass_obj
|
292
318
|
|
293
|
-
def
|
294
|
-
|
295
|
-
if
|
296
|
-
raise "inconsistent include/extend type args in RBS?" if module_type_args != type_args && type_args != [] && type_args != nil
|
319
|
+
def mix_module(kind, mod, type_args, singleton, absolute_path)
|
320
|
+
mod_, module_type_args, absolute_paths = @modules[kind][singleton].find {|m,| m == mod }
|
321
|
+
if mod_
|
322
|
+
raise "inconsistent #{ kind == :after ? "include/extend" : "prepend" } type args in RBS?" if module_type_args != type_args && type_args != [] && type_args != nil
|
297
323
|
else
|
298
324
|
absolute_paths = Utils::MutableSet.new
|
299
|
-
@modules[singleton].unshift([mod, type_args, absolute_paths])
|
325
|
+
@modules[kind][singleton].unshift([mod, type_args, absolute_paths])
|
300
326
|
end
|
301
327
|
absolute_paths << absolute_path
|
302
328
|
end
|
@@ -313,10 +339,8 @@ module TypeProf
|
|
313
339
|
@consts[name] = [ty, absolute_path]
|
314
340
|
end
|
315
341
|
|
316
|
-
def
|
317
|
-
|
318
|
-
yield subst, direct if mthds&.include?(mthd)
|
319
|
-
@modules[singleton].each do |mod_def, type_args,|
|
342
|
+
def adjust_substitution_for_module(mods, mid, mthd, subst, &blk)
|
343
|
+
mods.each do |mod_def, type_args,|
|
320
344
|
if mod_def.klass_obj.type_params && type_args
|
321
345
|
subst2 = {}
|
322
346
|
mod_def.klass_obj.type_params.zip(type_args) do |(tyvar, *), tyarg|
|
@@ -328,11 +352,29 @@ module TypeProf
|
|
328
352
|
end
|
329
353
|
end
|
330
354
|
|
331
|
-
def
|
355
|
+
def adjust_substitution(singleton, mid, mthd, subst, direct, &blk)
|
356
|
+
adjust_substitution_for_module(@modules[:before][singleton], mid, mthd, subst, &blk)
|
357
|
+
|
358
|
+
mthds = @methods[[singleton, mid]]
|
359
|
+
yield subst, direct if mthds&.include?(mthd)
|
360
|
+
|
361
|
+
adjust_substitution_for_module(@modules[:after][singleton], mid, mthd, subst, &blk)
|
362
|
+
end
|
363
|
+
|
364
|
+
def search_method(singleton, mid, visited, &blk)
|
365
|
+
# Currently, circular inclusion of modules is allowed
|
366
|
+
return if visited[self]
|
367
|
+
visited[self] = true
|
368
|
+
|
369
|
+
@modules[:before][singleton].each do |mod_def,|
|
370
|
+
mod_def.search_method(false, mid, visited, &blk)
|
371
|
+
end
|
372
|
+
|
332
373
|
mthds = @methods[[singleton, mid]]
|
333
374
|
yield mthds, @klass_obj, singleton if mthds
|
334
|
-
|
335
|
-
|
375
|
+
|
376
|
+
@modules[:after][singleton].each do |mod_def,|
|
377
|
+
mod_def.search_method(false, mid, visited, &blk)
|
336
378
|
end
|
337
379
|
end
|
338
380
|
|
@@ -360,17 +402,17 @@ module TypeProf
|
|
360
402
|
end
|
361
403
|
end
|
362
404
|
|
363
|
-
def
|
364
|
-
return if
|
405
|
+
def mix_module(kind, mixing_mod, mixed_mod, type_args, singleton, caller_ep)
|
406
|
+
return if mixed_mod == Type.any
|
365
407
|
|
366
|
-
|
367
|
-
|
368
|
-
if
|
369
|
-
|
370
|
-
if
|
371
|
-
|
408
|
+
mixing_mod = @class_defs[mixing_mod.idx]
|
409
|
+
mixed_mod.each_child do |mixed_mod|
|
410
|
+
if mixed_mod.is_a?(Type::Class)
|
411
|
+
mixed_mod = @class_defs[mixed_mod.idx]
|
412
|
+
if mixed_mod && mixed_mod.kind == :module
|
413
|
+
mixing_mod.mix_module(kind, mixed_mod, type_args, singleton, caller_ep ? caller_ep.ctx.iseq.absolute_path : nil)
|
372
414
|
else
|
373
|
-
warn "
|
415
|
+
warn(caller_ep, "attempted to #{ kind == :after ? "include/extend" : "prepend" } non-module; ignored")
|
374
416
|
end
|
375
417
|
end
|
376
418
|
end
|
@@ -380,12 +422,12 @@ module TypeProf
|
|
380
422
|
cbase && cbase.idx != 1 ? @class_defs[cbase.idx].name : []
|
381
423
|
end
|
382
424
|
|
383
|
-
def new_class(cbase, name, type_params, superclass,
|
425
|
+
def new_class(cbase, name, type_params, superclass, absolute_path)
|
384
426
|
show_name = cbase_path(cbase) + [name]
|
385
427
|
idx = @class_defs.size
|
386
428
|
if superclass
|
387
429
|
@class_defs[idx] = ClassDef.new(:class, show_name, absolute_path)
|
388
|
-
klass = Type::Class.new(:class, idx, type_params, superclass,
|
430
|
+
klass = Type::Class.new(:class, idx, type_params, superclass, show_name)
|
389
431
|
@class_defs[idx].klass_obj = klass
|
390
432
|
cbase ||= klass # for bootstrap
|
391
433
|
add_constant(cbase, name, klass, absolute_path)
|
@@ -393,13 +435,17 @@ module TypeProf
|
|
393
435
|
else
|
394
436
|
# module
|
395
437
|
@class_defs[idx] = ClassDef.new(:module, show_name, absolute_path)
|
396
|
-
mod = Type::Class.new(:module, idx, type_params, nil,
|
438
|
+
mod = Type::Class.new(:module, idx, type_params, nil, show_name)
|
397
439
|
@class_defs[idx].klass_obj = mod
|
398
440
|
add_constant(cbase, name, mod, absolute_path)
|
399
441
|
return mod
|
400
442
|
end
|
401
443
|
end
|
402
444
|
|
445
|
+
def add_superclass_type_args!(klass, tyargs)
|
446
|
+
klass.superclass_type_args = tyargs
|
447
|
+
end
|
448
|
+
|
403
449
|
def new_struct(ep)
|
404
450
|
return @struct_defs[ep] if @struct_defs[ep]
|
405
451
|
|
@@ -407,7 +453,8 @@ module TypeProf
|
|
407
453
|
superclass = Type::Builtin[:struct]
|
408
454
|
name = "AnonymousStruct_generated_#{ @anonymous_struct_gen_id += 1 }"
|
409
455
|
@class_defs[idx] = ClassDef.new(:class, [name], ep.ctx.iseq.absolute_path)
|
410
|
-
klass = Type::Class.new(:class, idx, [], superclass,
|
456
|
+
klass = Type::Class.new(:class, idx, [], superclass, name)
|
457
|
+
add_superclass_type_args!(klass, [Type.any])
|
411
458
|
@class_defs[idx].klass_obj = klass
|
412
459
|
|
413
460
|
@struct_defs[ep] = klass
|
@@ -467,13 +514,13 @@ module TypeProf
|
|
467
514
|
if klass.kind == :class
|
468
515
|
while klass != :__root__
|
469
516
|
class_def = @class_defs[klass.idx]
|
470
|
-
class_def.search_method(singleton, mid, &blk)
|
517
|
+
class_def.search_method(singleton, mid, {}, &blk)
|
471
518
|
klass = klass.superclass
|
472
519
|
end
|
473
520
|
else
|
474
521
|
# module
|
475
522
|
class_def = @class_defs[klass.idx]
|
476
|
-
class_def.search_method(singleton, mid, &blk)
|
523
|
+
class_def.search_method(singleton, mid, {}, &blk)
|
477
524
|
end
|
478
525
|
if singleton
|
479
526
|
search_method(Type::Builtin[klass_orig.kind], false, mid, &blk)
|
@@ -533,9 +580,7 @@ module TypeProf
|
|
533
580
|
end
|
534
581
|
|
535
582
|
def add_constant(klass, name, value, user_defined)
|
536
|
-
if klass
|
537
|
-
self
|
538
|
-
else
|
583
|
+
if klass.is_a?(Type::Class)
|
539
584
|
@class_defs[klass.idx].add_constant(name, value, user_defined)
|
540
585
|
end
|
541
586
|
end
|
@@ -554,39 +599,39 @@ module TypeProf
|
|
554
599
|
mdef
|
555
600
|
end
|
556
601
|
|
557
|
-
def add_attr_method(klass,
|
602
|
+
def add_attr_method(klass, mid, ivar, kind, pub_meth, ep)
|
558
603
|
if kind == :reader || kind == :accessor
|
559
|
-
add_method(klass, mid, false, AttrMethodDef.new(ivar, :reader,
|
604
|
+
add_method(klass, mid, false, AttrMethodDef.new(ivar, :reader, pub_meth, ep))
|
560
605
|
end
|
561
606
|
if kind == :writer || kind == :accessor
|
562
|
-
add_method(klass, :"#{ mid }=", false, AttrMethodDef.new(ivar, :writer,
|
607
|
+
add_method(klass, :"#{ mid }=", false, AttrMethodDef.new(ivar, :writer, pub_meth, ep))
|
563
608
|
end
|
564
609
|
end
|
565
610
|
|
566
|
-
def add_iseq_method(klass, mid, iseq, cref, outer_ep)
|
567
|
-
add_method(klass, mid, false, ISeqMethodDef.new(iseq, cref, outer_ep))
|
611
|
+
def add_iseq_method(klass, mid, iseq, cref, outer_ep, pub_meth)
|
612
|
+
add_method(klass, mid, false, ISeqMethodDef.new(iseq, cref, outer_ep, pub_meth))
|
568
613
|
end
|
569
614
|
|
570
|
-
def add_singleton_iseq_method(klass, mid, iseq, cref, outer_ep)
|
571
|
-
add_method(klass, mid, true, ISeqMethodDef.new(iseq, cref, outer_ep))
|
615
|
+
def add_singleton_iseq_method(klass, mid, iseq, cref, outer_ep, pub_meth)
|
616
|
+
add_method(klass, mid, true, ISeqMethodDef.new(iseq, cref, outer_ep, pub_meth))
|
572
617
|
end
|
573
618
|
|
574
|
-
def set_custom_method(klass, mid, impl)
|
575
|
-
set_method(klass, mid, false, CustomMethodDef.new(impl))
|
619
|
+
def set_custom_method(klass, mid, impl, pub_meth = true)
|
620
|
+
set_method(klass, mid, false, CustomMethodDef.new(impl, pub_meth))
|
576
621
|
end
|
577
622
|
|
578
|
-
def set_singleton_custom_method(klass, mid, impl)
|
579
|
-
set_method(klass, mid, true, CustomMethodDef.new(impl))
|
623
|
+
def set_singleton_custom_method(klass, mid, impl, pub_meth = true)
|
624
|
+
set_method(klass, mid, true, CustomMethodDef.new(impl, pub_meth))
|
580
625
|
end
|
581
626
|
|
582
|
-
def alias_method(klass, singleton,
|
627
|
+
def alias_method(klass, singleton, alias_mid, orig_mid, ep)
|
583
628
|
if klass == Type.any
|
584
629
|
self
|
585
630
|
else
|
586
|
-
mdefs = get_method(klass, singleton,
|
631
|
+
mdefs = get_method(klass, singleton, orig_mid)
|
587
632
|
if mdefs
|
588
633
|
mdefs.each do |mdef|
|
589
|
-
@class_defs[klass.idx].add_method(
|
634
|
+
@class_defs[klass.idx].add_method(alias_mid, singleton, AliasMethodDef.new(orig_mid, mdef, ep))
|
590
635
|
end
|
591
636
|
end
|
592
637
|
end
|
@@ -601,6 +646,10 @@ module TypeProf
|
|
601
646
|
@iseq_method_to_ctxs[iseq_mdef] << ctx
|
602
647
|
end
|
603
648
|
|
649
|
+
def add_executed_iseq(iseq)
|
650
|
+
@executed_iseqs << iseq
|
651
|
+
end
|
652
|
+
|
604
653
|
def add_callsite!(callee_ctx, caller_ep, caller_env, &ctn)
|
605
654
|
@executed_iseqs << callee_ctx.iseq if callee_ctx.is_a?(Context)
|
606
655
|
|
@@ -660,8 +709,10 @@ module TypeProf
|
|
660
709
|
def add_read!(site, ep, &ctn)
|
661
710
|
entry = @tbl[site] ||= Entry.new(false, {}, Type.bot, Utils::MutableSet.new)
|
662
711
|
entry.read_continuations[ep] = ctn
|
663
|
-
entry.absolute_paths << ep.ctx.iseq.absolute_path
|
664
|
-
|
712
|
+
entry.absolute_paths << ep.ctx.iseq.absolute_path if ep.ctx.is_a?(Context)
|
713
|
+
ty = entry.type
|
714
|
+
ty = Type.nil if ty == Type.bot
|
715
|
+
ctn[ty, ep]
|
665
716
|
end
|
666
717
|
|
667
718
|
def add_write!(site, ty, ep, scratch)
|
@@ -669,7 +720,7 @@ module TypeProf
|
|
669
720
|
if ep
|
670
721
|
if entry.rbs_declared
|
671
722
|
unless Type.match?(ty, entry.type)
|
672
|
-
scratch.warn(ep, "inconsistent assignment to RBS-declared
|
723
|
+
scratch.warn(ep, "inconsistent assignment to RBS-declared variable")
|
673
724
|
return
|
674
725
|
end
|
675
726
|
end
|
@@ -719,6 +770,7 @@ module TypeProf
|
|
719
770
|
|
720
771
|
def add_cvar_read!(klass, var, ep, &ctn)
|
721
772
|
klass.each_child do |klass|
|
773
|
+
next unless klass.is_a?(Type::Class)
|
722
774
|
class_def = @class_defs[klass.idx]
|
723
775
|
next unless class_def
|
724
776
|
class_def.cvars.add_read!(var, ep, &ctn)
|
@@ -727,6 +779,7 @@ module TypeProf
|
|
727
779
|
|
728
780
|
def add_cvar_write!(klass, var, ty, ep)
|
729
781
|
klass.each_child do |klass|
|
782
|
+
next unless klass.is_a?(Type::Class)
|
730
783
|
class_def = @class_defs[klass.idx]
|
731
784
|
next unless class_def
|
732
785
|
class_def.cvars.add_write!(var, ty, ep, self)
|
@@ -858,7 +911,7 @@ module TypeProf
|
|
858
911
|
@pending_execution.delete(iseq)
|
859
912
|
end while @executed_iseqs.include?(iseq)
|
860
913
|
|
861
|
-
puts "DEBUG: trigger
|
914
|
+
puts "DEBUG: trigger stub execution (#{ iseq&.name || "(nil)" }): rest #{ @pending_execution.size }" if Config.verbose >= 2
|
862
915
|
|
863
916
|
break if !iseq
|
864
917
|
case kind
|
@@ -953,7 +1006,7 @@ module TypeProf
|
|
953
1006
|
locals[kwrest_index] = Type.any if kwrest_index
|
954
1007
|
locals[block_index] = Type.nil if block_index
|
955
1008
|
|
956
|
-
env = Env.new(StaticEnv.new(recv, Type.nil, false), locals, [], Utils::HashWrapper.new({}))
|
1009
|
+
env = Env.new(StaticEnv.new(recv, Type.nil, false, true), locals, [], Utils::HashWrapper.new({}))
|
957
1010
|
|
958
1011
|
if !@pending_execution[iseq] || @pending_execution[iseq][0] == :block
|
959
1012
|
@pending_execution[iseq] = [:method, [meth, ep, env]]
|
@@ -962,10 +1015,14 @@ module TypeProf
|
|
962
1015
|
|
963
1016
|
def pend_block_dummy_execution(blk, iseq, nep, nenv)
|
964
1017
|
@pending_execution[iseq] ||= [:block, [blk, {}]]
|
965
|
-
if @pending_execution[iseq][
|
966
|
-
|
1018
|
+
if @pending_execution[iseq][0] == :block
|
1019
|
+
if @pending_execution[iseq][1][1][nep]
|
1020
|
+
@pending_execution[iseq][1][1][nep] = @pending_execution[iseq][1][1][nep].merge(nenv)
|
1021
|
+
else
|
1022
|
+
@pending_execution[iseq][1][1][nep] = nenv
|
1023
|
+
end
|
967
1024
|
else
|
968
|
-
|
1025
|
+
# XXX: what to do?
|
969
1026
|
end
|
970
1027
|
end
|
971
1028
|
|
@@ -1014,9 +1071,9 @@ module TypeProf
|
|
1014
1071
|
block_start = iseq.fargs_format[:block_start]
|
1015
1072
|
|
1016
1073
|
lead_tys = env.locals[0, lead_num].map {|ty| globalize_type(ty, env, ep) }
|
1017
|
-
opt_tys = opt.size > 1 ? env.locals[lead_num, opt.size - 1].map {|ty| globalize_type(ty, env, ep) } :
|
1074
|
+
opt_tys = opt.size > 1 ? env.locals[lead_num, opt.size - 1].map {|ty| globalize_type(ty, env, ep) } : []
|
1018
1075
|
if rest_start # XXX:squash
|
1019
|
-
ty = globalize_type(env.locals[
|
1076
|
+
ty = globalize_type(env.locals[rest_start], env, ep)
|
1020
1077
|
rest_ty = Type.bot
|
1021
1078
|
ty.each_child_global do |ty|
|
1022
1079
|
if ty.is_a?(Type::Array)
|
@@ -1051,6 +1108,7 @@ module TypeProf
|
|
1051
1108
|
end
|
1052
1109
|
end
|
1053
1110
|
kw_rest_ty = globalize_type(env.locals[kw_rest], env, ep) if kw_rest
|
1111
|
+
kw_rest_ty = nil if kw_rest_ty == Type.nil
|
1054
1112
|
if block_start
|
1055
1113
|
blk_ty = globalize_type(env.locals[block_start], env, ep)
|
1056
1114
|
elsif iseq.type == :method
|
@@ -1148,7 +1206,7 @@ module TypeProf
|
|
1148
1206
|
cref = ep.ctx.cref
|
1149
1207
|
recv.each_child do |recv|
|
1150
1208
|
if recv.is_a?(Type::Class)
|
1151
|
-
meth = add_singleton_iseq_method(recv, mid, iseq, cref, nil)
|
1209
|
+
meth = add_singleton_iseq_method(recv, mid, iseq, cref, nil, env.static_env.pub_meth)
|
1152
1210
|
pend_method_execution(iseq, meth, recv, mid, ep.ctx.cref, nil)
|
1153
1211
|
else
|
1154
1212
|
recv = Type.any # XXX: what to do?
|
@@ -1185,11 +1243,11 @@ module TypeProf
|
|
1185
1243
|
else # module
|
1186
1244
|
superclass = nil
|
1187
1245
|
end
|
1188
|
-
if cbase
|
1189
|
-
klass =
|
1246
|
+
if cbase.is_a?(Type::Class)
|
1247
|
+
klass = new_class(cbase, id, [], superclass, ep.ctx.iseq.absolute_path)
|
1248
|
+
add_superclass_type_args!(klass, superclass.type_params.map { Type.any }) if superclass
|
1190
1249
|
else
|
1191
|
-
|
1192
|
-
klass = new_class(cbase, id, [], superclass, superclass_type_args, ep.ctx.iseq.absolute_path)
|
1250
|
+
klass = Type.any
|
1193
1251
|
end
|
1194
1252
|
end
|
1195
1253
|
singleton = false
|
@@ -1211,7 +1269,7 @@ module TypeProf
|
|
1211
1269
|
nctx = Context.new(iseq, ncref, nil)
|
1212
1270
|
nep = ExecutionPoint.new(nctx, 0, nil)
|
1213
1271
|
locals = [Type.nil] * iseq.locals.size
|
1214
|
-
nenv = Env.new(StaticEnv.new(recv, blk, false), locals, [], Utils::HashWrapper.new({}))
|
1272
|
+
nenv = Env.new(StaticEnv.new(recv, blk, false, true), locals, [], Utils::HashWrapper.new({}))
|
1215
1273
|
merge_env(nep, nenv)
|
1216
1274
|
add_callsite!(nep.ctx, ep, env) do |ret_ty, ep, env|
|
1217
1275
|
nenv, ret_ty = localize_type(ret_ty, env, ep)
|
@@ -1230,7 +1288,7 @@ module TypeProf
|
|
1230
1288
|
end
|
1231
1289
|
end
|
1232
1290
|
return
|
1233
|
-
when :
|
1291
|
+
when :getlocal_send_branch
|
1234
1292
|
getlocal_operands, send_operands, branch_operands = operands
|
1235
1293
|
env, recvs, mid, aargs = setup_actual_arguments(:method, send_operands, ep, env)
|
1236
1294
|
recvs = Type.any if recvs == Type.bot
|
@@ -1258,6 +1316,31 @@ module TypeProf
|
|
1258
1316
|
end
|
1259
1317
|
end
|
1260
1318
|
return
|
1319
|
+
when :send_branch
|
1320
|
+
send_operands, branch_operands = operands
|
1321
|
+
env, recvs, mid, aargs = setup_actual_arguments(:method, send_operands, ep, env)
|
1322
|
+
recvs = Type.any if recvs == Type.bot
|
1323
|
+
recvs.each_child do |recv|
|
1324
|
+
do_send(recv, mid, aargs, ep, env) do |ret_ty, ep, env|
|
1325
|
+
env, ret_ty, = localize_type(ret_ty, env, ep)
|
1326
|
+
|
1327
|
+
branchtype, target, = branch_operands
|
1328
|
+
# branchtype: :if or :unless or :nil
|
1329
|
+
ep_then = ep.next
|
1330
|
+
ep_else = ep.jump(target)
|
1331
|
+
|
1332
|
+
case ret_ty
|
1333
|
+
when Type::Instance.new(Type::Builtin[:true])
|
1334
|
+
merge_env(branchtype == :if ? ep_else : ep_then, env)
|
1335
|
+
when Type::Instance.new(Type::Builtin[:false])
|
1336
|
+
merge_env(branchtype == :if ? ep_then : ep_else, env)
|
1337
|
+
else
|
1338
|
+
merge_env(ep_then, env)
|
1339
|
+
merge_env(ep_else, env)
|
1340
|
+
end
|
1341
|
+
end
|
1342
|
+
end
|
1343
|
+
return
|
1261
1344
|
when :invokeblock
|
1262
1345
|
env, recvs, mid, aargs = setup_actual_arguments(:block, operands, ep, env)
|
1263
1346
|
blk = env.static_env.blk_ty
|
@@ -1327,11 +1410,24 @@ module TypeProf
|
|
1327
1410
|
return
|
1328
1411
|
when :break
|
1329
1412
|
tmp_ep = ep
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1413
|
+
while true
|
1414
|
+
if tmp_ep.ctx.iseq.type == :block
|
1415
|
+
tmp_ep = tmp_ep.outer
|
1416
|
+
nenv = @return_envs[tmp_ep].push(ty)
|
1417
|
+
merge_env(tmp_ep.next, nenv)
|
1418
|
+
break
|
1419
|
+
end
|
1420
|
+
_type, _iseq, cont, stack_depth = tmp_ep.ctx.iseq.catch_table[tmp_ep.pc]&.find {|type,| type == :break }
|
1421
|
+
if cont
|
1422
|
+
nenv = @return_envs[tmp_ep]
|
1423
|
+
nenv, = nenv.pop(nenv.stack.size - stack_depth)
|
1424
|
+
nenv = nenv.push(ty)
|
1425
|
+
tmp_ep = tmp_ep.jump(cont)
|
1426
|
+
merge_env(tmp_ep, nenv)
|
1427
|
+
break
|
1428
|
+
end
|
1429
|
+
tmp_ep = tmp_ep.outer
|
1430
|
+
end
|
1335
1431
|
when :next, :redo
|
1336
1432
|
# begin; rescue; next; end
|
1337
1433
|
tmp_ep = ep.outer
|
@@ -1573,7 +1669,7 @@ module TypeProf
|
|
1573
1669
|
warn(ep, "already initialized constant #{ Type::Instance.new(cbase).screen_name(self) }::#{ name }")
|
1574
1670
|
end
|
1575
1671
|
ty.each_child do |ty|
|
1576
|
-
if ty.is_a?(Type::Class) && ty.superclass == Type::Builtin[:struct]
|
1672
|
+
if ty.is_a?(Type::Class) && cbase.is_a?(Type::Class) && ty.superclass == Type::Builtin[:struct]
|
1577
1673
|
@class_defs[ty.idx].name = cbase_path(cbase) + [name]
|
1578
1674
|
end
|
1579
1675
|
end
|
@@ -1582,7 +1678,6 @@ module TypeProf
|
|
1582
1678
|
when :getspecial
|
1583
1679
|
key, type = operands
|
1584
1680
|
if type == 0
|
1585
|
-
raise NotImplementedError
|
1586
1681
|
case key
|
1587
1682
|
when 0 # VM_SVAR_LASTLINE
|
1588
1683
|
env = env.push(Type.any) # or String | NilClass only?
|
@@ -1600,8 +1695,12 @@ module TypeProf
|
|
1600
1695
|
return
|
1601
1696
|
end
|
1602
1697
|
when :setspecial
|
1603
|
-
|
1604
|
-
|
1698
|
+
key, = operands
|
1699
|
+
if key >= 2 # flip-flop
|
1700
|
+
env, = env.pop(1)
|
1701
|
+
else
|
1702
|
+
raise "unknown setspecial key: #{ key }"
|
1703
|
+
end
|
1605
1704
|
|
1606
1705
|
when :dup
|
1607
1706
|
env, (ty,) = env.pop(1)
|
@@ -1652,10 +1751,16 @@ module TypeProf
|
|
1652
1751
|
env = env.push(Type.optional(sym_ty))
|
1653
1752
|
when :checkmatch
|
1654
1753
|
flag, = operands
|
1754
|
+
|
1755
|
+
# This flag means that the stack top is an array, and the check needs to be applied to find all elements
|
1756
|
+
# However, currently TypeProf uses very conservative interpretation (all check returns both true and false),
|
1757
|
+
# so we just ignore the flag now
|
1655
1758
|
_array = flag & 4 != 0
|
1759
|
+
|
1656
1760
|
case flag & 3
|
1657
|
-
when 1
|
1658
|
-
|
1761
|
+
when 1 # VM_CHECKMATCH_TYPE_WHEN
|
1762
|
+
env, = env.pop(2)
|
1763
|
+
env = env.push(Type.bool)
|
1659
1764
|
when 2 # VM_CHECKMATCH_TYPE_CASE
|
1660
1765
|
env, = env.pop(2)
|
1661
1766
|
env = env.push(Type.bool)
|
@@ -1865,6 +1970,10 @@ module TypeProf
|
|
1865
1970
|
rest_ty = aargs.last
|
1866
1971
|
aargs = aargs[0..-2]
|
1867
1972
|
if flag_args_kw_splat
|
1973
|
+
# XXX: The types contained in ActualArguments are expected to be all local types.
|
1974
|
+
# This "globalize_type" breaks the invariant, and violates the assertion of Union#globalize that asserts @elems be nil.
|
1975
|
+
# To fix this issue fundamentally, ActualArguments should keep all arguments as-is (as like the VM does),
|
1976
|
+
# and globalize some types on the on-demand bases.
|
1868
1977
|
ty = globalize_type(rest_ty, env, ep)
|
1869
1978
|
if ty.is_a?(Type::Array)
|
1870
1979
|
_, (ty,) = ty.elems.take_last(1)
|
@@ -1897,6 +2006,10 @@ module TypeProf
|
|
1897
2006
|
aargs = ActualArguments.new(aargs, rest_ty, kw_tys, blk_ty)
|
1898
2007
|
elsif flag_args_kw_splat
|
1899
2008
|
last = aargs.last
|
2009
|
+
# XXX: The types contained in ActualArguments are expected to be all local types.
|
2010
|
+
# This "globalize_type" breaks the invariant, and violates the assertion of Union#globalize that asserts @elems be nil.
|
2011
|
+
# To fix this issue fundamentally, ActualArguments should keep all arguments as-is (as like the VM does),
|
2012
|
+
# and globalize some types on the on-demand bases.
|
1900
2013
|
ty = globalize_type(last, env, ep)
|
1901
2014
|
case ty
|
1902
2015
|
when Type::Hash
|
@@ -1940,7 +2053,7 @@ module TypeProf
|
|
1940
2053
|
nctx = Context.new(blk_iseq, ep.ctx.cref, ep.ctx.mid)
|
1941
2054
|
nep = ExecutionPoint.new(nctx, 0, ep)
|
1942
2055
|
nlocals = [Type.any] * blk_iseq.locals.size
|
1943
|
-
nsenv = StaticEnv.new(env.static_env.recv_ty, Type.any, env.static_env.mod_func)
|
2056
|
+
nsenv = StaticEnv.new(env.static_env.recv_ty, Type.any, env.static_env.mod_func, env.static_env.pub_meth)
|
1944
2057
|
nenv = Env.new(nsenv, nlocals, [], nil)
|
1945
2058
|
pend_block_dummy_execution(blk_ty, blk_iseq, nep, nenv)
|
1946
2059
|
merge_return_env(ep) {|tenv| tenv ? tenv.merge(env) : env }
|
@@ -1991,27 +2104,27 @@ module TypeProf
|
|
1991
2104
|
|
1992
2105
|
def do_define_iseq_method(ep, env, mid, iseq, outer_ep)
|
1993
2106
|
cref = ep.ctx.cref
|
1994
|
-
recv = env.static_env.recv_ty
|
1995
2107
|
if cref.klass.is_a?(Type::Class)
|
1996
2108
|
typed_mdef = check_typed_method(cref.klass, mid, ep.ctx.cref.singleton)
|
1997
|
-
recv =
|
2109
|
+
recv = cref.klass
|
2110
|
+
recv = Type::Instance.new(recv) unless ep.ctx.cref.singleton
|
1998
2111
|
if typed_mdef
|
1999
|
-
mdef = ISeqMethodDef.new(iseq, cref, outer_ep)
|
2112
|
+
mdef = ISeqMethodDef.new(iseq, cref, outer_ep, env.static_env.pub_meth)
|
2000
2113
|
typed_mdef.each do |typed_mdef|
|
2001
2114
|
typed_mdef.do_match_iseq_mdef(mdef, recv, mid, env, ep, self)
|
2002
2115
|
end
|
2003
2116
|
else
|
2004
2117
|
if ep.ctx.cref.singleton
|
2005
|
-
meth = add_singleton_iseq_method(cref.klass, mid, iseq, cref, outer_ep)
|
2118
|
+
meth = add_singleton_iseq_method(cref.klass, mid, iseq, cref, outer_ep, true)
|
2006
2119
|
else
|
2007
|
-
meth = add_iseq_method(cref.klass, mid, iseq, cref, outer_ep)
|
2120
|
+
meth = add_iseq_method(cref.klass, mid, iseq, cref, outer_ep, env.static_env.pub_meth)
|
2008
2121
|
if env.static_env.mod_func
|
2009
|
-
add_singleton_iseq_method(cref.klass, mid, iseq, cref, outer_ep)
|
2122
|
+
add_singleton_iseq_method(cref.klass, mid, iseq, cref, outer_ep, true)
|
2010
2123
|
end
|
2011
2124
|
end
|
2012
|
-
|
2013
|
-
pend_method_execution(iseq, meth, recv, mid, ep.ctx.cref, outer_ep)
|
2014
2125
|
end
|
2126
|
+
|
2127
|
+
pend_method_execution(iseq, meth, recv, mid, ep.ctx.cref, outer_ep)
|
2015
2128
|
else
|
2016
2129
|
# XXX: what to do?
|
2017
2130
|
end
|
@@ -2040,7 +2153,7 @@ module TypeProf
|
|
2040
2153
|
|
2041
2154
|
bsig ||= BlockSignature.new([], [], nil, Type.nil)
|
2042
2155
|
|
2043
|
-
bsig = bsig.screen_name(self)
|
2156
|
+
bsig = bsig.screen_name(nil, self)
|
2044
2157
|
ret_ty = ret_ty.screen_name(self)
|
2045
2158
|
ret_ty = (ret_ty.include?("|") ? "(#{ ret_ty })" : ret_ty) # XXX?
|
2046
2159
|
|
@@ -2057,7 +2170,7 @@ module TypeProf
|
|
2057
2170
|
next unless @block_to_ctx[blk.block_body] # this occurs when screen_name is called before type-profiling finished (e.g., error message)
|
2058
2171
|
@block_to_ctx[blk.block_body].each do |blk_ctx|
|
2059
2172
|
if farg_tys
|
2060
|
-
farg_tys = farg_tys.
|
2173
|
+
farg_tys = farg_tys.merge_as_block_arguments(@method_signatures[blk_ctx])
|
2061
2174
|
else
|
2062
2175
|
farg_tys = @method_signatures[blk_ctx]
|
2063
2176
|
end
|
@@ -2067,7 +2180,7 @@ module TypeProf
|
|
2067
2180
|
end
|
2068
2181
|
end
|
2069
2182
|
|
2070
|
-
farg_tys = farg_tys ? farg_tys.screen_name(self) : "(unknown)"
|
2183
|
+
farg_tys = farg_tys ? farg_tys.screen_name(nil, self) : "(unknown)"
|
2071
2184
|
ret_ty = ret_ty.screen_name(self)
|
2072
2185
|
ret_ty = (ret_ty.include?("|") ? "(#{ ret_ty })" : ret_ty) # XXX?
|
2073
2186
|
|
@@ -2079,7 +2192,7 @@ module TypeProf
|
|
2079
2192
|
farg_tys = @method_signatures[ctx]
|
2080
2193
|
ret_ty = @return_values[ctx] || Type.bot
|
2081
2194
|
|
2082
|
-
farg_tys = farg_tys.screen_name(self)
|
2195
|
+
farg_tys = farg_tys.screen_name(ctx.iseq, self)
|
2083
2196
|
ret_ty = ret_ty.screen_name(self)
|
2084
2197
|
ret_ty = (ret_ty.include?("|") ? "(#{ ret_ty })" : ret_ty) # XXX?
|
2085
2198
|
"#{ (farg_tys.empty? ? "" : "#{ farg_tys } ") }-> #{ ret_ty }"
|