rbs 3.9.2 → 4.0.0.dev.1

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