sorbet-runtime 0.5.6305 → 0.5.6324
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/configuration.rb +9 -1
- data/lib/types/private/methods/_methods.rb +3 -4
- data/lib/types/private/methods/call_validation.rb +7 -785
- data/lib/types/private/methods/call_validation_2_6.rb +781 -0
- data/lib/types/private/methods/call_validation_2_7.rb +781 -0
- data/lib/types/types/typed_enumerable.rb +5 -1
- data/lib/types/utils.rb +7 -0
- metadata +5 -3
@@ -0,0 +1,781 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: false
|
3
|
+
|
4
|
+
# DO NOT EDIT. This file is autogenerated. To regenerate, run:
|
5
|
+
#
|
6
|
+
# bazel test //gems/sorbet-runtime:update_call_validation
|
7
|
+
|
8
|
+
module T::Private::Methods::CallValidation
|
9
|
+
def self.create_validator_method_fast(mod, original_method, method_sig)
|
10
|
+
if method_sig.return_type.is_a?(T::Private::Types::Void)
|
11
|
+
raise 'Should have used create_validator_procedure_fast'
|
12
|
+
end
|
13
|
+
# trampoline to reduce stack frame size
|
14
|
+
if method_sig.arg_types.empty?
|
15
|
+
create_validator_method_fast0(mod, original_method, method_sig, method_sig.return_type.raw_type)
|
16
|
+
elsif method_sig.arg_types.length == 1
|
17
|
+
create_validator_method_fast1(mod, original_method, method_sig, method_sig.return_type.raw_type,
|
18
|
+
method_sig.arg_types[0][1].raw_type)
|
19
|
+
elsif method_sig.arg_types.length == 2
|
20
|
+
create_validator_method_fast2(mod, original_method, method_sig, method_sig.return_type.raw_type,
|
21
|
+
method_sig.arg_types[0][1].raw_type,
|
22
|
+
method_sig.arg_types[1][1].raw_type)
|
23
|
+
elsif method_sig.arg_types.length == 3
|
24
|
+
create_validator_method_fast3(mod, original_method, method_sig, method_sig.return_type.raw_type,
|
25
|
+
method_sig.arg_types[0][1].raw_type,
|
26
|
+
method_sig.arg_types[1][1].raw_type,
|
27
|
+
method_sig.arg_types[2][1].raw_type)
|
28
|
+
elsif method_sig.arg_types.length == 4
|
29
|
+
create_validator_method_fast4(mod, original_method, method_sig, method_sig.return_type.raw_type,
|
30
|
+
method_sig.arg_types[0][1].raw_type,
|
31
|
+
method_sig.arg_types[1][1].raw_type,
|
32
|
+
method_sig.arg_types[2][1].raw_type,
|
33
|
+
method_sig.arg_types[3][1].raw_type)
|
34
|
+
else
|
35
|
+
raise 'should not happen'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.create_validator_method_fast0(mod, original_method, method_sig, return_type)
|
40
|
+
mod.send(:define_method, method_sig.method_name) do |&blk|
|
41
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
42
|
+
# reduce number of allocations that happen here.
|
43
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
44
|
+
T::Profile.typecheck_sample_attempts -= 1
|
45
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
46
|
+
if should_sample
|
47
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
48
|
+
T::Profile.typecheck_samples += 1
|
49
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
50
|
+
end
|
51
|
+
|
52
|
+
if should_sample
|
53
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
54
|
+
end
|
55
|
+
|
56
|
+
# The following line breaks are intentional to show nice pry message
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
# PRY note:
|
68
|
+
# this code is sig validation code.
|
69
|
+
# Please issue `finish` to step out of it
|
70
|
+
|
71
|
+
return_value = original_method.bind_call(self, &blk)
|
72
|
+
if should_sample
|
73
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
74
|
+
end
|
75
|
+
|
76
|
+
unless return_value.is_a?(return_type)
|
77
|
+
message = method_sig.return_type.error_message_for_obj(return_value)
|
78
|
+
if message
|
79
|
+
CallValidation.report_error(
|
80
|
+
method_sig,
|
81
|
+
message,
|
82
|
+
'Return value',
|
83
|
+
nil,
|
84
|
+
method_sig.return_type,
|
85
|
+
return_value,
|
86
|
+
caller_offset: -1
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if should_sample
|
91
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
92
|
+
end
|
93
|
+
return_value
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.create_validator_method_fast1(mod, original_method, method_sig, return_type, arg0_type)
|
98
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, &blk|
|
99
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
100
|
+
# reduce number of allocations that happen here.
|
101
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
102
|
+
T::Profile.typecheck_sample_attempts -= 1
|
103
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
104
|
+
if should_sample
|
105
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
106
|
+
T::Profile.typecheck_samples += 1
|
107
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
108
|
+
end
|
109
|
+
|
110
|
+
unless arg0.is_a?(arg0_type)
|
111
|
+
CallValidation.report_error(
|
112
|
+
method_sig,
|
113
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
114
|
+
'Parameter',
|
115
|
+
method_sig.arg_types[0][0],
|
116
|
+
arg0_type,
|
117
|
+
arg0,
|
118
|
+
caller_offset: -1
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
if should_sample
|
123
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
124
|
+
end
|
125
|
+
|
126
|
+
# The following line breaks are intentional to show nice pry message
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
# PRY note:
|
138
|
+
# this code is sig validation code.
|
139
|
+
# Please issue `finish` to step out of it
|
140
|
+
|
141
|
+
return_value = original_method.bind_call(self, arg0, &blk)
|
142
|
+
if should_sample
|
143
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
144
|
+
end
|
145
|
+
|
146
|
+
unless return_value.is_a?(return_type)
|
147
|
+
message = method_sig.return_type.error_message_for_obj(return_value)
|
148
|
+
if message
|
149
|
+
CallValidation.report_error(
|
150
|
+
method_sig,
|
151
|
+
message,
|
152
|
+
'Return value',
|
153
|
+
nil,
|
154
|
+
method_sig.return_type,
|
155
|
+
return_value,
|
156
|
+
caller_offset: -1
|
157
|
+
)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
if should_sample
|
161
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
162
|
+
end
|
163
|
+
return_value
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.create_validator_method_fast2(mod, original_method, method_sig, return_type, arg0_type, arg1_type)
|
168
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, arg1, &blk|
|
169
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
170
|
+
# reduce number of allocations that happen here.
|
171
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
172
|
+
T::Profile.typecheck_sample_attempts -= 1
|
173
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
174
|
+
if should_sample
|
175
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
176
|
+
T::Profile.typecheck_samples += 1
|
177
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
178
|
+
end
|
179
|
+
|
180
|
+
unless arg0.is_a?(arg0_type)
|
181
|
+
CallValidation.report_error(
|
182
|
+
method_sig,
|
183
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
184
|
+
'Parameter',
|
185
|
+
method_sig.arg_types[0][0],
|
186
|
+
arg0_type,
|
187
|
+
arg0,
|
188
|
+
caller_offset: -1
|
189
|
+
)
|
190
|
+
end
|
191
|
+
|
192
|
+
unless arg1.is_a?(arg1_type)
|
193
|
+
CallValidation.report_error(
|
194
|
+
method_sig,
|
195
|
+
method_sig.arg_types[1][1].error_message_for_obj(arg1),
|
196
|
+
'Parameter',
|
197
|
+
method_sig.arg_types[1][0],
|
198
|
+
arg1_type,
|
199
|
+
arg1,
|
200
|
+
caller_offset: -1
|
201
|
+
)
|
202
|
+
end
|
203
|
+
|
204
|
+
if should_sample
|
205
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
206
|
+
end
|
207
|
+
|
208
|
+
# The following line breaks are intentional to show nice pry message
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
# PRY note:
|
220
|
+
# this code is sig validation code.
|
221
|
+
# Please issue `finish` to step out of it
|
222
|
+
|
223
|
+
return_value = original_method.bind_call(self, arg0, arg1, &blk)
|
224
|
+
if should_sample
|
225
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
226
|
+
end
|
227
|
+
|
228
|
+
unless return_value.is_a?(return_type)
|
229
|
+
message = method_sig.return_type.error_message_for_obj(return_value)
|
230
|
+
if message
|
231
|
+
CallValidation.report_error(
|
232
|
+
method_sig,
|
233
|
+
message,
|
234
|
+
'Return value',
|
235
|
+
nil,
|
236
|
+
method_sig.return_type,
|
237
|
+
return_value,
|
238
|
+
caller_offset: -1
|
239
|
+
)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
if should_sample
|
243
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
244
|
+
end
|
245
|
+
return_value
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def self.create_validator_method_fast3(mod, original_method, method_sig, return_type, arg0_type, arg1_type, arg2_type)
|
250
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, &blk|
|
251
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
252
|
+
# reduce number of allocations that happen here.
|
253
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
254
|
+
T::Profile.typecheck_sample_attempts -= 1
|
255
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
256
|
+
if should_sample
|
257
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
258
|
+
T::Profile.typecheck_samples += 1
|
259
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
260
|
+
end
|
261
|
+
|
262
|
+
unless arg0.is_a?(arg0_type)
|
263
|
+
CallValidation.report_error(
|
264
|
+
method_sig,
|
265
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
266
|
+
'Parameter',
|
267
|
+
method_sig.arg_types[0][0],
|
268
|
+
arg0_type,
|
269
|
+
arg0,
|
270
|
+
caller_offset: -1
|
271
|
+
)
|
272
|
+
end
|
273
|
+
|
274
|
+
unless arg1.is_a?(arg1_type)
|
275
|
+
CallValidation.report_error(
|
276
|
+
method_sig,
|
277
|
+
method_sig.arg_types[1][1].error_message_for_obj(arg1),
|
278
|
+
'Parameter',
|
279
|
+
method_sig.arg_types[1][0],
|
280
|
+
arg1_type,
|
281
|
+
arg1,
|
282
|
+
caller_offset: -1
|
283
|
+
)
|
284
|
+
end
|
285
|
+
|
286
|
+
unless arg2.is_a?(arg2_type)
|
287
|
+
CallValidation.report_error(
|
288
|
+
method_sig,
|
289
|
+
method_sig.arg_types[2][1].error_message_for_obj(arg2),
|
290
|
+
'Parameter',
|
291
|
+
method_sig.arg_types[2][0],
|
292
|
+
arg2_type,
|
293
|
+
arg2,
|
294
|
+
caller_offset: -1
|
295
|
+
)
|
296
|
+
end
|
297
|
+
|
298
|
+
if should_sample
|
299
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
300
|
+
end
|
301
|
+
|
302
|
+
# The following line breaks are intentional to show nice pry message
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
# PRY note:
|
314
|
+
# this code is sig validation code.
|
315
|
+
# Please issue `finish` to step out of it
|
316
|
+
|
317
|
+
return_value = original_method.bind_call(self, arg0, arg1, arg2, &blk)
|
318
|
+
if should_sample
|
319
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
320
|
+
end
|
321
|
+
|
322
|
+
unless return_value.is_a?(return_type)
|
323
|
+
message = method_sig.return_type.error_message_for_obj(return_value)
|
324
|
+
if message
|
325
|
+
CallValidation.report_error(
|
326
|
+
method_sig,
|
327
|
+
message,
|
328
|
+
'Return value',
|
329
|
+
nil,
|
330
|
+
method_sig.return_type,
|
331
|
+
return_value,
|
332
|
+
caller_offset: -1
|
333
|
+
)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
if should_sample
|
337
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
338
|
+
end
|
339
|
+
return_value
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
def self.create_validator_method_fast4(mod, original_method, method_sig, return_type, arg0_type, arg1_type, arg2_type, arg3_type)
|
344
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, arg3, &blk|
|
345
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
346
|
+
# reduce number of allocations that happen here.
|
347
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
348
|
+
T::Profile.typecheck_sample_attempts -= 1
|
349
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
350
|
+
if should_sample
|
351
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
352
|
+
T::Profile.typecheck_samples += 1
|
353
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
354
|
+
end
|
355
|
+
|
356
|
+
unless arg0.is_a?(arg0_type)
|
357
|
+
CallValidation.report_error(
|
358
|
+
method_sig,
|
359
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
360
|
+
'Parameter',
|
361
|
+
method_sig.arg_types[0][0],
|
362
|
+
arg0_type,
|
363
|
+
arg0,
|
364
|
+
caller_offset: -1
|
365
|
+
)
|
366
|
+
end
|
367
|
+
|
368
|
+
unless arg1.is_a?(arg1_type)
|
369
|
+
CallValidation.report_error(
|
370
|
+
method_sig,
|
371
|
+
method_sig.arg_types[1][1].error_message_for_obj(arg1),
|
372
|
+
'Parameter',
|
373
|
+
method_sig.arg_types[1][0],
|
374
|
+
arg1_type,
|
375
|
+
arg1,
|
376
|
+
caller_offset: -1
|
377
|
+
)
|
378
|
+
end
|
379
|
+
|
380
|
+
unless arg2.is_a?(arg2_type)
|
381
|
+
CallValidation.report_error(
|
382
|
+
method_sig,
|
383
|
+
method_sig.arg_types[2][1].error_message_for_obj(arg2),
|
384
|
+
'Parameter',
|
385
|
+
method_sig.arg_types[2][0],
|
386
|
+
arg2_type,
|
387
|
+
arg2,
|
388
|
+
caller_offset: -1
|
389
|
+
)
|
390
|
+
end
|
391
|
+
|
392
|
+
unless arg3.is_a?(arg3_type)
|
393
|
+
CallValidation.report_error(
|
394
|
+
method_sig,
|
395
|
+
method_sig.arg_types[3][1].error_message_for_obj(arg3),
|
396
|
+
'Parameter',
|
397
|
+
method_sig.arg_types[3][0],
|
398
|
+
arg3_type,
|
399
|
+
arg3,
|
400
|
+
caller_offset: -1
|
401
|
+
)
|
402
|
+
end
|
403
|
+
|
404
|
+
if should_sample
|
405
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
406
|
+
end
|
407
|
+
|
408
|
+
# The following line breaks are intentional to show nice pry message
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
# PRY note:
|
420
|
+
# this code is sig validation code.
|
421
|
+
# Please issue `finish` to step out of it
|
422
|
+
|
423
|
+
return_value = original_method.bind_call(self, arg0, arg1, arg2, arg3, &blk)
|
424
|
+
if should_sample
|
425
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
426
|
+
end
|
427
|
+
|
428
|
+
unless return_value.is_a?(return_type)
|
429
|
+
message = method_sig.return_type.error_message_for_obj(return_value)
|
430
|
+
if message
|
431
|
+
CallValidation.report_error(
|
432
|
+
method_sig,
|
433
|
+
message,
|
434
|
+
'Return value',
|
435
|
+
nil,
|
436
|
+
method_sig.return_type,
|
437
|
+
return_value,
|
438
|
+
caller_offset: -1
|
439
|
+
)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
if should_sample
|
443
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
444
|
+
end
|
445
|
+
return_value
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
def self.create_validator_procedure_fast(mod, original_method, method_sig)
|
450
|
+
# trampoline to reduce stack frame size
|
451
|
+
if method_sig.arg_types.empty?
|
452
|
+
create_validator_procedure_fast0(mod, original_method, method_sig)
|
453
|
+
elsif method_sig.arg_types.length == 1
|
454
|
+
create_validator_procedure_fast1(mod, original_method, method_sig,
|
455
|
+
method_sig.arg_types[0][1].raw_type)
|
456
|
+
elsif method_sig.arg_types.length == 2
|
457
|
+
create_validator_procedure_fast2(mod, original_method, method_sig,
|
458
|
+
method_sig.arg_types[0][1].raw_type,
|
459
|
+
method_sig.arg_types[1][1].raw_type)
|
460
|
+
elsif method_sig.arg_types.length == 3
|
461
|
+
create_validator_procedure_fast3(mod, original_method, method_sig,
|
462
|
+
method_sig.arg_types[0][1].raw_type,
|
463
|
+
method_sig.arg_types[1][1].raw_type,
|
464
|
+
method_sig.arg_types[2][1].raw_type)
|
465
|
+
elsif method_sig.arg_types.length == 4
|
466
|
+
create_validator_procedure_fast4(mod, original_method, method_sig,
|
467
|
+
method_sig.arg_types[0][1].raw_type,
|
468
|
+
method_sig.arg_types[1][1].raw_type,
|
469
|
+
method_sig.arg_types[2][1].raw_type,
|
470
|
+
method_sig.arg_types[3][1].raw_type)
|
471
|
+
else
|
472
|
+
raise 'should not happen'
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
def self.create_validator_procedure_fast0(mod, original_method, method_sig)
|
477
|
+
mod.send(:define_method, method_sig.method_name) do |&blk|
|
478
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
479
|
+
# reduce number of allocations that happen here.
|
480
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
481
|
+
T::Profile.typecheck_sample_attempts -= 1
|
482
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
483
|
+
if should_sample
|
484
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
485
|
+
T::Profile.typecheck_samples += 1
|
486
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
487
|
+
end
|
488
|
+
|
489
|
+
if should_sample
|
490
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
491
|
+
end
|
492
|
+
|
493
|
+
# The following line breaks are intentional to show nice pry message
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
# PRY note:
|
505
|
+
# this code is sig validation code.
|
506
|
+
# Please issue `finish` to step out of it
|
507
|
+
|
508
|
+
original_method.bind_call(self, &blk)
|
509
|
+
T::Private::Types::Void::VOID
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
513
|
+
def self.create_validator_procedure_fast1(mod, original_method, method_sig, arg0_type)
|
514
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, &blk|
|
515
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
516
|
+
# reduce number of allocations that happen here.
|
517
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
518
|
+
T::Profile.typecheck_sample_attempts -= 1
|
519
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
520
|
+
if should_sample
|
521
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
522
|
+
T::Profile.typecheck_samples += 1
|
523
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
524
|
+
end
|
525
|
+
|
526
|
+
unless arg0.is_a?(arg0_type)
|
527
|
+
CallValidation.report_error(
|
528
|
+
method_sig,
|
529
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
530
|
+
'Parameter',
|
531
|
+
method_sig.arg_types[0][0],
|
532
|
+
arg0_type,
|
533
|
+
arg0,
|
534
|
+
caller_offset: -1
|
535
|
+
)
|
536
|
+
end
|
537
|
+
|
538
|
+
if should_sample
|
539
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
540
|
+
end
|
541
|
+
|
542
|
+
# The following line breaks are intentional to show nice pry message
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
# PRY note:
|
554
|
+
# this code is sig validation code.
|
555
|
+
# Please issue `finish` to step out of it
|
556
|
+
|
557
|
+
original_method.bind_call(self, arg0, &blk)
|
558
|
+
T::Private::Types::Void::VOID
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
def self.create_validator_procedure_fast2(mod, original_method, method_sig, arg0_type, arg1_type)
|
563
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, arg1, &blk|
|
564
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
565
|
+
# reduce number of allocations that happen here.
|
566
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
567
|
+
T::Profile.typecheck_sample_attempts -= 1
|
568
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
569
|
+
if should_sample
|
570
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
571
|
+
T::Profile.typecheck_samples += 1
|
572
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
573
|
+
end
|
574
|
+
|
575
|
+
unless arg0.is_a?(arg0_type)
|
576
|
+
CallValidation.report_error(
|
577
|
+
method_sig,
|
578
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
579
|
+
'Parameter',
|
580
|
+
method_sig.arg_types[0][0],
|
581
|
+
arg0_type,
|
582
|
+
arg0,
|
583
|
+
caller_offset: -1
|
584
|
+
)
|
585
|
+
end
|
586
|
+
|
587
|
+
unless arg1.is_a?(arg1_type)
|
588
|
+
CallValidation.report_error(
|
589
|
+
method_sig,
|
590
|
+
method_sig.arg_types[1][1].error_message_for_obj(arg1),
|
591
|
+
'Parameter',
|
592
|
+
method_sig.arg_types[1][0],
|
593
|
+
arg1_type,
|
594
|
+
arg1,
|
595
|
+
caller_offset: -1
|
596
|
+
)
|
597
|
+
end
|
598
|
+
|
599
|
+
if should_sample
|
600
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
601
|
+
end
|
602
|
+
|
603
|
+
# The following line breaks are intentional to show nice pry message
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
|
614
|
+
# PRY note:
|
615
|
+
# this code is sig validation code.
|
616
|
+
# Please issue `finish` to step out of it
|
617
|
+
|
618
|
+
original_method.bind_call(self, arg0, arg1, &blk)
|
619
|
+
T::Private::Types::Void::VOID
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
def self.create_validator_procedure_fast3(mod, original_method, method_sig, arg0_type, arg1_type, arg2_type)
|
624
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, &blk|
|
625
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
626
|
+
# reduce number of allocations that happen here.
|
627
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
628
|
+
T::Profile.typecheck_sample_attempts -= 1
|
629
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
630
|
+
if should_sample
|
631
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
632
|
+
T::Profile.typecheck_samples += 1
|
633
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
634
|
+
end
|
635
|
+
|
636
|
+
unless arg0.is_a?(arg0_type)
|
637
|
+
CallValidation.report_error(
|
638
|
+
method_sig,
|
639
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
640
|
+
'Parameter',
|
641
|
+
method_sig.arg_types[0][0],
|
642
|
+
arg0_type,
|
643
|
+
arg0,
|
644
|
+
caller_offset: -1
|
645
|
+
)
|
646
|
+
end
|
647
|
+
|
648
|
+
unless arg1.is_a?(arg1_type)
|
649
|
+
CallValidation.report_error(
|
650
|
+
method_sig,
|
651
|
+
method_sig.arg_types[1][1].error_message_for_obj(arg1),
|
652
|
+
'Parameter',
|
653
|
+
method_sig.arg_types[1][0],
|
654
|
+
arg1_type,
|
655
|
+
arg1,
|
656
|
+
caller_offset: -1
|
657
|
+
)
|
658
|
+
end
|
659
|
+
|
660
|
+
unless arg2.is_a?(arg2_type)
|
661
|
+
CallValidation.report_error(
|
662
|
+
method_sig,
|
663
|
+
method_sig.arg_types[2][1].error_message_for_obj(arg2),
|
664
|
+
'Parameter',
|
665
|
+
method_sig.arg_types[2][0],
|
666
|
+
arg2_type,
|
667
|
+
arg2,
|
668
|
+
caller_offset: -1
|
669
|
+
)
|
670
|
+
end
|
671
|
+
|
672
|
+
if should_sample
|
673
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
674
|
+
end
|
675
|
+
|
676
|
+
# The following line breaks are intentional to show nice pry message
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
|
682
|
+
|
683
|
+
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
# PRY note:
|
688
|
+
# this code is sig validation code.
|
689
|
+
# Please issue `finish` to step out of it
|
690
|
+
|
691
|
+
original_method.bind_call(self, arg0, arg1, arg2, &blk)
|
692
|
+
T::Private::Types::Void::VOID
|
693
|
+
end
|
694
|
+
end
|
695
|
+
|
696
|
+
def self.create_validator_procedure_fast4(mod, original_method, method_sig, arg0_type, arg1_type, arg2_type, arg3_type)
|
697
|
+
mod.send(:define_method, method_sig.method_name) do |arg0, arg1, arg2, arg3, &blk|
|
698
|
+
# This block is called for every `sig`. It's critical to keep it fast and
|
699
|
+
# reduce number of allocations that happen here.
|
700
|
+
# This method is a manually sped-up version of more general code in `validate_call`
|
701
|
+
T::Profile.typecheck_sample_attempts -= 1
|
702
|
+
should_sample = T::Profile.typecheck_sample_attempts == 0
|
703
|
+
if should_sample
|
704
|
+
T::Profile.typecheck_sample_attempts = T::Profile::SAMPLE_RATE
|
705
|
+
T::Profile.typecheck_samples += 1
|
706
|
+
t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
707
|
+
end
|
708
|
+
|
709
|
+
unless arg0.is_a?(arg0_type)
|
710
|
+
CallValidation.report_error(
|
711
|
+
method_sig,
|
712
|
+
method_sig.arg_types[0][1].error_message_for_obj(arg0),
|
713
|
+
'Parameter',
|
714
|
+
method_sig.arg_types[0][0],
|
715
|
+
arg0_type,
|
716
|
+
arg0,
|
717
|
+
caller_offset: -1
|
718
|
+
)
|
719
|
+
end
|
720
|
+
|
721
|
+
unless arg1.is_a?(arg1_type)
|
722
|
+
CallValidation.report_error(
|
723
|
+
method_sig,
|
724
|
+
method_sig.arg_types[1][1].error_message_for_obj(arg1),
|
725
|
+
'Parameter',
|
726
|
+
method_sig.arg_types[1][0],
|
727
|
+
arg1_type,
|
728
|
+
arg1,
|
729
|
+
caller_offset: -1
|
730
|
+
)
|
731
|
+
end
|
732
|
+
|
733
|
+
unless arg2.is_a?(arg2_type)
|
734
|
+
CallValidation.report_error(
|
735
|
+
method_sig,
|
736
|
+
method_sig.arg_types[2][1].error_message_for_obj(arg2),
|
737
|
+
'Parameter',
|
738
|
+
method_sig.arg_types[2][0],
|
739
|
+
arg2_type,
|
740
|
+
arg2,
|
741
|
+
caller_offset: -1
|
742
|
+
)
|
743
|
+
end
|
744
|
+
|
745
|
+
unless arg3.is_a?(arg3_type)
|
746
|
+
CallValidation.report_error(
|
747
|
+
method_sig,
|
748
|
+
method_sig.arg_types[3][1].error_message_for_obj(arg3),
|
749
|
+
'Parameter',
|
750
|
+
method_sig.arg_types[3][0],
|
751
|
+
arg3_type,
|
752
|
+
arg3,
|
753
|
+
caller_offset: -1
|
754
|
+
)
|
755
|
+
end
|
756
|
+
|
757
|
+
if should_sample
|
758
|
+
T::Profile.typecheck_duration += (Process.clock_gettime(Process::CLOCK_MONOTONIC) - t1)
|
759
|
+
end
|
760
|
+
|
761
|
+
# The following line breaks are intentional to show nice pry message
|
762
|
+
|
763
|
+
|
764
|
+
|
765
|
+
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
# PRY note:
|
773
|
+
# this code is sig validation code.
|
774
|
+
# Please issue `finish` to step out of it
|
775
|
+
|
776
|
+
original_method.bind_call(self, arg0, arg1, arg2, arg3, &blk)
|
777
|
+
T::Private::Types::Void::VOID
|
778
|
+
end
|
779
|
+
end
|
780
|
+
|
781
|
+
end
|