rbs 4.0.0.dev.2 → 4.0.0.dev.3
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/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +51 -0
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +0 -17
- data/.github/workflows/typecheck.yml +0 -2
- data/.gitignore +4 -0
- data/.rubocop.yml +1 -1
- data/.vscode/extensions.json +5 -0
- data/.vscode/settings.json +19 -0
- data/README.md +37 -0
- data/Rakefile +82 -0
- data/config.yml +1 -1
- data/core/enumerable.rbs +9 -0
- data/core/io.rbs +4 -4
- data/core/thread.rbs +0 -7
- data/ext/rbs_extension/ast_translation.c +1008 -1074
- data/ext/rbs_extension/class_constants.c +78 -74
- data/ext/rbs_extension/compat.h +3 -3
- data/ext/rbs_extension/extconf.rb +11 -1
- data/ext/rbs_extension/legacy_location.c +173 -172
- data/ext/rbs_extension/legacy_location.h +3 -3
- data/ext/rbs_extension/main.c +315 -273
- data/include/rbs/ast.h +11 -12
- data/include/rbs/defines.h +11 -12
- data/include/rbs/lexer.h +105 -105
- data/include/rbs/location.h +14 -14
- data/include/rbs/parser.h +21 -19
- data/include/rbs/string.h +3 -3
- data/include/rbs/util/rbs_allocator.h +14 -14
- data/include/rbs/util/rbs_constant_pool.h +3 -3
- data/include/rbs/util/rbs_encoding.h +1 -1
- data/lib/rbs/environment.rb +4 -0
- data/lib/rbs/namespace.rb +0 -7
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/type_name.rb +0 -7
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/environment.rbs +3 -0
- data/sig/namespace.rbs +0 -5
- data/sig/parser.rbs +20 -0
- data/sig/typename.rbs +0 -5
- data/sig/types.rbs +4 -1
- data/src/ast.c +216 -214
- data/src/lexer.c +2923 -2675
- data/src/lexstate.c +155 -155
- data/src/location.c +40 -40
- data/src/parser.c +2591 -2586
- data/src/string.c +2 -2
- data/src/util/rbs_allocator.c +7 -9
- data/src/util/rbs_assert.c +9 -9
- data/src/util/rbs_constant_pool.c +5 -7
- data/src/util/rbs_encoding.c +20095 -4056
- data/src/util/rbs_unescape.c +33 -32
- data/stdlib/json/0/json.rbs +9 -43
- data/stdlib/ripper/0/ripper.rbs +3 -0
- data/stdlib/socket/0/addrinfo.rbs +2 -2
- metadata +7 -2
@@ -44,19 +44,19 @@ VALUE rbs_hash_to_ruby_hash(rbs_translation_context_t ctx, rbs_hash_t *rbs_hash)
|
|
44
44
|
}
|
45
45
|
|
46
46
|
VALUE rbs_loc_to_ruby_location(rbs_translation_context_t ctx, rbs_location_t *source_loc) {
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
if (source_loc == NULL) {
|
48
|
+
return Qnil;
|
49
|
+
}
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
VALUE new_loc = rbs_new_location(ctx.buffer, source_loc->rg);
|
52
|
+
rbs_loc *new_loc_struct = rbs_check_location(new_loc);
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
if (source_loc->children != NULL) {
|
55
|
+
rbs_loc_legacy_alloc_children(new_loc_struct, source_loc->children->cap);
|
56
|
+
memcpy(new_loc_struct->children, source_loc->children, RBS_LOC_CHILDREN_SIZE(source_loc->children->cap));
|
57
|
+
}
|
58
58
|
|
59
|
-
|
59
|
+
return new_loc;
|
60
60
|
}
|
61
61
|
|
62
62
|
VALUE rbs_location_list_to_ruby_array(rbs_translation_context_t ctx, rbs_location_list_t *list) {
|
@@ -74,1077 +74,1011 @@ VALUE rbs_location_list_to_ruby_array(rbs_translation_context_t ctx, rbs_locatio
|
|
74
74
|
}
|
75
75
|
|
76
76
|
#ifdef RB_PASS_KEYWORDS
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
// Ruby 2.7 or later
|
78
|
+
#define CLASS_NEW_INSTANCE(klass, argc, argv) \
|
79
|
+
rb_class_new_instance_kw(argc, argv, klass, RB_PASS_KEYWORDS)
|
80
80
|
#else
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
// Ruby 2.6
|
82
|
+
#define CLASS_NEW_INSTANCE(receiver, argc, argv) \
|
83
|
+
rb_class_new_instance(argc, argv, receiver)
|
84
84
|
#endif
|
85
85
|
|
86
86
|
VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instance) {
|
87
87
|
if (instance == NULL) return Qnil;
|
88
88
|
|
89
89
|
switch (instance->type) {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
)
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
VALUE h = rb_hash_new();
|
1083
|
-
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
1084
|
-
rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
|
1085
|
-
|
1086
|
-
|
1087
|
-
return CLASS_NEW_INSTANCE(
|
1088
|
-
RBS_Types_Tuple,
|
1089
|
-
1,
|
1090
|
-
&h
|
1091
|
-
);
|
1092
|
-
}
|
1093
|
-
case RBS_TYPES_UNION: {
|
1094
|
-
rbs_types_union_t *node = (rbs_types_union_t *)instance;
|
1095
|
-
|
1096
|
-
VALUE h = rb_hash_new();
|
1097
|
-
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
1098
|
-
rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
|
1099
|
-
|
1100
|
-
|
1101
|
-
return CLASS_NEW_INSTANCE(
|
1102
|
-
RBS_Types_Union,
|
1103
|
-
1,
|
1104
|
-
&h
|
1105
|
-
);
|
1106
|
-
}
|
1107
|
-
case RBS_TYPES_UNTYPED_FUNCTION: {
|
1108
|
-
rbs_types_untyped_function_t *node = (rbs_types_untyped_function_t *)instance;
|
1109
|
-
|
1110
|
-
VALUE h = rb_hash_new();
|
1111
|
-
rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
|
1112
|
-
|
1113
|
-
|
1114
|
-
return CLASS_NEW_INSTANCE(
|
1115
|
-
RBS_Types_UntypedFunction,
|
1116
|
-
1,
|
1117
|
-
&h
|
1118
|
-
);
|
1119
|
-
}
|
1120
|
-
case RBS_TYPES_VARIABLE: {
|
1121
|
-
rbs_types_variable_t *node = (rbs_types_variable_t *)instance;
|
1122
|
-
|
1123
|
-
VALUE h = rb_hash_new();
|
1124
|
-
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
1125
|
-
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
1126
|
-
|
1127
|
-
|
1128
|
-
return CLASS_NEW_INSTANCE(
|
1129
|
-
RBS_Types_Variable,
|
1130
|
-
1,
|
1131
|
-
&h
|
1132
|
-
);
|
1133
|
-
}
|
1134
|
-
case RBS_KEYWORD: {
|
1135
|
-
rbs_constant_t *constant = rbs_constant_pool_id_to_constant(RBS_GLOBAL_CONSTANT_POOL, ((rbs_keyword_t *) instance)->constant_id);
|
1136
|
-
assert(constant != NULL && "constant is NULL");
|
1137
|
-
assert(constant->start != NULL && "constant->start is NULL");
|
1138
|
-
|
1139
|
-
return ID2SYM(rb_intern2((const char *) constant->start, constant->length));
|
1140
|
-
}
|
1141
|
-
case RBS_AST_SYMBOL: {
|
1142
|
-
rbs_constant_t *constant = rbs_constant_pool_id_to_constant(ctx.constant_pool, ((rbs_keyword_t *) instance)->constant_id);
|
1143
|
-
assert(constant != NULL && "constant is NULL");
|
1144
|
-
assert(constant->start != NULL && "constant->start is NULL");
|
1145
|
-
|
1146
|
-
return ID2SYM(rb_intern3((const char *) constant->start, constant->length, ctx.encoding));
|
1147
|
-
}
|
90
|
+
case RBS_AST_ANNOTATION: {
|
91
|
+
rbs_ast_annotation_t *node = (rbs_ast_annotation_t *) instance;
|
92
|
+
|
93
|
+
VALUE h = rb_hash_new();
|
94
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
95
|
+
rb_hash_aset(h, ID2SYM(rb_intern("string")), rbs_string_to_ruby_string(&node->string, ctx.encoding));
|
96
|
+
|
97
|
+
return CLASS_NEW_INSTANCE(
|
98
|
+
RBS_AST_Annotation,
|
99
|
+
1,
|
100
|
+
&h
|
101
|
+
);
|
102
|
+
}
|
103
|
+
case RBS_AST_BOOL: {
|
104
|
+
return ((rbs_ast_bool_t *) instance)->value ? Qtrue : Qfalse;
|
105
|
+
}
|
106
|
+
case RBS_AST_COMMENT: {
|
107
|
+
rbs_ast_comment_t *node = (rbs_ast_comment_t *) instance;
|
108
|
+
|
109
|
+
VALUE h = rb_hash_new();
|
110
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
111
|
+
rb_hash_aset(h, ID2SYM(rb_intern("string")), rbs_string_to_ruby_string(&node->string, ctx.encoding));
|
112
|
+
|
113
|
+
return CLASS_NEW_INSTANCE(
|
114
|
+
RBS_AST_Comment,
|
115
|
+
1,
|
116
|
+
&h
|
117
|
+
);
|
118
|
+
}
|
119
|
+
case RBS_AST_DECLARATIONS_CLASS: {
|
120
|
+
rbs_ast_declarations_class_t *node = (rbs_ast_declarations_class_t *) instance;
|
121
|
+
|
122
|
+
VALUE h = rb_hash_new();
|
123
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
124
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
125
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
|
126
|
+
rb_hash_aset(h, ID2SYM(rb_intern("super_class")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->super_class)); // rbs_ast_declarations_class_super
|
127
|
+
rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
|
128
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
129
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
130
|
+
|
131
|
+
rb_funcall(
|
132
|
+
RBS_AST_TypeParam,
|
133
|
+
rb_intern("resolve_variables"),
|
134
|
+
1,
|
135
|
+
rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
|
136
|
+
);
|
137
|
+
return CLASS_NEW_INSTANCE(
|
138
|
+
RBS_AST_Declarations_Class,
|
139
|
+
1,
|
140
|
+
&h
|
141
|
+
);
|
142
|
+
}
|
143
|
+
case RBS_AST_DECLARATIONS_CLASS_SUPER: {
|
144
|
+
rbs_ast_declarations_class_super_t *node = (rbs_ast_declarations_class_super_t *) instance;
|
145
|
+
|
146
|
+
VALUE h = rb_hash_new();
|
147
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
148
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
149
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
150
|
+
|
151
|
+
return CLASS_NEW_INSTANCE(
|
152
|
+
RBS_AST_Declarations_Class_Super,
|
153
|
+
1,
|
154
|
+
&h
|
155
|
+
);
|
156
|
+
}
|
157
|
+
case RBS_AST_DECLARATIONS_CLASS_ALIAS: {
|
158
|
+
rbs_ast_declarations_class_alias_t *node = (rbs_ast_declarations_class_alias_t *) instance;
|
159
|
+
|
160
|
+
VALUE h = rb_hash_new();
|
161
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
162
|
+
rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_type_name
|
163
|
+
rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_type_name
|
164
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
165
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
166
|
+
|
167
|
+
return CLASS_NEW_INSTANCE(
|
168
|
+
RBS_AST_Declarations_ClassAlias,
|
169
|
+
1,
|
170
|
+
&h
|
171
|
+
);
|
172
|
+
}
|
173
|
+
case RBS_AST_DECLARATIONS_CONSTANT: {
|
174
|
+
rbs_ast_declarations_constant_t *node = (rbs_ast_declarations_constant_t *) instance;
|
175
|
+
|
176
|
+
VALUE h = rb_hash_new();
|
177
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
178
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
179
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
180
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
181
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
182
|
+
|
183
|
+
return CLASS_NEW_INSTANCE(
|
184
|
+
RBS_AST_Declarations_Constant,
|
185
|
+
1,
|
186
|
+
&h
|
187
|
+
);
|
188
|
+
}
|
189
|
+
case RBS_AST_DECLARATIONS_GLOBAL: {
|
190
|
+
rbs_ast_declarations_global_t *node = (rbs_ast_declarations_global_t *) instance;
|
191
|
+
|
192
|
+
VALUE h = rb_hash_new();
|
193
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
194
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
195
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
196
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
197
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
198
|
+
|
199
|
+
return CLASS_NEW_INSTANCE(
|
200
|
+
RBS_AST_Declarations_Global,
|
201
|
+
1,
|
202
|
+
&h
|
203
|
+
);
|
204
|
+
}
|
205
|
+
case RBS_AST_DECLARATIONS_INTERFACE: {
|
206
|
+
rbs_ast_declarations_interface_t *node = (rbs_ast_declarations_interface_t *) instance;
|
207
|
+
|
208
|
+
VALUE h = rb_hash_new();
|
209
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
210
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
211
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
|
212
|
+
rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
|
213
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
214
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
215
|
+
|
216
|
+
rb_funcall(
|
217
|
+
RBS_AST_TypeParam,
|
218
|
+
rb_intern("resolve_variables"),
|
219
|
+
1,
|
220
|
+
rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
|
221
|
+
);
|
222
|
+
return CLASS_NEW_INSTANCE(
|
223
|
+
RBS_AST_Declarations_Interface,
|
224
|
+
1,
|
225
|
+
&h
|
226
|
+
);
|
227
|
+
}
|
228
|
+
case RBS_AST_DECLARATIONS_MODULE: {
|
229
|
+
rbs_ast_declarations_module_t *node = (rbs_ast_declarations_module_t *) instance;
|
230
|
+
|
231
|
+
VALUE h = rb_hash_new();
|
232
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
233
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
234
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
|
235
|
+
rb_hash_aset(h, ID2SYM(rb_intern("self_types")), rbs_node_list_to_ruby_array(ctx, node->self_types));
|
236
|
+
rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
|
237
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
238
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
239
|
+
|
240
|
+
rb_funcall(
|
241
|
+
RBS_AST_TypeParam,
|
242
|
+
rb_intern("resolve_variables"),
|
243
|
+
1,
|
244
|
+
rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
|
245
|
+
);
|
246
|
+
return CLASS_NEW_INSTANCE(
|
247
|
+
RBS_AST_Declarations_Module,
|
248
|
+
1,
|
249
|
+
&h
|
250
|
+
);
|
251
|
+
}
|
252
|
+
case RBS_AST_DECLARATIONS_MODULE_SELF: {
|
253
|
+
rbs_ast_declarations_module_self_t *node = (rbs_ast_declarations_module_self_t *) instance;
|
254
|
+
|
255
|
+
VALUE h = rb_hash_new();
|
256
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
257
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
258
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
259
|
+
|
260
|
+
return CLASS_NEW_INSTANCE(
|
261
|
+
RBS_AST_Declarations_Module_Self,
|
262
|
+
1,
|
263
|
+
&h
|
264
|
+
);
|
265
|
+
}
|
266
|
+
case RBS_AST_DECLARATIONS_MODULE_ALIAS: {
|
267
|
+
rbs_ast_declarations_module_alias_t *node = (rbs_ast_declarations_module_alias_t *) instance;
|
268
|
+
|
269
|
+
VALUE h = rb_hash_new();
|
270
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
271
|
+
rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_type_name
|
272
|
+
rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_type_name
|
273
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
274
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
275
|
+
|
276
|
+
return CLASS_NEW_INSTANCE(
|
277
|
+
RBS_AST_Declarations_ModuleAlias,
|
278
|
+
1,
|
279
|
+
&h
|
280
|
+
);
|
281
|
+
}
|
282
|
+
case RBS_AST_DECLARATIONS_TYPE_ALIAS: {
|
283
|
+
rbs_ast_declarations_type_alias_t *node = (rbs_ast_declarations_type_alias_t *) instance;
|
284
|
+
|
285
|
+
VALUE h = rb_hash_new();
|
286
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
287
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
288
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
|
289
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
290
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
291
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
292
|
+
|
293
|
+
rb_funcall(
|
294
|
+
RBS_AST_TypeParam,
|
295
|
+
rb_intern("resolve_variables"),
|
296
|
+
1,
|
297
|
+
rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
|
298
|
+
);
|
299
|
+
return CLASS_NEW_INSTANCE(
|
300
|
+
RBS_AST_Declarations_TypeAlias,
|
301
|
+
1,
|
302
|
+
&h
|
303
|
+
);
|
304
|
+
}
|
305
|
+
case RBS_AST_DIRECTIVES_USE: {
|
306
|
+
rbs_ast_directives_use_t *node = (rbs_ast_directives_use_t *) instance;
|
307
|
+
|
308
|
+
VALUE h = rb_hash_new();
|
309
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
310
|
+
rb_hash_aset(h, ID2SYM(rb_intern("clauses")), rbs_node_list_to_ruby_array(ctx, node->clauses));
|
311
|
+
|
312
|
+
return CLASS_NEW_INSTANCE(
|
313
|
+
RBS_AST_Directives_Use,
|
314
|
+
1,
|
315
|
+
&h
|
316
|
+
);
|
317
|
+
}
|
318
|
+
case RBS_AST_DIRECTIVES_USE_SINGLE_CLAUSE: {
|
319
|
+
rbs_ast_directives_use_single_clause_t *node = (rbs_ast_directives_use_single_clause_t *) instance;
|
320
|
+
|
321
|
+
VALUE h = rb_hash_new();
|
322
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
323
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_name)); // rbs_type_name
|
324
|
+
rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_ast_symbol
|
325
|
+
|
326
|
+
return CLASS_NEW_INSTANCE(
|
327
|
+
RBS_AST_Directives_Use_SingleClause,
|
328
|
+
1,
|
329
|
+
&h
|
330
|
+
);
|
331
|
+
}
|
332
|
+
case RBS_AST_DIRECTIVES_USE_WILDCARD_CLAUSE: {
|
333
|
+
rbs_ast_directives_use_wildcard_clause_t *node = (rbs_ast_directives_use_wildcard_clause_t *) instance;
|
334
|
+
|
335
|
+
VALUE h = rb_hash_new();
|
336
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
337
|
+
rb_hash_aset(h, ID2SYM(rb_intern("namespace")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rbs_namespace)); // rbs_namespace
|
338
|
+
|
339
|
+
return CLASS_NEW_INSTANCE(
|
340
|
+
RBS_AST_Directives_Use_WildcardClause,
|
341
|
+
1,
|
342
|
+
&h
|
343
|
+
);
|
344
|
+
}
|
345
|
+
case RBS_AST_INTEGER: {
|
346
|
+
rbs_ast_integer_t *integer_node = (rbs_ast_integer_t *) instance;
|
347
|
+
rbs_string_t string_repr = integer_node->string_representation;
|
348
|
+
|
349
|
+
VALUE str = rb_enc_str_new(string_repr.start, rbs_string_len(string_repr), rb_utf8_encoding());
|
350
|
+
|
351
|
+
return rb_funcall(str, rb_intern("to_i"), 0);
|
352
|
+
}
|
353
|
+
case RBS_AST_MEMBERS_ALIAS: {
|
354
|
+
rbs_ast_members_alias_t *node = (rbs_ast_members_alias_t *) instance;
|
355
|
+
|
356
|
+
VALUE h = rb_hash_new();
|
357
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
358
|
+
rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_ast_symbol
|
359
|
+
rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_ast_symbol
|
360
|
+
rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
|
361
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
362
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
363
|
+
|
364
|
+
return CLASS_NEW_INSTANCE(
|
365
|
+
RBS_AST_Members_Alias,
|
366
|
+
1,
|
367
|
+
&h
|
368
|
+
);
|
369
|
+
}
|
370
|
+
case RBS_AST_MEMBERS_ATTR_ACCESSOR: {
|
371
|
+
rbs_ast_members_attr_accessor_t *node = (rbs_ast_members_attr_accessor_t *) instance;
|
372
|
+
|
373
|
+
VALUE h = rb_hash_new();
|
374
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
375
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
376
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
377
|
+
rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_node
|
378
|
+
rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
|
379
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
380
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
381
|
+
rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
|
382
|
+
|
383
|
+
return CLASS_NEW_INSTANCE(
|
384
|
+
RBS_AST_Members_AttrAccessor,
|
385
|
+
1,
|
386
|
+
&h
|
387
|
+
);
|
388
|
+
}
|
389
|
+
case RBS_AST_MEMBERS_ATTR_READER: {
|
390
|
+
rbs_ast_members_attr_reader_t *node = (rbs_ast_members_attr_reader_t *) instance;
|
391
|
+
|
392
|
+
VALUE h = rb_hash_new();
|
393
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
394
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
395
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
396
|
+
rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_node
|
397
|
+
rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
|
398
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
399
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
400
|
+
rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
|
401
|
+
|
402
|
+
return CLASS_NEW_INSTANCE(
|
403
|
+
RBS_AST_Members_AttrReader,
|
404
|
+
1,
|
405
|
+
&h
|
406
|
+
);
|
407
|
+
}
|
408
|
+
case RBS_AST_MEMBERS_ATTR_WRITER: {
|
409
|
+
rbs_ast_members_attr_writer_t *node = (rbs_ast_members_attr_writer_t *) instance;
|
410
|
+
|
411
|
+
VALUE h = rb_hash_new();
|
412
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
413
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
414
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
415
|
+
rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_node
|
416
|
+
rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
|
417
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
418
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
419
|
+
rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
|
420
|
+
|
421
|
+
return CLASS_NEW_INSTANCE(
|
422
|
+
RBS_AST_Members_AttrWriter,
|
423
|
+
1,
|
424
|
+
&h
|
425
|
+
);
|
426
|
+
}
|
427
|
+
case RBS_AST_MEMBERS_CLASS_INSTANCE_VARIABLE: {
|
428
|
+
rbs_ast_members_class_instance_variable_t *node = (rbs_ast_members_class_instance_variable_t *) instance;
|
429
|
+
|
430
|
+
VALUE h = rb_hash_new();
|
431
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
432
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
433
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
434
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
435
|
+
|
436
|
+
return CLASS_NEW_INSTANCE(
|
437
|
+
RBS_AST_Members_ClassInstanceVariable,
|
438
|
+
1,
|
439
|
+
&h
|
440
|
+
);
|
441
|
+
}
|
442
|
+
case RBS_AST_MEMBERS_CLASS_VARIABLE: {
|
443
|
+
rbs_ast_members_class_variable_t *node = (rbs_ast_members_class_variable_t *) instance;
|
444
|
+
|
445
|
+
VALUE h = rb_hash_new();
|
446
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
447
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
448
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
449
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
450
|
+
|
451
|
+
return CLASS_NEW_INSTANCE(
|
452
|
+
RBS_AST_Members_ClassVariable,
|
453
|
+
1,
|
454
|
+
&h
|
455
|
+
);
|
456
|
+
}
|
457
|
+
case RBS_AST_MEMBERS_EXTEND: {
|
458
|
+
rbs_ast_members_extend_t *node = (rbs_ast_members_extend_t *) instance;
|
459
|
+
|
460
|
+
VALUE h = rb_hash_new();
|
461
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
462
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
463
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
464
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
465
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
466
|
+
|
467
|
+
return CLASS_NEW_INSTANCE(
|
468
|
+
RBS_AST_Members_Extend,
|
469
|
+
1,
|
470
|
+
&h
|
471
|
+
);
|
472
|
+
}
|
473
|
+
case RBS_AST_MEMBERS_INCLUDE: {
|
474
|
+
rbs_ast_members_include_t *node = (rbs_ast_members_include_t *) instance;
|
475
|
+
|
476
|
+
VALUE h = rb_hash_new();
|
477
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
478
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
479
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
480
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
481
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
482
|
+
|
483
|
+
return CLASS_NEW_INSTANCE(
|
484
|
+
RBS_AST_Members_Include,
|
485
|
+
1,
|
486
|
+
&h
|
487
|
+
);
|
488
|
+
}
|
489
|
+
case RBS_AST_MEMBERS_INSTANCE_VARIABLE: {
|
490
|
+
rbs_ast_members_instance_variable_t *node = (rbs_ast_members_instance_variable_t *) instance;
|
491
|
+
|
492
|
+
VALUE h = rb_hash_new();
|
493
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
494
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
495
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
496
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
497
|
+
|
498
|
+
return CLASS_NEW_INSTANCE(
|
499
|
+
RBS_AST_Members_InstanceVariable,
|
500
|
+
1,
|
501
|
+
&h
|
502
|
+
);
|
503
|
+
}
|
504
|
+
case RBS_AST_MEMBERS_METHOD_DEFINITION: {
|
505
|
+
rbs_ast_members_method_definition_t *node = (rbs_ast_members_method_definition_t *) instance;
|
506
|
+
|
507
|
+
VALUE h = rb_hash_new();
|
508
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
509
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
510
|
+
rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
|
511
|
+
rb_hash_aset(h, ID2SYM(rb_intern("overloads")), rbs_node_list_to_ruby_array(ctx, node->overloads));
|
512
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
513
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
514
|
+
rb_hash_aset(h, ID2SYM(rb_intern("overloading")), node->overloading ? Qtrue : Qfalse);
|
515
|
+
rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
|
516
|
+
|
517
|
+
return CLASS_NEW_INSTANCE(
|
518
|
+
RBS_AST_Members_MethodDefinition,
|
519
|
+
1,
|
520
|
+
&h
|
521
|
+
);
|
522
|
+
}
|
523
|
+
case RBS_AST_MEMBERS_METHOD_DEFINITION_OVERLOAD: {
|
524
|
+
rbs_ast_members_method_definition_overload_t *node = (rbs_ast_members_method_definition_overload_t *) instance;
|
525
|
+
|
526
|
+
VALUE h = rb_hash_new();
|
527
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
528
|
+
rb_hash_aset(h, ID2SYM(rb_intern("method_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->method_type)); // rbs_node
|
529
|
+
|
530
|
+
return CLASS_NEW_INSTANCE(
|
531
|
+
RBS_AST_Members_MethodDefinition_Overload,
|
532
|
+
1,
|
533
|
+
&h
|
534
|
+
);
|
535
|
+
}
|
536
|
+
case RBS_AST_MEMBERS_PREPEND: {
|
537
|
+
rbs_ast_members_prepend_t *node = (rbs_ast_members_prepend_t *) instance;
|
538
|
+
|
539
|
+
VALUE h = rb_hash_new();
|
540
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
541
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
542
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
543
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
544
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
|
545
|
+
|
546
|
+
return CLASS_NEW_INSTANCE(
|
547
|
+
RBS_AST_Members_Prepend,
|
548
|
+
1,
|
549
|
+
&h
|
550
|
+
);
|
551
|
+
}
|
552
|
+
case RBS_AST_MEMBERS_PRIVATE: {
|
553
|
+
rbs_ast_members_private_t *node = (rbs_ast_members_private_t *) instance;
|
554
|
+
|
555
|
+
VALUE h = rb_hash_new();
|
556
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
557
|
+
|
558
|
+
return CLASS_NEW_INSTANCE(
|
559
|
+
RBS_AST_Members_Private,
|
560
|
+
1,
|
561
|
+
&h
|
562
|
+
);
|
563
|
+
}
|
564
|
+
case RBS_AST_MEMBERS_PUBLIC: {
|
565
|
+
rbs_ast_members_public_t *node = (rbs_ast_members_public_t *) instance;
|
566
|
+
|
567
|
+
VALUE h = rb_hash_new();
|
568
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
569
|
+
|
570
|
+
return CLASS_NEW_INSTANCE(
|
571
|
+
RBS_AST_Members_Public,
|
572
|
+
1,
|
573
|
+
&h
|
574
|
+
);
|
575
|
+
}
|
576
|
+
case RBS_AST_RUBY_ANNOTATIONS_COLON_METHOD_TYPE_ANNOTATION: {
|
577
|
+
rbs_ast_ruby_annotations_colon_method_type_annotation_t *node = (rbs_ast_ruby_annotations_colon_method_type_annotation_t *) instance;
|
578
|
+
|
579
|
+
VALUE h = rb_hash_new();
|
580
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
581
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
582
|
+
rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
|
583
|
+
rb_hash_aset(h, ID2SYM(rb_intern("method_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->method_type)); // rbs_node
|
584
|
+
|
585
|
+
return CLASS_NEW_INSTANCE(
|
586
|
+
RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation,
|
587
|
+
1,
|
588
|
+
&h
|
589
|
+
);
|
590
|
+
}
|
591
|
+
case RBS_AST_RUBY_ANNOTATIONS_METHOD_TYPES_ANNOTATION: {
|
592
|
+
rbs_ast_ruby_annotations_method_types_annotation_t *node = (rbs_ast_ruby_annotations_method_types_annotation_t *) instance;
|
593
|
+
|
594
|
+
VALUE h = rb_hash_new();
|
595
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
596
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
597
|
+
rb_hash_aset(h, ID2SYM(rb_intern("overloads")), rbs_node_list_to_ruby_array(ctx, node->overloads));
|
598
|
+
rb_hash_aset(h, ID2SYM(rb_intern("vertical_bar_locations")), rbs_location_list_to_ruby_array(ctx, node->vertical_bar_locations));
|
599
|
+
|
600
|
+
return CLASS_NEW_INSTANCE(
|
601
|
+
RBS_AST_Ruby_Annotations_MethodTypesAnnotation,
|
602
|
+
1,
|
603
|
+
&h
|
604
|
+
);
|
605
|
+
}
|
606
|
+
case RBS_AST_RUBY_ANNOTATIONS_NODE_TYPE_ASSERTION: {
|
607
|
+
rbs_ast_ruby_annotations_node_type_assertion_t *node = (rbs_ast_ruby_annotations_node_type_assertion_t *) instance;
|
608
|
+
|
609
|
+
VALUE h = rb_hash_new();
|
610
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
611
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
612
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
613
|
+
|
614
|
+
return CLASS_NEW_INSTANCE(
|
615
|
+
RBS_AST_Ruby_Annotations_NodeTypeAssertion,
|
616
|
+
1,
|
617
|
+
&h
|
618
|
+
);
|
619
|
+
}
|
620
|
+
case RBS_AST_RUBY_ANNOTATIONS_RETURN_TYPE_ANNOTATION: {
|
621
|
+
rbs_ast_ruby_annotations_return_type_annotation_t *node = (rbs_ast_ruby_annotations_return_type_annotation_t *) instance;
|
622
|
+
|
623
|
+
VALUE h = rb_hash_new();
|
624
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
625
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
626
|
+
rb_hash_aset(h, ID2SYM(rb_intern("return_location")), rbs_loc_to_ruby_location(ctx, node->return_location));
|
627
|
+
rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_loc_to_ruby_location(ctx, node->colon_location));
|
628
|
+
rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
|
629
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_loc_to_ruby_location(ctx, node->comment_location));
|
630
|
+
|
631
|
+
return CLASS_NEW_INSTANCE(
|
632
|
+
RBS_AST_Ruby_Annotations_ReturnTypeAnnotation,
|
633
|
+
1,
|
634
|
+
&h
|
635
|
+
);
|
636
|
+
}
|
637
|
+
case RBS_AST_RUBY_ANNOTATIONS_SKIP_ANNOTATION: {
|
638
|
+
rbs_ast_ruby_annotations_skip_annotation_t *node = (rbs_ast_ruby_annotations_skip_annotation_t *) instance;
|
639
|
+
|
640
|
+
VALUE h = rb_hash_new();
|
641
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
642
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
643
|
+
rb_hash_aset(h, ID2SYM(rb_intern("skip_location")), rbs_loc_to_ruby_location(ctx, node->skip_location));
|
644
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_loc_to_ruby_location(ctx, node->comment_location));
|
645
|
+
|
646
|
+
return CLASS_NEW_INSTANCE(
|
647
|
+
RBS_AST_Ruby_Annotations_SkipAnnotation,
|
648
|
+
1,
|
649
|
+
&h
|
650
|
+
);
|
651
|
+
}
|
652
|
+
case RBS_AST_STRING: {
|
653
|
+
rbs_ast_string_t *string_node = (rbs_ast_string_t *) instance;
|
654
|
+
rbs_string_t s = string_node->string;
|
655
|
+
|
656
|
+
return rb_enc_str_new(s.start, rbs_string_len(s), rb_utf8_encoding());
|
657
|
+
}
|
658
|
+
case RBS_AST_TYPE_PARAM: {
|
659
|
+
rbs_ast_type_param_t *node = (rbs_ast_type_param_t *) instance;
|
660
|
+
|
661
|
+
VALUE h = rb_hash_new();
|
662
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
663
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
664
|
+
rb_hash_aset(h, ID2SYM(rb_intern("variance")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->variance)); // rbs_keyword
|
665
|
+
rb_hash_aset(h, ID2SYM(rb_intern("upper_bound")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->upper_bound)); // rbs_node
|
666
|
+
rb_hash_aset(h, ID2SYM(rb_intern("default_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->default_type)); // rbs_node
|
667
|
+
rb_hash_aset(h, ID2SYM(rb_intern("unchecked")), node->unchecked ? Qtrue : Qfalse);
|
668
|
+
|
669
|
+
return CLASS_NEW_INSTANCE(
|
670
|
+
RBS_AST_TypeParam,
|
671
|
+
1,
|
672
|
+
&h
|
673
|
+
);
|
674
|
+
}
|
675
|
+
case RBS_METHOD_TYPE: {
|
676
|
+
rbs_method_type_t *node = (rbs_method_type_t *) instance;
|
677
|
+
|
678
|
+
VALUE h = rb_hash_new();
|
679
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
680
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
|
681
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
682
|
+
rb_hash_aset(h, ID2SYM(rb_intern("block")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->block)); // rbs_types_block
|
683
|
+
|
684
|
+
rb_funcall(
|
685
|
+
RBS_AST_TypeParam,
|
686
|
+
rb_intern("resolve_variables"),
|
687
|
+
1,
|
688
|
+
rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
|
689
|
+
);
|
690
|
+
return CLASS_NEW_INSTANCE(
|
691
|
+
RBS_MethodType,
|
692
|
+
1,
|
693
|
+
&h
|
694
|
+
);
|
695
|
+
}
|
696
|
+
case RBS_NAMESPACE: {
|
697
|
+
rbs_namespace_t *node = (rbs_namespace_t *) instance;
|
698
|
+
|
699
|
+
VALUE h = rb_hash_new();
|
700
|
+
rb_hash_aset(h, ID2SYM(rb_intern("path")), rbs_node_list_to_ruby_array(ctx, node->path));
|
701
|
+
rb_hash_aset(h, ID2SYM(rb_intern("absolute")), node->absolute ? Qtrue : Qfalse);
|
702
|
+
|
703
|
+
return CLASS_NEW_INSTANCE(
|
704
|
+
RBS_Namespace,
|
705
|
+
1,
|
706
|
+
&h
|
707
|
+
);
|
708
|
+
}
|
709
|
+
case RBS_SIGNATURE: {
|
710
|
+
rbs_signature_t *signature = (rbs_signature_t *) instance;
|
711
|
+
|
712
|
+
VALUE array = rb_ary_new();
|
713
|
+
rb_ary_push(array, rbs_node_list_to_ruby_array(ctx, signature->directives));
|
714
|
+
rb_ary_push(array, rbs_node_list_to_ruby_array(ctx, signature->declarations));
|
715
|
+
return array;
|
716
|
+
}
|
717
|
+
case RBS_TYPE_NAME: {
|
718
|
+
rbs_type_name_t *node = (rbs_type_name_t *) instance;
|
719
|
+
|
720
|
+
VALUE h = rb_hash_new();
|
721
|
+
rb_hash_aset(h, ID2SYM(rb_intern("namespace")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rbs_namespace)); // rbs_namespace
|
722
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
723
|
+
|
724
|
+
return CLASS_NEW_INSTANCE(
|
725
|
+
RBS_TypeName,
|
726
|
+
1,
|
727
|
+
&h
|
728
|
+
);
|
729
|
+
}
|
730
|
+
case RBS_TYPES_ALIAS: {
|
731
|
+
rbs_types_alias_t *node = (rbs_types_alias_t *) instance;
|
732
|
+
|
733
|
+
VALUE h = rb_hash_new();
|
734
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
735
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
736
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
737
|
+
|
738
|
+
return CLASS_NEW_INSTANCE(
|
739
|
+
RBS_Types_Alias,
|
740
|
+
1,
|
741
|
+
&h
|
742
|
+
);
|
743
|
+
}
|
744
|
+
case RBS_TYPES_BASES_ANY: {
|
745
|
+
rbs_types_bases_any_t *node = (rbs_types_bases_any_t *) instance;
|
746
|
+
|
747
|
+
VALUE h = rb_hash_new();
|
748
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
749
|
+
rb_hash_aset(h, ID2SYM(rb_intern("todo")), node->todo ? Qtrue : Qfalse);
|
750
|
+
|
751
|
+
return CLASS_NEW_INSTANCE(
|
752
|
+
RBS_Types_Bases_Any,
|
753
|
+
1,
|
754
|
+
&h
|
755
|
+
);
|
756
|
+
}
|
757
|
+
case RBS_TYPES_BASES_BOOL: {
|
758
|
+
rbs_types_bases_bool_t *node = (rbs_types_bases_bool_t *) instance;
|
759
|
+
|
760
|
+
VALUE h = rb_hash_new();
|
761
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
762
|
+
|
763
|
+
return CLASS_NEW_INSTANCE(
|
764
|
+
RBS_Types_Bases_Bool,
|
765
|
+
1,
|
766
|
+
&h
|
767
|
+
);
|
768
|
+
}
|
769
|
+
case RBS_TYPES_BASES_BOTTOM: {
|
770
|
+
rbs_types_bases_bottom_t *node = (rbs_types_bases_bottom_t *) instance;
|
771
|
+
|
772
|
+
VALUE h = rb_hash_new();
|
773
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
774
|
+
|
775
|
+
return CLASS_NEW_INSTANCE(
|
776
|
+
RBS_Types_Bases_Bottom,
|
777
|
+
1,
|
778
|
+
&h
|
779
|
+
);
|
780
|
+
}
|
781
|
+
case RBS_TYPES_BASES_CLASS: {
|
782
|
+
rbs_types_bases_class_t *node = (rbs_types_bases_class_t *) instance;
|
783
|
+
|
784
|
+
VALUE h = rb_hash_new();
|
785
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
786
|
+
|
787
|
+
return CLASS_NEW_INSTANCE(
|
788
|
+
RBS_Types_Bases_Class,
|
789
|
+
1,
|
790
|
+
&h
|
791
|
+
);
|
792
|
+
}
|
793
|
+
case RBS_TYPES_BASES_INSTANCE: {
|
794
|
+
rbs_types_bases_instance_t *node = (rbs_types_bases_instance_t *) instance;
|
795
|
+
|
796
|
+
VALUE h = rb_hash_new();
|
797
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
798
|
+
|
799
|
+
return CLASS_NEW_INSTANCE(
|
800
|
+
RBS_Types_Bases_Instance,
|
801
|
+
1,
|
802
|
+
&h
|
803
|
+
);
|
804
|
+
}
|
805
|
+
case RBS_TYPES_BASES_NIL: {
|
806
|
+
rbs_types_bases_nil_t *node = (rbs_types_bases_nil_t *) instance;
|
807
|
+
|
808
|
+
VALUE h = rb_hash_new();
|
809
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
810
|
+
|
811
|
+
return CLASS_NEW_INSTANCE(
|
812
|
+
RBS_Types_Bases_Nil,
|
813
|
+
1,
|
814
|
+
&h
|
815
|
+
);
|
816
|
+
}
|
817
|
+
case RBS_TYPES_BASES_SELF: {
|
818
|
+
rbs_types_bases_self_t *node = (rbs_types_bases_self_t *) instance;
|
819
|
+
|
820
|
+
VALUE h = rb_hash_new();
|
821
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
822
|
+
|
823
|
+
return CLASS_NEW_INSTANCE(
|
824
|
+
RBS_Types_Bases_Self,
|
825
|
+
1,
|
826
|
+
&h
|
827
|
+
);
|
828
|
+
}
|
829
|
+
case RBS_TYPES_BASES_TOP: {
|
830
|
+
rbs_types_bases_top_t *node = (rbs_types_bases_top_t *) instance;
|
831
|
+
|
832
|
+
VALUE h = rb_hash_new();
|
833
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
834
|
+
|
835
|
+
return CLASS_NEW_INSTANCE(
|
836
|
+
RBS_Types_Bases_Top,
|
837
|
+
1,
|
838
|
+
&h
|
839
|
+
);
|
840
|
+
}
|
841
|
+
case RBS_TYPES_BASES_VOID: {
|
842
|
+
rbs_types_bases_void_t *node = (rbs_types_bases_void_t *) instance;
|
843
|
+
|
844
|
+
VALUE h = rb_hash_new();
|
845
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
846
|
+
|
847
|
+
return CLASS_NEW_INSTANCE(
|
848
|
+
RBS_Types_Bases_Void,
|
849
|
+
1,
|
850
|
+
&h
|
851
|
+
);
|
852
|
+
}
|
853
|
+
case RBS_TYPES_BLOCK: {
|
854
|
+
rbs_types_block_t *node = (rbs_types_block_t *) instance;
|
855
|
+
|
856
|
+
VALUE h = rb_hash_new();
|
857
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
858
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
859
|
+
rb_hash_aset(h, ID2SYM(rb_intern("required")), node->required ? Qtrue : Qfalse);
|
860
|
+
rb_hash_aset(h, ID2SYM(rb_intern("self_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->self_type)); // rbs_node
|
861
|
+
|
862
|
+
return CLASS_NEW_INSTANCE(
|
863
|
+
RBS_Types_Block,
|
864
|
+
1,
|
865
|
+
&h
|
866
|
+
);
|
867
|
+
}
|
868
|
+
case RBS_TYPES_CLASS_INSTANCE: {
|
869
|
+
rbs_types_class_instance_t *node = (rbs_types_class_instance_t *) instance;
|
870
|
+
|
871
|
+
VALUE h = rb_hash_new();
|
872
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
873
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
874
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
875
|
+
|
876
|
+
return CLASS_NEW_INSTANCE(
|
877
|
+
RBS_Types_ClassInstance,
|
878
|
+
1,
|
879
|
+
&h
|
880
|
+
);
|
881
|
+
}
|
882
|
+
case RBS_TYPES_CLASS_SINGLETON: {
|
883
|
+
rbs_types_class_singleton_t *node = (rbs_types_class_singleton_t *) instance;
|
884
|
+
|
885
|
+
VALUE h = rb_hash_new();
|
886
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
887
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
888
|
+
|
889
|
+
return CLASS_NEW_INSTANCE(
|
890
|
+
RBS_Types_ClassSingleton,
|
891
|
+
1,
|
892
|
+
&h
|
893
|
+
);
|
894
|
+
}
|
895
|
+
case RBS_TYPES_FUNCTION: {
|
896
|
+
rbs_types_function_t *node = (rbs_types_function_t *) instance;
|
897
|
+
|
898
|
+
VALUE h = rb_hash_new();
|
899
|
+
rb_hash_aset(h, ID2SYM(rb_intern("required_positionals")), rbs_node_list_to_ruby_array(ctx, node->required_positionals));
|
900
|
+
rb_hash_aset(h, ID2SYM(rb_intern("optional_positionals")), rbs_node_list_to_ruby_array(ctx, node->optional_positionals));
|
901
|
+
rb_hash_aset(h, ID2SYM(rb_intern("rest_positionals")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rest_positionals)); // rbs_node
|
902
|
+
rb_hash_aset(h, ID2SYM(rb_intern("trailing_positionals")), rbs_node_list_to_ruby_array(ctx, node->trailing_positionals));
|
903
|
+
rb_hash_aset(h, ID2SYM(rb_intern("required_keywords")), rbs_hash_to_ruby_hash(ctx, node->required_keywords));
|
904
|
+
rb_hash_aset(h, ID2SYM(rb_intern("optional_keywords")), rbs_hash_to_ruby_hash(ctx, node->optional_keywords));
|
905
|
+
rb_hash_aset(h, ID2SYM(rb_intern("rest_keywords")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rest_keywords)); // rbs_node
|
906
|
+
rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
|
907
|
+
|
908
|
+
return CLASS_NEW_INSTANCE(
|
909
|
+
RBS_Types_Function,
|
910
|
+
1,
|
911
|
+
&h
|
912
|
+
);
|
913
|
+
}
|
914
|
+
case RBS_TYPES_FUNCTION_PARAM: {
|
915
|
+
rbs_types_function_param_t *node = (rbs_types_function_param_t *) instance;
|
916
|
+
|
917
|
+
VALUE h = rb_hash_new();
|
918
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
919
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
920
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
921
|
+
|
922
|
+
return CLASS_NEW_INSTANCE(
|
923
|
+
RBS_Types_Function_Param,
|
924
|
+
1,
|
925
|
+
&h
|
926
|
+
);
|
927
|
+
}
|
928
|
+
case RBS_TYPES_INTERFACE: {
|
929
|
+
rbs_types_interface_t *node = (rbs_types_interface_t *) instance;
|
930
|
+
|
931
|
+
VALUE h = rb_hash_new();
|
932
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
933
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
|
934
|
+
rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
|
935
|
+
|
936
|
+
return CLASS_NEW_INSTANCE(
|
937
|
+
RBS_Types_Interface,
|
938
|
+
1,
|
939
|
+
&h
|
940
|
+
);
|
941
|
+
}
|
942
|
+
case RBS_TYPES_INTERSECTION: {
|
943
|
+
rbs_types_intersection_t *node = (rbs_types_intersection_t *) instance;
|
944
|
+
|
945
|
+
VALUE h = rb_hash_new();
|
946
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
947
|
+
rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
|
948
|
+
|
949
|
+
return CLASS_NEW_INSTANCE(
|
950
|
+
RBS_Types_Intersection,
|
951
|
+
1,
|
952
|
+
&h
|
953
|
+
);
|
954
|
+
}
|
955
|
+
case RBS_TYPES_LITERAL: {
|
956
|
+
rbs_types_literal_t *node = (rbs_types_literal_t *) instance;
|
957
|
+
|
958
|
+
VALUE h = rb_hash_new();
|
959
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
960
|
+
rb_hash_aset(h, ID2SYM(rb_intern("literal")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->literal)); // rbs_node
|
961
|
+
|
962
|
+
return CLASS_NEW_INSTANCE(
|
963
|
+
RBS_Types_Literal,
|
964
|
+
1,
|
965
|
+
&h
|
966
|
+
);
|
967
|
+
}
|
968
|
+
case RBS_TYPES_OPTIONAL: {
|
969
|
+
rbs_types_optional_t *node = (rbs_types_optional_t *) instance;
|
970
|
+
|
971
|
+
VALUE h = rb_hash_new();
|
972
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
973
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
974
|
+
|
975
|
+
return CLASS_NEW_INSTANCE(
|
976
|
+
RBS_Types_Optional,
|
977
|
+
1,
|
978
|
+
&h
|
979
|
+
);
|
980
|
+
}
|
981
|
+
case RBS_TYPES_PROC: {
|
982
|
+
rbs_types_proc_t *node = (rbs_types_proc_t *) instance;
|
983
|
+
|
984
|
+
VALUE h = rb_hash_new();
|
985
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
986
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
987
|
+
rb_hash_aset(h, ID2SYM(rb_intern("block")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->block)); // rbs_types_block
|
988
|
+
rb_hash_aset(h, ID2SYM(rb_intern("self_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->self_type)); // rbs_node
|
989
|
+
|
990
|
+
return CLASS_NEW_INSTANCE(
|
991
|
+
RBS_Types_Proc,
|
992
|
+
1,
|
993
|
+
&h
|
994
|
+
);
|
995
|
+
}
|
996
|
+
case RBS_TYPES_RECORD: {
|
997
|
+
rbs_types_record_t *node = (rbs_types_record_t *) instance;
|
998
|
+
|
999
|
+
VALUE h = rb_hash_new();
|
1000
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
1001
|
+
rb_hash_aset(h, ID2SYM(rb_intern("all_fields")), rbs_hash_to_ruby_hash(ctx, node->all_fields));
|
1002
|
+
|
1003
|
+
return CLASS_NEW_INSTANCE(
|
1004
|
+
RBS_Types_Record,
|
1005
|
+
1,
|
1006
|
+
&h
|
1007
|
+
);
|
1008
|
+
}
|
1009
|
+
case RBS_TYPES_RECORD_FIELD_TYPE: {
|
1010
|
+
rbs_types_record_field_type_t *record_fieldtype = (rbs_types_record_field_type_t *) instance;
|
1011
|
+
|
1012
|
+
VALUE array = rb_ary_new();
|
1013
|
+
rb_ary_push(array, rbs_struct_to_ruby_value(ctx, record_fieldtype->type));
|
1014
|
+
rb_ary_push(array, record_fieldtype->required ? Qtrue : Qfalse);
|
1015
|
+
return array;
|
1016
|
+
}
|
1017
|
+
case RBS_TYPES_TUPLE: {
|
1018
|
+
rbs_types_tuple_t *node = (rbs_types_tuple_t *) instance;
|
1019
|
+
|
1020
|
+
VALUE h = rb_hash_new();
|
1021
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
1022
|
+
rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
|
1023
|
+
|
1024
|
+
return CLASS_NEW_INSTANCE(
|
1025
|
+
RBS_Types_Tuple,
|
1026
|
+
1,
|
1027
|
+
&h
|
1028
|
+
);
|
1029
|
+
}
|
1030
|
+
case RBS_TYPES_UNION: {
|
1031
|
+
rbs_types_union_t *node = (rbs_types_union_t *) instance;
|
1032
|
+
|
1033
|
+
VALUE h = rb_hash_new();
|
1034
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
1035
|
+
rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
|
1036
|
+
|
1037
|
+
return CLASS_NEW_INSTANCE(
|
1038
|
+
RBS_Types_Union,
|
1039
|
+
1,
|
1040
|
+
&h
|
1041
|
+
);
|
1042
|
+
}
|
1043
|
+
case RBS_TYPES_UNTYPED_FUNCTION: {
|
1044
|
+
rbs_types_untyped_function_t *node = (rbs_types_untyped_function_t *) instance;
|
1045
|
+
|
1046
|
+
VALUE h = rb_hash_new();
|
1047
|
+
rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
|
1048
|
+
|
1049
|
+
return CLASS_NEW_INSTANCE(
|
1050
|
+
RBS_Types_UntypedFunction,
|
1051
|
+
1,
|
1052
|
+
&h
|
1053
|
+
);
|
1054
|
+
}
|
1055
|
+
case RBS_TYPES_VARIABLE: {
|
1056
|
+
rbs_types_variable_t *node = (rbs_types_variable_t *) instance;
|
1057
|
+
|
1058
|
+
VALUE h = rb_hash_new();
|
1059
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
1060
|
+
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
1061
|
+
|
1062
|
+
return CLASS_NEW_INSTANCE(
|
1063
|
+
RBS_Types_Variable,
|
1064
|
+
1,
|
1065
|
+
&h
|
1066
|
+
);
|
1067
|
+
}
|
1068
|
+
case RBS_KEYWORD: {
|
1069
|
+
rbs_constant_t *constant = rbs_constant_pool_id_to_constant(RBS_GLOBAL_CONSTANT_POOL, ((rbs_keyword_t *) instance)->constant_id);
|
1070
|
+
assert(constant != NULL && "constant is NULL");
|
1071
|
+
assert(constant->start != NULL && "constant->start is NULL");
|
1072
|
+
|
1073
|
+
return ID2SYM(rb_intern2((const char *) constant->start, constant->length));
|
1074
|
+
}
|
1075
|
+
case RBS_AST_SYMBOL: {
|
1076
|
+
rbs_constant_t *constant = rbs_constant_pool_id_to_constant(ctx.constant_pool, ((rbs_keyword_t *) instance)->constant_id);
|
1077
|
+
assert(constant != NULL && "constant is NULL");
|
1078
|
+
assert(constant->start != NULL && "constant->start is NULL");
|
1079
|
+
|
1080
|
+
return ID2SYM(rb_intern3((const char *) constant->start, constant->length, ctx.encoding));
|
1081
|
+
}
|
1148
1082
|
}
|
1149
1083
|
|
1150
1084
|
rb_raise(rb_eRuntimeError, "Unknown node type: %d", instance->type);
|