raap 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +29 -0
- data/README.md +12 -1
- data/Rakefile +10 -1
- data/exe/raap +3 -1
- data/lib/raap/bind_call.rb +18 -6
- data/lib/raap/cli.rb +188 -118
- data/lib/raap/function_type.rb +14 -10
- data/lib/raap/method_property.rb +60 -28
- data/lib/raap/method_type.rb +13 -6
- data/lib/raap/minitest.rb +7 -3
- data/lib/raap/rbs.rb +19 -0
- data/lib/raap/result.rb +84 -8
- data/lib/raap/sized.rb +2 -0
- data/lib/raap/symbolic_caller.rb +38 -26
- data/lib/raap/type.rb +85 -69
- data/lib/raap/type_substitution.rb +2 -1
- data/lib/raap/value/interface.rb +15 -7
- data/lib/raap/value/intersection.rb +22 -10
- data/lib/raap/value/module.rb +46 -7
- data/lib/raap/value/variable.rb +10 -1
- data/lib/raap/version.rb +1 -1
- data/lib/raap.rb +3 -2
- data/public/jacket.webp +0 -0
- data/rbs_collection.lock.yaml +61 -1
- data/rbs_collection.yaml +0 -1
- data/sig/raap.rbs +64 -35
- data/sig/shims.rbs +4 -0
- metadata +10 -9
data/lib/raap/type.rb
CHANGED
@@ -13,25 +13,37 @@ module RaaP
|
|
13
13
|
|
14
14
|
def self.positive_float
|
15
15
|
x = Random.rand
|
16
|
-
x / Math.sqrt(1 - x * x)
|
16
|
+
x / Math.sqrt(1 - (x * x))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
GENERATORS = {}
|
21
21
|
SIMPLE_SOURCE = ('a'..'z').to_a << '_'
|
22
|
-
RECURSION = Hash.new { |h, k| h[k] = { count: 0, logged: false } }
|
23
22
|
|
24
23
|
# Type.register "::Integer::positive" { sized { |size| size } }
|
25
24
|
def self.register(type_name, &block)
|
26
25
|
raise ArgumentError, "block is required" unless block
|
26
|
+
|
27
27
|
GENERATORS[type_name] = __skip__ = block
|
28
28
|
end
|
29
29
|
|
30
|
+
def self.random
|
31
|
+
Type.new("Integer | Float | Rational | Complex | String | Symbol | bool | Encoding | BasicObject | nil | Time")
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.random_without_basic_object
|
35
|
+
random.tap do |r|
|
36
|
+
# @type var rtype: ::RBS::Types::Union
|
37
|
+
rtype = r.type
|
38
|
+
rtype.types.reject! { |t| t.to_s == "BasicObject" }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
# Special class case
|
31
43
|
register("::Array") do
|
32
|
-
|
33
|
-
t =
|
34
|
-
array(
|
44
|
+
instance = __skip__ = type
|
45
|
+
t = instance.args[0] ? Type.new(instance.args[0], range:) : Type.random
|
46
|
+
array(t)
|
35
47
|
end
|
36
48
|
register("::Binding") { sized { binding } }
|
37
49
|
register("::Complex") { complex }
|
@@ -40,14 +52,10 @@ module RaaP
|
|
40
52
|
register("::FalseClass") { sized { false } }
|
41
53
|
register("::Float") { float }
|
42
54
|
register("::Hash") do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
v = _type.args[1] || 'untyped'
|
48
|
-
[Type.new(k).pick(size: size), Type.new(v).pick(size: size)]
|
49
|
-
end
|
50
|
-
end
|
55
|
+
instance = __skip__ = type
|
56
|
+
key = instance.args[0] ? Type.new(instance.args[0]) : Type.random_without_basic_object
|
57
|
+
value = instance.args[1] ? Type.new(instance.args[1]) : Type.random
|
58
|
+
dict(key, value)
|
51
59
|
end
|
52
60
|
register("::Integer") { integer }
|
53
61
|
register("::IO") { sized { $stdout } }
|
@@ -55,11 +63,11 @@ module RaaP
|
|
55
63
|
register("::NilClass") { sized { nil } }
|
56
64
|
register("::Proc") { sized { Proc.new {} } }
|
57
65
|
register("::Rational") { rational }
|
58
|
-
register("::Regexp") { sized { |size| Regexp.new(string.pick(size:
|
66
|
+
register("::Regexp") { sized { |size| Regexp.new(string.pick(size:)) } }
|
59
67
|
register("::String") { string }
|
60
68
|
register("::Struct") { sized { Struct.new(:foo, :bar).new } }
|
61
69
|
register("::Symbol") { symbol }
|
62
|
-
register("::Time") { sized { Time
|
70
|
+
register("::Time") { sized { [:call, Time, :now, [], {}, nil] } }
|
63
71
|
register("::TrueClass") { sized { true } }
|
64
72
|
register("::UnboundMethod") { sized { temp_method_object.unbind } }
|
65
73
|
|
@@ -79,15 +87,18 @@ module RaaP
|
|
79
87
|
|
80
88
|
def sized(&block)
|
81
89
|
Sized.new(&block).tap do |sized|
|
82
|
-
if s = @such_that
|
90
|
+
if (s = @such_that)
|
83
91
|
sized.such_that(&s)
|
84
92
|
end
|
85
93
|
end
|
86
94
|
end
|
87
95
|
|
88
|
-
def pick(size: 10
|
89
|
-
|
90
|
-
|
96
|
+
def pick(size: 10)
|
97
|
+
to_symbolic_caller(size:).eval
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_symbolic_caller(size: 10)
|
101
|
+
SymbolicCaller.new(to_symbolic_call(size:))
|
91
102
|
end
|
92
103
|
|
93
104
|
def to_symbolic_call(size: 10)
|
@@ -96,15 +107,23 @@ module RaaP
|
|
96
107
|
|
97
108
|
case type
|
98
109
|
when ::RBS::Types::Tuple
|
99
|
-
type.types.map { |t| Type.new(t).
|
110
|
+
type.types.map { |t| Type.new(t).to_symbolic_call(size:) }
|
100
111
|
when ::RBS::Types::Union
|
101
|
-
type.types.sample&.then { |t| Type.new(t).
|
112
|
+
type.types.sample&.then { |t| Type.new(t).to_symbolic_call(size:) }
|
102
113
|
when ::RBS::Types::Intersection
|
103
|
-
|
114
|
+
if type.free_variables.empty?
|
115
|
+
[:call, Value::Intersection, :new, [type.to_s], { size: }, nil]
|
116
|
+
else
|
117
|
+
[:call, Value::Intersection, :new, [type], { size: }, nil]
|
118
|
+
end
|
104
119
|
when ::RBS::Types::Interface
|
105
|
-
|
120
|
+
if type.free_variables.empty?
|
121
|
+
[:call, Value::Interface, :new, [type.to_s], { size: }, nil]
|
122
|
+
else
|
123
|
+
[:call, Value::Interface, :new, [type], { size: }, nil]
|
124
|
+
end
|
106
125
|
when ::RBS::Types::Variable
|
107
|
-
[:call, Value::Variable, :new, [type], {}, nil]
|
126
|
+
[:call, Value::Variable, :new, [type.to_s], {}, nil]
|
108
127
|
when ::RBS::Types::Bases::Void
|
109
128
|
[:call, Value::Void, :new, [], {}, nil]
|
110
129
|
when ::RBS::Types::Bases::Top
|
@@ -113,13 +132,13 @@ module RaaP
|
|
113
132
|
[:call, Value::Bottom, :new, [], {}, nil]
|
114
133
|
when ::RBS::Types::Optional
|
115
134
|
case Random.rand(2)
|
116
|
-
in 0 then Type.new(type.type).
|
135
|
+
in 0 then Type.new(type.type).to_symbolic_call(size: size / 2)
|
117
136
|
in 1 then nil
|
118
137
|
end
|
119
138
|
when ::RBS::Types::Alias
|
120
139
|
case gen = GENERATORS[type.name.absolute!.to_s]
|
121
140
|
in Proc then instance_exec(&gen)
|
122
|
-
in nil then Type.new(RBS.builder.expand_alias2(type.name, type.args)).
|
141
|
+
in nil then Type.new(RBS.builder.expand_alias2(type.name, type.args)).to_symbolic_call(size:)
|
123
142
|
end
|
124
143
|
when ::RBS::Types::Bases::Class
|
125
144
|
raise "cannot resolve `class` type"
|
@@ -131,29 +150,29 @@ module RaaP
|
|
131
150
|
Object.const_get(type.name.to_s)
|
132
151
|
when ::RBS::Types::ClassInstance
|
133
152
|
case gen = GENERATORS[type.name.absolute!.to_s]
|
134
|
-
in Proc then instance_exec(&gen).pick(size:
|
135
|
-
in nil then
|
153
|
+
in Proc then instance_exec(&gen).pick(size:)
|
154
|
+
in nil then to_symbolic_call_from_initialize(type, size:)
|
136
155
|
end
|
137
156
|
when ::RBS::Types::Record
|
138
|
-
type.fields.transform_values { |t| Type.new(t).
|
157
|
+
type.fields.transform_values { |t| Type.new(t).to_symbolic_call(size: size / 2) }
|
139
158
|
when ::RBS::Types::Proc
|
140
|
-
Proc.new { Type.new(type.type.return_type).
|
159
|
+
Proc.new { Type.new(type.type.return_type).to_symbolic_call(size:) }
|
141
160
|
when ::RBS::Types::Literal
|
142
161
|
type.literal
|
143
162
|
when ::RBS::Types::Bases::Bool
|
144
|
-
bool.pick(size:
|
163
|
+
bool.pick(size:)
|
145
164
|
when ::RBS::Types::Bases::Any
|
146
|
-
|
165
|
+
Type.random.to_symbolic_call(size:)
|
147
166
|
when ::RBS::Types::Bases::Nil
|
148
167
|
nil
|
149
168
|
else
|
150
|
-
raise "not implemented #{type
|
169
|
+
raise "not implemented #{type}"
|
151
170
|
end
|
152
171
|
end
|
153
172
|
|
154
173
|
private
|
155
174
|
|
156
|
-
def
|
175
|
+
def to_symbolic_call_from_initialize(type, size:)
|
157
176
|
type_name = type.name.absolute!
|
158
177
|
const = Object.const_get(type_name.to_s)
|
159
178
|
definition = RBS.builder.build_singleton(type_name)
|
@@ -163,13 +182,12 @@ module RaaP
|
|
163
182
|
rbs_method_type = snew.method_types.sample or raise
|
164
183
|
type_params = definition.type_params_decl.concat(rbs_method_type.type_params.drop(definition.type_params_decl.length))
|
165
184
|
ts = TypeSubstitution.new(type_params, type.args)
|
166
|
-
maped_rbs_method_type = rbs_method_type
|
167
185
|
maped_rbs_method_type = ts.method_type_sub(rbs_method_type)
|
168
186
|
method_type = MethodType.new(maped_rbs_method_type)
|
169
187
|
|
170
188
|
begin
|
171
|
-
try(times: 5, size:
|
172
|
-
args, kwargs, block = method_type.
|
189
|
+
try(times: 5, size:) do |size|
|
190
|
+
args, kwargs, block = method_type.arguments_to_symbolic_call(size:)
|
173
191
|
[:call, const, :new, args, kwargs, block]
|
174
192
|
end
|
175
193
|
rescue
|
@@ -177,7 +195,7 @@ module RaaP
|
|
177
195
|
raise
|
178
196
|
end
|
179
197
|
else
|
180
|
-
[:call, Value::Module, :new, [type], {}, nil]
|
198
|
+
[:call, Value::Module, :new, [type.to_s], { size: }, nil]
|
181
199
|
end
|
182
200
|
end
|
183
201
|
|
@@ -218,7 +236,7 @@ module RaaP
|
|
218
236
|
end
|
219
237
|
|
220
238
|
def integer
|
221
|
-
sized { |size| float.pick(size:
|
239
|
+
sized { |size| float.pick(size:).round }
|
222
240
|
end
|
223
241
|
|
224
242
|
def none_zero_integer
|
@@ -231,9 +249,9 @@ module RaaP
|
|
231
249
|
in nil, nil
|
232
250
|
Arithmetic.float * size
|
233
251
|
in nil, high
|
234
|
-
high - Arithmetic.positive_float * size
|
252
|
+
high - (Arithmetic.positive_float * size)
|
235
253
|
in low, nil
|
236
|
-
low + Arithmetic.positive_float * size
|
254
|
+
low + (Arithmetic.positive_float * size)
|
237
255
|
in low, high
|
238
256
|
Random.rand(Range.new(low.to_f, high.to_f, @range.exclude_end?))
|
239
257
|
end.round(2)
|
@@ -242,16 +260,16 @@ module RaaP
|
|
242
260
|
|
243
261
|
def rational
|
244
262
|
sized do |size|
|
245
|
-
a = integer.pick(size:
|
246
|
-
b = none_zero_integer.pick(size:
|
263
|
+
a = integer.pick(size:)
|
264
|
+
b = none_zero_integer.pick(size:)
|
247
265
|
[:call, Kernel, :Rational, [a, b], {}, nil]
|
248
266
|
end
|
249
267
|
end
|
250
268
|
|
251
269
|
def complex
|
252
270
|
sized do |size|
|
253
|
-
a = integer.pick(size:
|
254
|
-
b = none_zero_integer.pick(size:
|
271
|
+
a = integer.pick(size:)
|
272
|
+
b = none_zero_integer.pick(size:)
|
255
273
|
[:call, Kernel, :Complex, [a, b], {}, nil]
|
256
274
|
end
|
257
275
|
end
|
@@ -262,13 +280,11 @@ module RaaP
|
|
262
280
|
+""
|
263
281
|
else
|
264
282
|
case [@range.begin, @range.end]
|
265
|
-
in nil, nil
|
283
|
+
in [nil, nil]
|
266
284
|
size.times.map { SIMPLE_SOURCE.sample }.join
|
267
|
-
in nil, _
|
285
|
+
in [nil, _] | [_, nil]
|
268
286
|
raise "Should set range.begin and range.end"
|
269
|
-
in
|
270
|
-
raise "Should set range.begin and range.end"
|
271
|
-
in s, e
|
287
|
+
in [s, e]
|
272
288
|
a = (s..e).to_a
|
273
289
|
size.times.map { a.sample }.join
|
274
290
|
end
|
@@ -278,14 +294,28 @@ module RaaP
|
|
278
294
|
|
279
295
|
def symbol
|
280
296
|
sized do |size|
|
281
|
-
string.pick(size:
|
297
|
+
string.pick(size:).to_sym
|
282
298
|
end
|
283
299
|
end
|
284
300
|
|
285
301
|
def array(type)
|
286
302
|
sized do |size|
|
287
|
-
Array.new(integer.pick(size:
|
288
|
-
type.
|
303
|
+
Array.new(integer.pick(size:).abs) do
|
304
|
+
type.to_symbolic_call(size: size / 2)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
# Create Hash object. But not `hash`.
|
310
|
+
# Avoid to use `hash` since core method name
|
311
|
+
def dict(key_type, value_type)
|
312
|
+
sized do |size|
|
313
|
+
csize = size / 2
|
314
|
+
Array.new(integer.pick(size:).abs).to_h do
|
315
|
+
[
|
316
|
+
key_type.to_symbolic_call(size: csize),
|
317
|
+
value_type.to_symbolic_call(size: csize)
|
318
|
+
]
|
289
319
|
end
|
290
320
|
end
|
291
321
|
end
|
@@ -293,7 +323,7 @@ module RaaP
|
|
293
323
|
def encoding
|
294
324
|
sized do
|
295
325
|
e = Encoding.list.sample or raise
|
296
|
-
[:call, Encoding, :find, [e.name], {}
|
326
|
+
[:call, Encoding, :find, [e.name], {}, nil]
|
297
327
|
end
|
298
328
|
end
|
299
329
|
|
@@ -303,24 +333,10 @@ module RaaP
|
|
303
333
|
end
|
304
334
|
end
|
305
335
|
|
306
|
-
def untyped
|
307
|
-
case Random.rand(9)
|
308
|
-
in 0 then integer
|
309
|
-
in 1 then float
|
310
|
-
in 2 then rational
|
311
|
-
in 3 then complex
|
312
|
-
in 4 then string
|
313
|
-
in 5 then symbol
|
314
|
-
in 6 then bool
|
315
|
-
in 7 then encoding
|
316
|
-
in 8 then sized { [:call, BasicObject, :new, [], {}, nil] }
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
336
|
def temp_method_object
|
321
337
|
o = Object.new
|
322
338
|
m = 6.times.map { SIMPLE_SOURCE.sample }.join
|
323
|
-
o.define_singleton_method(m) {
|
339
|
+
o.define_singleton_method(m) {}
|
324
340
|
o.method(m)
|
325
341
|
end
|
326
342
|
end
|
@@ -14,7 +14,7 @@ module RaaP
|
|
14
14
|
elsif bound.upper_bound
|
15
15
|
[bound.name, bound.upper_bound]
|
16
16
|
else
|
17
|
-
[bound.name, ::RBS::Types::
|
17
|
+
[bound.name, ::RBS::Types::Variable.new(name: bound.name, location: nil)]
|
18
18
|
end
|
19
19
|
end
|
20
20
|
::RBS::Substitution.build(bound_map.keys, bound_map.values)
|
@@ -36,6 +36,7 @@ module RaaP
|
|
36
36
|
if self_type.nil? && instance_type.nil? && class_type.nil?
|
37
37
|
return search
|
38
38
|
end
|
39
|
+
|
39
40
|
search.map_type do |ty|
|
40
41
|
case ty
|
41
42
|
when ::RBS::Types::Bases::Self
|
data/lib/raap/value/interface.rb
CHANGED
@@ -5,22 +5,26 @@ module RaaP
|
|
5
5
|
class Interface < BasicObject
|
6
6
|
def initialize(type, size: 3, self_type: nil, instance_type: nil, class_type: nil)
|
7
7
|
@type = type.is_a?(::String) ? RBS.parse_type(type) : type
|
8
|
+
unless @type.instance_of?(::RBS::Types::Interface)
|
9
|
+
::Kernel.raise ::TypeError, "not an interface type: #{@type}"
|
10
|
+
end
|
8
11
|
@size = size
|
9
12
|
|
10
|
-
definition = RBS.builder.build_interface(@type.name.absolute!)
|
11
|
-
definition.methods.each do |name, method|
|
13
|
+
@definition = RBS.builder.build_interface(@type.name.absolute!)
|
14
|
+
@definition.methods.each do |name, method|
|
12
15
|
method_type = method.method_types.sample or Kernel.raise
|
13
|
-
type_params = definition.type_params_decl.concat(method_type.type_params.drop(definition.type_params_decl.length))
|
16
|
+
type_params = @definition.type_params_decl.concat(method_type.type_params.drop(@definition.type_params_decl.length))
|
14
17
|
ts = TypeSubstitution.new(type_params, @type.args)
|
15
18
|
|
16
19
|
subed_method_type = ts.method_type_sub(method_type, self_type:, instance_type:, class_type:)
|
17
20
|
|
18
|
-
BindCall.define_singleton_method(self, name) do
|
19
|
-
@
|
21
|
+
BindCall.define_singleton_method(self, name) do |*_, &b|
|
22
|
+
# @type var b: Proc?
|
23
|
+
@fixed_return_value ||= Type.new(subed_method_type.type.return_type).pick(size:)
|
20
24
|
if subed_method_type.block
|
21
25
|
@fixed_block_arguments ||= size.times.map do
|
22
26
|
fun_type = FunctionType.new(subed_method_type.block.type)
|
23
|
-
fun_type.pick_arguments(size:
|
27
|
+
fun_type.pick_arguments(size:)
|
24
28
|
end
|
25
29
|
else
|
26
30
|
@fixed_block_arguments = []
|
@@ -38,12 +42,16 @@ module RaaP
|
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
45
|
+
def respond_to?(name, _include_all = false)
|
46
|
+
@definition.methods.has_key?(name.to_sym)
|
47
|
+
end
|
48
|
+
|
41
49
|
def class
|
42
50
|
Interface
|
43
51
|
end
|
44
52
|
|
45
53
|
def inspect
|
46
|
-
"#<interface @type=#{@type
|
54
|
+
"#<interface @type=#{@type} @methods=#{@definition.methods.keys} @size=#{@size}>"
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
@@ -3,14 +3,17 @@
|
|
3
3
|
module RaaP
|
4
4
|
module Value
|
5
5
|
class Intersection < BasicObject
|
6
|
-
def initialize(type, size:)
|
7
|
-
@type = type
|
8
|
-
@
|
6
|
+
def initialize(type, size: 3)
|
7
|
+
@type = type.is_a?(::String) ? RBS.parse_type(type) : type
|
8
|
+
unless @type.instance_of?(::RBS::Types::Intersection)
|
9
|
+
::Kernel.raise ::TypeError, "not an intersection type: #{@type}"
|
10
|
+
end
|
11
|
+
@children = @type.types.map { |t| Type.new(t).pick(size:) }
|
9
12
|
@size = size
|
10
13
|
end
|
11
14
|
|
12
15
|
def inspect
|
13
|
-
"#<intersection @type=#{@type.to_s.inspect} @size=#{@size.inspect}>"
|
16
|
+
"#<intersection @type.to_s=#{@type.to_s.inspect} @size=#{@size.inspect}>"
|
14
17
|
end
|
15
18
|
|
16
19
|
def class
|
@@ -18,16 +21,25 @@ module RaaP
|
|
18
21
|
end
|
19
22
|
|
20
23
|
def method_missing(name, *args, **kwargs, &block)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
if respond_to?(name)
|
25
|
+
@children.each do |child|
|
26
|
+
if BindCall.respond_to?(child, name)
|
27
|
+
return child.__send__(name, *args, **kwargs, &block)
|
28
|
+
end
|
24
29
|
end
|
30
|
+
::Kernel.raise
|
31
|
+
else
|
32
|
+
super
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
28
|
-
def respond_to?(
|
29
|
-
@children.any? do |
|
30
|
-
BindCall.
|
36
|
+
def respond_to?(name, include_all = false)
|
37
|
+
@children.any? do |child|
|
38
|
+
if BindCall.instance_of?(child, ::BasicObject)
|
39
|
+
BindCall.respond_to?(child, name, include_all)
|
40
|
+
else
|
41
|
+
child.respond_to?(name, include_all)
|
42
|
+
end
|
31
43
|
end
|
32
44
|
end
|
33
45
|
end
|
data/lib/raap/value/module.rb
CHANGED
@@ -2,16 +2,55 @@ module RaaP
|
|
2
2
|
module Value
|
3
3
|
# FIXME: consider self_types
|
4
4
|
# HINT: intersection?
|
5
|
-
class Module
|
6
|
-
|
5
|
+
class Module < BasicObject
|
6
|
+
def initialize(type, size: 3)
|
7
|
+
@type = type.is_a?(::String) ? ::RaaP::RBS.parse_type(type) : type
|
8
|
+
@size = size
|
9
|
+
unless @type.instance_of?(::RBS::Types::ClassInstance)
|
10
|
+
::Kernel.raise ::TypeError, "not a module type: #{@type}"
|
11
|
+
end
|
7
12
|
|
8
|
-
|
9
|
-
@
|
10
|
-
|
11
|
-
|
13
|
+
one_instance_ancestors = ::RaaP::RBS.builder.ancestor_builder.one_instance_ancestors(@type.name.absolute!).self_types
|
14
|
+
@self_type = if one_instance_ancestors.nil? || one_instance_ancestors.empty?
|
15
|
+
::Object.new
|
16
|
+
else
|
17
|
+
one_instance_ancestors.map do |a_instance|
|
18
|
+
if a_instance.args.empty?
|
19
|
+
# : BasicObject
|
20
|
+
a_instance.name.absolute!.to_s
|
21
|
+
else
|
22
|
+
# : _Each[Integer]
|
23
|
+
args = a_instance.args.zip(@type.args).map do |_var, instance|
|
24
|
+
if instance
|
25
|
+
instance.to_s
|
26
|
+
else
|
27
|
+
'untyped'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
"#{a_instance.name}[#{args.map(&:to_s).join(', ')}]"
|
31
|
+
end
|
32
|
+
end.then do |ts|
|
33
|
+
ts << 'Object' if !ts.include?('::BasicObject')
|
34
|
+
Type.new(ts.join(' & ')).pick(size:)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
const = ::Object.const_get(@type.name.absolute!.to_s)
|
38
|
+
BindCall.extend(@self_type, const)
|
12
39
|
end
|
13
40
|
|
14
|
-
def
|
41
|
+
def method_missing(name, *args, **kwargs, &block)
|
42
|
+
@self_type.__send__(name, *args, **kwargs, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def respond_to?(name, include_all = false)
|
46
|
+
if BindCall.instance_of?(@self_type, ::BasicObject)
|
47
|
+
BindCall.respond_to?(@self_type, name, include_all)
|
48
|
+
else
|
49
|
+
@self_type.respond_to?(name, include_all)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def inspect = "#<module #{@type} : #{BindCall.class(@self_type)} size=#{@size}>"
|
15
54
|
def class = Value::Module
|
16
55
|
end
|
17
56
|
end
|
data/lib/raap/value/variable.rb
CHANGED
@@ -4,7 +4,16 @@ module RaaP
|
|
4
4
|
attr_reader :type
|
5
5
|
|
6
6
|
def initialize(type)
|
7
|
-
@type =
|
7
|
+
@type =
|
8
|
+
if type.respond_to?(:to_sym)
|
9
|
+
# @type var type: String | Symbol
|
10
|
+
::RBS::Types::Variable.new(name: type.to_sym, location: nil)
|
11
|
+
else
|
12
|
+
type
|
13
|
+
end
|
14
|
+
unless @type.instance_of?(::RBS::Types::Variable)
|
15
|
+
::Kernel.raise ::TypeError, "not a variable type: #{@type}"
|
16
|
+
end
|
8
17
|
end
|
9
18
|
|
10
19
|
def inspect = "#<var #{type}>"
|
data/lib/raap/version.rb
CHANGED
data/lib/raap.rb
CHANGED
@@ -15,7 +15,9 @@ module RaaP
|
|
15
15
|
attr_accessor :logger
|
16
16
|
end
|
17
17
|
|
18
|
-
self.logger = ::Logger.new($stdout
|
18
|
+
self.logger = ::Logger.new($stdout, formatter: proc { |severity, _datetime, _progname, msg|
|
19
|
+
"[RaaP] #{severity}: #{msg}\n"
|
20
|
+
})
|
19
21
|
self.logger.level = ::Logger::INFO
|
20
22
|
|
21
23
|
autoload :BindCall, "raap/bind_call"
|
@@ -23,7 +25,6 @@ module RaaP
|
|
23
25
|
autoload :FunctionType, "raap/function_type"
|
24
26
|
autoload :MethodProperty, "raap/method_property"
|
25
27
|
autoload :MethodType, "raap/method_type"
|
26
|
-
autoload :Minitest, "raap/minitest"
|
27
28
|
autoload :RBS, "raap/rbs"
|
28
29
|
autoload :Result, "raap/result"
|
29
30
|
autoload :Sized, "raap/sized"
|
data/public/jacket.webp
ADDED
Binary file
|
data/rbs_collection.lock.yaml
CHANGED
@@ -5,10 +5,58 @@ gems:
|
|
5
5
|
version: '0'
|
6
6
|
source:
|
7
7
|
type: stdlib
|
8
|
+
- name: activesupport
|
9
|
+
version: '7.0'
|
10
|
+
source:
|
11
|
+
type: git
|
12
|
+
name: ruby/gem_rbs_collection
|
13
|
+
revision: bc4cbee282cfb013be8c44a3fe7a374491492400
|
14
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
15
|
+
repo_dir: gems
|
16
|
+
- name: base64
|
17
|
+
version: '0'
|
18
|
+
source:
|
19
|
+
type: stdlib
|
20
|
+
- name: bigdecimal
|
21
|
+
version: '0'
|
22
|
+
source:
|
23
|
+
type: stdlib
|
24
|
+
- name: concurrent-ruby
|
25
|
+
version: '1.1'
|
26
|
+
source:
|
27
|
+
type: git
|
28
|
+
name: ruby/gem_rbs_collection
|
29
|
+
revision: bc4cbee282cfb013be8c44a3fe7a374491492400
|
30
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
31
|
+
repo_dir: gems
|
32
|
+
- name: connection_pool
|
33
|
+
version: '2.4'
|
34
|
+
source:
|
35
|
+
type: git
|
36
|
+
name: ruby/gem_rbs_collection
|
37
|
+
revision: bc4cbee282cfb013be8c44a3fe7a374491492400
|
38
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
39
|
+
repo_dir: gems
|
40
|
+
- name: date
|
41
|
+
version: '0'
|
42
|
+
source:
|
43
|
+
type: stdlib
|
44
|
+
- name: erb
|
45
|
+
version: '0'
|
46
|
+
source:
|
47
|
+
type: stdlib
|
8
48
|
- name: fileutils
|
9
49
|
version: '0'
|
10
50
|
source:
|
11
51
|
type: stdlib
|
52
|
+
- name: i18n
|
53
|
+
version: '1.10'
|
54
|
+
source:
|
55
|
+
type: git
|
56
|
+
name: ruby/gem_rbs_collection
|
57
|
+
revision: bc4cbee282cfb013be8c44a3fe7a374491492400
|
58
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
59
|
+
repo_dir: gems
|
12
60
|
- name: io-console
|
13
61
|
version: '0'
|
14
62
|
source:
|
@@ -46,7 +94,7 @@ gems:
|
|
46
94
|
source:
|
47
95
|
type: git
|
48
96
|
name: ruby/gem_rbs_collection
|
49
|
-
revision:
|
97
|
+
revision: bc4cbee282cfb013be8c44a3fe7a374491492400
|
50
98
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
51
99
|
repo_dir: gems
|
52
100
|
- name: rbs
|
@@ -57,6 +105,18 @@ gems:
|
|
57
105
|
version: '0'
|
58
106
|
source:
|
59
107
|
type: stdlib
|
108
|
+
- name: securerandom
|
109
|
+
version: '0'
|
110
|
+
source:
|
111
|
+
type: stdlib
|
112
|
+
- name: singleton
|
113
|
+
version: '0'
|
114
|
+
source:
|
115
|
+
type: stdlib
|
116
|
+
- name: time
|
117
|
+
version: '0'
|
118
|
+
source:
|
119
|
+
type: stdlib
|
60
120
|
- name: timeout
|
61
121
|
version: '0'
|
62
122
|
source:
|