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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +74 -0
  3. data/.clangd +2 -0
  4. data/.github/workflows/c-check.yml +51 -0
  5. data/.github/workflows/dependabot.yml +1 -1
  6. data/.github/workflows/ruby.yml +0 -17
  7. data/.github/workflows/typecheck.yml +0 -2
  8. data/.gitignore +4 -0
  9. data/.rubocop.yml +1 -1
  10. data/.vscode/extensions.json +5 -0
  11. data/.vscode/settings.json +19 -0
  12. data/README.md +37 -0
  13. data/Rakefile +82 -0
  14. data/config.yml +1 -1
  15. data/core/enumerable.rbs +9 -0
  16. data/core/io.rbs +4 -4
  17. data/core/thread.rbs +0 -7
  18. data/ext/rbs_extension/ast_translation.c +1008 -1074
  19. data/ext/rbs_extension/class_constants.c +78 -74
  20. data/ext/rbs_extension/compat.h +3 -3
  21. data/ext/rbs_extension/extconf.rb +11 -1
  22. data/ext/rbs_extension/legacy_location.c +173 -172
  23. data/ext/rbs_extension/legacy_location.h +3 -3
  24. data/ext/rbs_extension/main.c +315 -273
  25. data/include/rbs/ast.h +11 -12
  26. data/include/rbs/defines.h +11 -12
  27. data/include/rbs/lexer.h +105 -105
  28. data/include/rbs/location.h +14 -14
  29. data/include/rbs/parser.h +21 -19
  30. data/include/rbs/string.h +3 -3
  31. data/include/rbs/util/rbs_allocator.h +14 -14
  32. data/include/rbs/util/rbs_constant_pool.h +3 -3
  33. data/include/rbs/util/rbs_encoding.h +1 -1
  34. data/lib/rbs/environment.rb +4 -0
  35. data/lib/rbs/namespace.rb +0 -7
  36. data/lib/rbs/parser_aux.rb +5 -0
  37. data/lib/rbs/type_name.rb +0 -7
  38. data/lib/rbs/types.rb +3 -1
  39. data/lib/rbs/unit_test/convertibles.rb +1 -0
  40. data/lib/rbs/version.rb +1 -1
  41. data/sig/environment.rbs +3 -0
  42. data/sig/namespace.rbs +0 -5
  43. data/sig/parser.rbs +20 -0
  44. data/sig/typename.rbs +0 -5
  45. data/sig/types.rbs +4 -1
  46. data/src/ast.c +216 -214
  47. data/src/lexer.c +2923 -2675
  48. data/src/lexstate.c +155 -155
  49. data/src/location.c +40 -40
  50. data/src/parser.c +2591 -2586
  51. data/src/string.c +2 -2
  52. data/src/util/rbs_allocator.c +7 -9
  53. data/src/util/rbs_assert.c +9 -9
  54. data/src/util/rbs_constant_pool.c +5 -7
  55. data/src/util/rbs_encoding.c +20095 -4056
  56. data/src/util/rbs_unescape.c +33 -32
  57. data/stdlib/json/0/json.rbs +9 -43
  58. data/stdlib/ripper/0/ripper.rbs +3 -0
  59. data/stdlib/socket/0/addrinfo.rbs +2 -2
  60. 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
- if (source_loc == NULL) {
48
- return Qnil;
49
- }
47
+ if (source_loc == NULL) {
48
+ return Qnil;
49
+ }
50
50
 
51
- VALUE new_loc = rbs_new_location(ctx.buffer, source_loc->rg);
52
- rbs_loc *new_loc_struct = rbs_check_location(new_loc);
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
- 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
- }
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
- return new_loc;
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
- // 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)
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
- // Ruby 2.6
82
- #define CLASS_NEW_INSTANCE(receiver, argc, argv)\
83
- rb_class_new_instance(argc, argv, receiver)
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
- 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
- }
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);