rbs 3.10.0 → 4.0.0.dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +3 -3
  3. data/.github/workflows/ruby.yml +24 -35
  4. data/.github/workflows/typecheck.yml +3 -1
  5. data/.github/workflows/windows.yml +2 -2
  6. data/.gitignore +0 -4
  7. data/CHANGELOG.md +0 -88
  8. data/README.md +1 -38
  9. data/Rakefile +20 -142
  10. data/Steepfile +1 -0
  11. data/config.yml +43 -1
  12. data/core/array.rbs +46 -100
  13. data/core/complex.rbs +21 -32
  14. data/core/dir.rbs +2 -2
  15. data/core/encoding.rbs +9 -6
  16. data/core/enumerable.rbs +3 -90
  17. data/core/enumerator.rbs +1 -18
  18. data/core/errno.rbs +0 -8
  19. data/core/errors.rbs +1 -28
  20. data/core/exception.rbs +2 -2
  21. data/core/fiber.rbs +4 -5
  22. data/core/file.rbs +12 -27
  23. data/core/file_test.rbs +1 -1
  24. data/core/float.rbs +22 -209
  25. data/core/gc.rbs +281 -417
  26. data/core/hash.rbs +727 -1024
  27. data/core/integer.rbs +38 -78
  28. data/core/io/buffer.rbs +7 -18
  29. data/core/io/wait.rbs +33 -11
  30. data/core/io.rbs +12 -14
  31. data/core/kernel.rbs +51 -57
  32. data/core/marshal.rbs +1 -1
  33. data/core/match_data.rbs +1 -1
  34. data/core/math.rbs +3 -42
  35. data/core/method.rbs +6 -14
  36. data/core/module.rbs +17 -88
  37. data/core/nil_class.rbs +3 -3
  38. data/core/numeric.rbs +16 -16
  39. data/core/object.rbs +3 -3
  40. data/core/object_space.rbs +15 -21
  41. data/core/proc.rbs +8 -15
  42. data/core/process.rbs +2 -2
  43. data/core/ractor.rbs +437 -278
  44. data/core/range.rbs +8 -7
  45. data/core/rational.rbs +24 -37
  46. data/core/rbs/unnamed/argf.rbs +2 -2
  47. data/core/rbs/unnamed/env_class.rbs +1 -1
  48. data/core/rbs/unnamed/random.rbs +2 -4
  49. data/core/regexp.rbs +20 -25
  50. data/core/ruby_vm.rbs +4 -6
  51. data/core/rubygems/errors.rbs +70 -3
  52. data/core/rubygems/rubygems.rbs +79 -11
  53. data/core/rubygems/version.rbs +3 -2
  54. data/core/set.rbs +359 -488
  55. data/core/string.rbs +1228 -3153
  56. data/core/struct.rbs +1 -1
  57. data/core/symbol.rbs +4 -4
  58. data/core/thread.rbs +29 -92
  59. data/core/time.rbs +9 -35
  60. data/core/trace_point.rbs +4 -7
  61. data/core/unbound_method.rbs +6 -14
  62. data/docs/collection.md +2 -2
  63. data/docs/gem.md +1 -0
  64. data/docs/sigs.md +3 -3
  65. data/ext/rbs_extension/ast_translation.c +1077 -944
  66. data/ext/rbs_extension/ast_translation.h +0 -7
  67. data/ext/rbs_extension/class_constants.c +83 -71
  68. data/ext/rbs_extension/class_constants.h +7 -4
  69. data/ext/rbs_extension/extconf.rb +2 -24
  70. data/ext/rbs_extension/legacy_location.c +172 -173
  71. data/ext/rbs_extension/legacy_location.h +3 -8
  72. data/ext/rbs_extension/main.c +289 -239
  73. data/ext/rbs_extension/rbs_extension.h +0 -3
  74. data/ext/rbs_extension/rbs_string_bridging.h +0 -4
  75. data/include/rbs/ast.h +98 -37
  76. data/include/rbs/defines.h +12 -38
  77. data/include/rbs/lexer.h +114 -126
  78. data/include/rbs/location.h +14 -14
  79. data/include/rbs/parser.h +37 -21
  80. data/include/rbs/string.h +5 -3
  81. data/include/rbs/util/rbs_allocator.h +19 -40
  82. data/include/rbs/util/rbs_assert.h +1 -12
  83. data/include/rbs/util/rbs_constant_pool.h +3 -3
  84. data/include/rbs/util/rbs_encoding.h +1 -3
  85. data/include/rbs/util/rbs_unescape.h +1 -2
  86. data/lib/rbs/ast/ruby/annotations.rb +119 -0
  87. data/lib/rbs/ast/ruby/comment_block.rb +221 -0
  88. data/lib/rbs/ast/ruby/declarations.rb +86 -0
  89. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
  90. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  91. data/lib/rbs/ast/ruby/members.rb +213 -0
  92. data/lib/rbs/buffer.rb +104 -24
  93. data/lib/rbs/cli/validate.rb +40 -35
  94. data/lib/rbs/cli.rb +5 -6
  95. data/lib/rbs/collection/config/lockfile_generator.rb +0 -1
  96. data/lib/rbs/collection.rb +0 -1
  97. data/lib/rbs/definition.rb +6 -1
  98. data/lib/rbs/definition_builder/ancestor_builder.rb +65 -62
  99. data/lib/rbs/definition_builder/method_builder.rb +45 -30
  100. data/lib/rbs/definition_builder.rb +44 -9
  101. data/lib/rbs/environment/class_entry.rb +69 -0
  102. data/lib/rbs/environment/module_entry.rb +66 -0
  103. data/lib/rbs/environment.rb +244 -218
  104. data/lib/rbs/environment_loader.rb +3 -3
  105. data/lib/rbs/errors.rb +5 -4
  106. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  107. data/lib/rbs/inline_parser.rb +206 -0
  108. data/lib/rbs/location_aux.rb +35 -3
  109. data/lib/rbs/parser_aux.rb +11 -6
  110. data/lib/rbs/prototype/runtime.rb +2 -2
  111. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  112. data/lib/rbs/resolver/type_name_resolver.rb +38 -124
  113. data/lib/rbs/source.rb +99 -0
  114. data/lib/rbs/subtractor.rb +4 -3
  115. data/lib/rbs/test/type_check.rb +0 -14
  116. data/lib/rbs/types.rb +1 -3
  117. data/lib/rbs/version.rb +1 -1
  118. data/lib/rbs.rb +13 -1
  119. data/lib/rdoc/discover.rb +1 -1
  120. data/lib/rdoc_plugin/parser.rb +1 -1
  121. data/rbs.gemspec +1 -0
  122. data/sig/ancestor_builder.rbs +1 -1
  123. data/sig/ast/ruby/annotations.rbs +110 -0
  124. data/sig/ast/ruby/comment_block.rbs +119 -0
  125. data/sig/ast/ruby/declarations.rbs +60 -0
  126. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  127. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  128. data/sig/ast/ruby/members.rbs +72 -0
  129. data/sig/buffer.rbs +63 -5
  130. data/sig/definition.rbs +1 -0
  131. data/sig/definition_builder.rbs +1 -1
  132. data/sig/environment/class_entry.rbs +50 -0
  133. data/sig/environment/module_entry.rbs +50 -0
  134. data/sig/environment.rbs +28 -133
  135. data/sig/errors.rbs +13 -6
  136. data/sig/inline_parser/comment_association.rbs +71 -0
  137. data/sig/inline_parser.rbs +87 -0
  138. data/sig/location.rbs +32 -7
  139. data/sig/manifest.yaml +1 -0
  140. data/sig/method_builder.rbs +7 -4
  141. data/sig/parser.rbs +16 -20
  142. data/sig/resolver/type_name_resolver.rbs +7 -38
  143. data/sig/source.rbs +48 -0
  144. data/sig/types.rbs +1 -4
  145. data/src/ast.c +290 -201
  146. data/src/lexer.c +2813 -2902
  147. data/src/lexer.re +4 -0
  148. data/src/lexstate.c +155 -169
  149. data/src/location.c +40 -40
  150. data/src/parser.c +2665 -2433
  151. data/src/string.c +48 -0
  152. data/src/util/rbs_allocator.c +77 -80
  153. data/src/util/rbs_assert.c +10 -10
  154. data/src/util/rbs_buffer.c +2 -2
  155. data/src/util/rbs_constant_pool.c +15 -13
  156. data/src/util/rbs_encoding.c +4062 -20097
  157. data/src/util/rbs_unescape.c +48 -85
  158. data/stdlib/bigdecimal/0/big_decimal.rbs +82 -100
  159. data/stdlib/bigdecimal-math/0/big_math.rbs +8 -169
  160. data/stdlib/cgi/0/core.rbs +396 -2
  161. data/stdlib/cgi/0/manifest.yaml +0 -1
  162. data/stdlib/coverage/0/coverage.rbs +1 -3
  163. data/stdlib/date/0/date.rbs +59 -67
  164. data/stdlib/date/0/date_time.rbs +1 -1
  165. data/stdlib/delegate/0/delegator.rbs +7 -10
  166. data/stdlib/erb/0/erb.rbs +347 -737
  167. data/stdlib/fileutils/0/fileutils.rbs +13 -18
  168. data/stdlib/forwardable/0/forwardable.rbs +0 -3
  169. data/stdlib/json/0/json.rbs +48 -68
  170. data/stdlib/net-http/0/net-http.rbs +0 -3
  171. data/stdlib/objspace/0/objspace.rbs +4 -9
  172. data/stdlib/open-uri/0/open-uri.rbs +0 -40
  173. data/stdlib/openssl/0/openssl.rbs +228 -331
  174. data/stdlib/optparse/0/optparse.rbs +3 -3
  175. data/{core → stdlib/pathname/0}/pathname.rbs +355 -255
  176. data/stdlib/psych/0/psych.rbs +3 -3
  177. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  178. data/stdlib/resolv/0/resolv.rbs +68 -25
  179. data/stdlib/ripper/0/ripper.rbs +2 -5
  180. data/stdlib/singleton/0/singleton.rbs +0 -3
  181. data/stdlib/socket/0/socket.rbs +1 -13
  182. data/stdlib/socket/0/tcp_socket.rbs +2 -10
  183. data/stdlib/stringio/0/stringio.rbs +85 -1176
  184. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  185. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  186. data/stdlib/time/0/time.rbs +1 -1
  187. data/stdlib/timeout/0/timeout.rbs +7 -63
  188. data/stdlib/tsort/0/cyclic.rbs +0 -3
  189. data/stdlib/uri/0/common.rbs +2 -11
  190. data/stdlib/uri/0/file.rbs +1 -1
  191. data/stdlib/uri/0/generic.rbs +16 -17
  192. data/stdlib/uri/0/rfc2396_parser.rbs +7 -6
  193. data/stdlib/zlib/0/zstream.rbs +0 -1
  194. metadata +40 -12
  195. data/.clang-format +0 -74
  196. data/.clangd +0 -2
  197. data/.github/workflows/c-check.yml +0 -54
  198. data/core/ruby.rbs +0 -53
  199. data/docs/aliases.md +0 -79
  200. data/docs/encoding.md +0 -56
  201. data/ext/rbs_extension/compat.h +0 -10
  202. data/stdlib/cgi-escape/0/escape.rbs +0 -153
@@ -11,9 +11,6 @@
11
11
  #include "rbs_string_bridging.h"
12
12
  #include "legacy_location.h"
13
13
 
14
- VALUE EMPTY_ARRAY;
15
- VALUE EMPTY_HASH;
16
-
17
14
  #define RBS_LOC_CHILDREN_SIZE(cap) (sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * ((cap) - 1))
18
15
 
19
16
  rbs_translation_context_t rbs_translation_context_create(rbs_constant_pool_t *constant_pool, VALUE buffer, rb_encoding *ruby_encoding) {
@@ -35,10 +32,6 @@ VALUE rbs_node_list_to_ruby_array(rbs_translation_context_t ctx, rbs_node_list_t
35
32
  }
36
33
 
37
34
  VALUE rbs_hash_to_ruby_hash(rbs_translation_context_t ctx, rbs_hash_t *rbs_hash) {
38
- if (!rbs_hash->head) {
39
- return EMPTY_HASH;
40
- }
41
-
42
35
  VALUE ruby_hash = rb_hash_new();
43
36
 
44
37
  for (rbs_hash_node_t *n = rbs_hash->head; n != NULL; n = n->next) {
@@ -51,28 +44,28 @@ VALUE rbs_hash_to_ruby_hash(rbs_translation_context_t ctx, rbs_hash_t *rbs_hash)
51
44
  }
52
45
 
53
46
  VALUE rbs_loc_to_ruby_location(rbs_translation_context_t ctx, rbs_location_t *source_loc) {
54
- if (source_loc == NULL) {
55
- return Qnil;
56
- }
47
+ if (source_loc == NULL) {
48
+ return Qnil;
49
+ }
57
50
 
58
- VALUE new_loc = rbs_new_location(ctx.buffer, source_loc->rg);
59
- 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);
60
53
 
61
- if (source_loc->children != NULL) {
62
- rbs_loc_legacy_alloc_children(new_loc_struct, source_loc->children->cap);
63
- memcpy(new_loc_struct->children, source_loc->children, RBS_LOC_CHILDREN_SIZE(source_loc->children->cap));
64
- }
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
+ }
65
58
 
66
- return new_loc;
59
+ return new_loc;
67
60
  }
68
61
 
69
62
  VALUE rbs_location_list_to_ruby_array(rbs_translation_context_t ctx, rbs_location_list_t *list) {
63
+ VALUE ruby_array = rb_ary_new();
64
+
70
65
  if (list == NULL) {
71
- return EMPTY_ARRAY;
66
+ return ruby_array;
72
67
  }
73
68
 
74
- VALUE ruby_array = rb_ary_new();
75
-
76
69
  for (rbs_location_list_node_t *n = list->head; n != NULL; n = n->next) {
77
70
  rb_ary_push(ruby_array, rbs_loc_to_ruby_location(ctx, n->loc));
78
71
  }
@@ -81,936 +74,1076 @@ VALUE rbs_location_list_to_ruby_array(rbs_translation_context_t ctx, rbs_locatio
81
74
  }
82
75
 
83
76
  #ifdef RB_PASS_KEYWORDS
84
- // Ruby 2.7 or later
85
- #define CLASS_NEW_INSTANCE(klass, argc, argv) \
86
- 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)
87
80
  #else
88
- // Ruby 2.6
89
- #define CLASS_NEW_INSTANCE(receiver, argc, argv) \
90
- 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)
91
84
  #endif
92
85
 
93
86
  VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instance) {
94
87
  if (instance == NULL) return Qnil;
95
88
 
96
89
  switch (instance->type) {
97
- case RBS_AST_ANNOTATION: {
98
- rbs_ast_annotation_t *node = (rbs_ast_annotation_t *) instance;
99
-
100
- VALUE h = rb_hash_new();
101
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
102
- rb_hash_aset(h, ID2SYM(rb_intern("string")), rbs_string_to_ruby_string(&node->string, ctx.encoding));
103
-
104
- return CLASS_NEW_INSTANCE(
105
- RBS_AST_Annotation,
106
- 1,
107
- &h
108
- );
109
- }
110
- case RBS_AST_BOOL: {
111
- return ((rbs_ast_bool_t *) instance)->value ? Qtrue : Qfalse;
112
- }
113
- case RBS_AST_COMMENT: {
114
- rbs_ast_comment_t *node = (rbs_ast_comment_t *) instance;
115
-
116
- VALUE h = rb_hash_new();
117
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
118
- rb_hash_aset(h, ID2SYM(rb_intern("string")), rbs_string_to_ruby_string(&node->string, ctx.encoding));
119
-
120
- return CLASS_NEW_INSTANCE(
121
- RBS_AST_Comment,
122
- 1,
123
- &h
124
- );
125
- }
126
- case RBS_AST_DECLARATIONS_CLASS: {
127
- rbs_ast_declarations_class_t *node = (rbs_ast_declarations_class_t *) instance;
128
-
129
- VALUE h = rb_hash_new();
130
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
131
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
132
- rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
133
- 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
134
- rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
135
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
136
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
137
-
138
- rb_funcall(
139
- RBS_AST_TypeParam,
140
- rb_intern("resolve_variables"),
141
- 1,
142
- rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
143
- );
144
- return CLASS_NEW_INSTANCE(
145
- RBS_AST_Declarations_Class,
146
- 1,
147
- &h
148
- );
149
- }
150
- case RBS_AST_DECLARATIONS_CLASS_SUPER: {
151
- rbs_ast_declarations_class_super_t *node = (rbs_ast_declarations_class_super_t *) instance;
152
-
153
- VALUE h = rb_hash_new();
154
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
155
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
156
- rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
157
-
158
- return CLASS_NEW_INSTANCE(
159
- RBS_AST_Declarations_Class_Super,
160
- 1,
161
- &h
162
- );
163
- }
164
- case RBS_AST_DECLARATIONS_CLASS_ALIAS: {
165
- rbs_ast_declarations_class_alias_t *node = (rbs_ast_declarations_class_alias_t *) instance;
166
-
167
- VALUE h = rb_hash_new();
168
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
169
- rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_type_name
170
- rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_type_name
171
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
172
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
173
-
174
- return CLASS_NEW_INSTANCE(
175
- RBS_AST_Declarations_ClassAlias,
176
- 1,
177
- &h
178
- );
179
- }
180
- case RBS_AST_DECLARATIONS_CONSTANT: {
181
- rbs_ast_declarations_constant_t *node = (rbs_ast_declarations_constant_t *) instance;
182
-
183
- VALUE h = rb_hash_new();
184
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
185
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
186
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
187
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
188
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
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
- return CLASS_NEW_INSTANCE(
207
- RBS_AST_Declarations_Global,
208
- 1,
209
- &h
210
- );
211
- }
212
- case RBS_AST_DECLARATIONS_INTERFACE: {
213
- rbs_ast_declarations_interface_t *node = (rbs_ast_declarations_interface_t *) instance;
214
-
215
- VALUE h = rb_hash_new();
216
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
217
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
218
- rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
219
- rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
220
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
221
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
222
-
223
- rb_funcall(
224
- RBS_AST_TypeParam,
225
- rb_intern("resolve_variables"),
226
- 1,
227
- rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
228
- );
229
- return CLASS_NEW_INSTANCE(
230
- RBS_AST_Declarations_Interface,
231
- 1,
232
- &h
233
- );
234
- }
235
- case RBS_AST_DECLARATIONS_MODULE: {
236
- rbs_ast_declarations_module_t *node = (rbs_ast_declarations_module_t *) instance;
237
-
238
- VALUE h = rb_hash_new();
239
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
240
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
241
- rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
242
- rb_hash_aset(h, ID2SYM(rb_intern("self_types")), rbs_node_list_to_ruby_array(ctx, node->self_types));
243
- rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
244
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
245
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
246
-
247
- rb_funcall(
248
- RBS_AST_TypeParam,
249
- rb_intern("resolve_variables"),
250
- 1,
251
- rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
252
- );
253
- return CLASS_NEW_INSTANCE(
254
- RBS_AST_Declarations_Module,
255
- 1,
256
- &h
257
- );
258
- }
259
- case RBS_AST_DECLARATIONS_MODULE_SELF: {
260
- rbs_ast_declarations_module_self_t *node = (rbs_ast_declarations_module_self_t *) instance;
261
-
262
- VALUE h = rb_hash_new();
263
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
264
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
265
- rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
266
-
267
- return CLASS_NEW_INSTANCE(
268
- RBS_AST_Declarations_Module_Self,
269
- 1,
270
- &h
271
- );
272
- }
273
- case RBS_AST_DECLARATIONS_MODULE_ALIAS: {
274
- rbs_ast_declarations_module_alias_t *node = (rbs_ast_declarations_module_alias_t *) instance;
275
-
276
- VALUE h = rb_hash_new();
277
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
278
- rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_type_name
279
- rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_type_name
280
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
281
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
282
-
283
- return CLASS_NEW_INSTANCE(
284
- RBS_AST_Declarations_ModuleAlias,
285
- 1,
286
- &h
287
- );
288
- }
289
- case RBS_AST_DECLARATIONS_TYPE_ALIAS: {
290
- rbs_ast_declarations_type_alias_t *node = (rbs_ast_declarations_type_alias_t *) instance;
291
-
292
- VALUE h = rb_hash_new();
293
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
294
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
295
- rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
296
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
297
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
298
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
299
-
300
- rb_funcall(
301
- RBS_AST_TypeParam,
302
- rb_intern("resolve_variables"),
303
- 1,
304
- rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
305
- );
306
- return CLASS_NEW_INSTANCE(
307
- RBS_AST_Declarations_TypeAlias,
308
- 1,
309
- &h
310
- );
311
- }
312
- case RBS_AST_DIRECTIVES_USE: {
313
- rbs_ast_directives_use_t *node = (rbs_ast_directives_use_t *) instance;
314
-
315
- VALUE h = rb_hash_new();
316
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
317
- rb_hash_aset(h, ID2SYM(rb_intern("clauses")), rbs_node_list_to_ruby_array(ctx, node->clauses));
318
-
319
- return CLASS_NEW_INSTANCE(
320
- RBS_AST_Directives_Use,
321
- 1,
322
- &h
323
- );
324
- }
325
- case RBS_AST_DIRECTIVES_USE_SINGLE_CLAUSE: {
326
- rbs_ast_directives_use_single_clause_t *node = (rbs_ast_directives_use_single_clause_t *) instance;
327
-
328
- VALUE h = rb_hash_new();
329
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
330
- rb_hash_aset(h, ID2SYM(rb_intern("type_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_name)); // rbs_type_name
331
- rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_ast_symbol
332
-
333
- return CLASS_NEW_INSTANCE(
334
- RBS_AST_Directives_Use_SingleClause,
335
- 1,
336
- &h
337
- );
338
- }
339
- case RBS_AST_DIRECTIVES_USE_WILDCARD_CLAUSE: {
340
- rbs_ast_directives_use_wildcard_clause_t *node = (rbs_ast_directives_use_wildcard_clause_t *) instance;
341
-
342
- VALUE h = rb_hash_new();
343
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
344
- rb_hash_aset(h, ID2SYM(rb_intern("namespace")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rbs_namespace)); // rbs_namespace
345
-
346
- return CLASS_NEW_INSTANCE(
347
- RBS_AST_Directives_Use_WildcardClause,
348
- 1,
349
- &h
350
- );
351
- }
352
- case RBS_AST_INTEGER: {
353
- rbs_ast_integer_t *integer_node = (rbs_ast_integer_t *) instance;
354
- rbs_string_t string_repr = integer_node->string_representation;
355
-
356
- VALUE str = rb_enc_str_new(string_repr.start, rbs_string_len(string_repr), rb_utf8_encoding());
357
-
358
- return rb_funcall(str, rb_intern("to_i"), 0);
359
- }
360
- case RBS_AST_MEMBERS_ALIAS: {
361
- rbs_ast_members_alias_t *node = (rbs_ast_members_alias_t *) instance;
362
-
363
- VALUE h = rb_hash_new();
364
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
365
- rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_ast_symbol
366
- rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_ast_symbol
367
- rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
368
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
369
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
370
-
371
- return CLASS_NEW_INSTANCE(
372
- RBS_AST_Members_Alias,
373
- 1,
374
- &h
375
- );
376
- }
377
- case RBS_AST_MEMBERS_ATTR_ACCESSOR: {
378
- rbs_ast_members_attr_accessor_t *node = (rbs_ast_members_attr_accessor_t *) instance;
379
-
380
- VALUE h = rb_hash_new();
381
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
382
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
383
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
384
- rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_node
385
- rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
386
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
387
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
388
- rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
389
-
390
- return CLASS_NEW_INSTANCE(
391
- RBS_AST_Members_AttrAccessor,
392
- 1,
393
- &h
394
- );
395
- }
396
- case RBS_AST_MEMBERS_ATTR_READER: {
397
- rbs_ast_members_attr_reader_t *node = (rbs_ast_members_attr_reader_t *) instance;
398
-
399
- VALUE h = rb_hash_new();
400
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
401
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
402
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
403
- rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_node
404
- rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
405
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
406
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
407
- rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
408
-
409
- return CLASS_NEW_INSTANCE(
410
- RBS_AST_Members_AttrReader,
411
- 1,
412
- &h
413
- );
414
- }
415
- case RBS_AST_MEMBERS_ATTR_WRITER: {
416
- rbs_ast_members_attr_writer_t *node = (rbs_ast_members_attr_writer_t *) instance;
417
-
418
- VALUE h = rb_hash_new();
419
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
420
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
421
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
422
- rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_node
423
- rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
424
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
425
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
426
- rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
427
-
428
- return CLASS_NEW_INSTANCE(
429
- RBS_AST_Members_AttrWriter,
430
- 1,
431
- &h
432
- );
433
- }
434
- case RBS_AST_MEMBERS_CLASS_INSTANCE_VARIABLE: {
435
- rbs_ast_members_class_instance_variable_t *node = (rbs_ast_members_class_instance_variable_t *) instance;
436
-
437
- VALUE h = rb_hash_new();
438
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
439
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
440
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
441
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
442
-
443
- return CLASS_NEW_INSTANCE(
444
- RBS_AST_Members_ClassInstanceVariable,
445
- 1,
446
- &h
447
- );
448
- }
449
- case RBS_AST_MEMBERS_CLASS_VARIABLE: {
450
- rbs_ast_members_class_variable_t *node = (rbs_ast_members_class_variable_t *) instance;
451
-
452
- VALUE h = rb_hash_new();
453
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
454
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
455
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
456
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
457
-
458
- return CLASS_NEW_INSTANCE(
459
- RBS_AST_Members_ClassVariable,
460
- 1,
461
- &h
462
- );
463
- }
464
- case RBS_AST_MEMBERS_EXTEND: {
465
- rbs_ast_members_extend_t *node = (rbs_ast_members_extend_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_type_name
470
- rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
471
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
472
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
473
-
474
- return CLASS_NEW_INSTANCE(
475
- RBS_AST_Members_Extend,
476
- 1,
477
- &h
478
- );
479
- }
480
- case RBS_AST_MEMBERS_INCLUDE: {
481
- rbs_ast_members_include_t *node = (rbs_ast_members_include_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
- return CLASS_NEW_INSTANCE(
491
- RBS_AST_Members_Include,
492
- 1,
493
- &h
494
- );
495
- }
496
- case RBS_AST_MEMBERS_INSTANCE_VARIABLE: {
497
- rbs_ast_members_instance_variable_t *node = (rbs_ast_members_instance_variable_t *) instance;
498
-
499
- VALUE h = rb_hash_new();
500
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
501
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
502
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
503
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
504
-
505
- return CLASS_NEW_INSTANCE(
506
- RBS_AST_Members_InstanceVariable,
507
- 1,
508
- &h
509
- );
510
- }
511
- case RBS_AST_MEMBERS_METHOD_DEFINITION: {
512
- rbs_ast_members_method_definition_t *node = (rbs_ast_members_method_definition_t *) instance;
513
-
514
- VALUE h = rb_hash_new();
515
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
516
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
517
- rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->kind)); // rbs_keyword
518
- rb_hash_aset(h, ID2SYM(rb_intern("overloads")), rbs_node_list_to_ruby_array(ctx, node->overloads));
519
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
520
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
521
- rb_hash_aset(h, ID2SYM(rb_intern("overloading")), node->overloading ? Qtrue : Qfalse);
522
- rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->visibility)); // rbs_keyword
523
-
524
- return CLASS_NEW_INSTANCE(
525
- RBS_AST_Members_MethodDefinition,
526
- 1,
527
- &h
528
- );
529
- }
530
- case RBS_AST_MEMBERS_METHOD_DEFINITION_OVERLOAD: {
531
- rbs_ast_members_method_definition_overload_t *node = (rbs_ast_members_method_definition_overload_t *) instance;
532
-
533
- VALUE h = rb_hash_new();
534
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
535
- rb_hash_aset(h, ID2SYM(rb_intern("method_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->method_type)); // rbs_node
536
-
537
- return CLASS_NEW_INSTANCE(
538
- RBS_AST_Members_MethodDefinition_Overload,
539
- 1,
540
- &h
541
- );
542
- }
543
- case RBS_AST_MEMBERS_PREPEND: {
544
- rbs_ast_members_prepend_t *node = (rbs_ast_members_prepend_t *) instance;
545
-
546
- VALUE h = rb_hash_new();
547
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
548
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
549
- rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
550
- rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
551
- rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
552
-
553
- return CLASS_NEW_INSTANCE(
554
- RBS_AST_Members_Prepend,
555
- 1,
556
- &h
557
- );
558
- }
559
- case RBS_AST_MEMBERS_PRIVATE: {
560
- rbs_ast_members_private_t *node = (rbs_ast_members_private_t *) instance;
561
-
562
- VALUE h = rb_hash_new();
563
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
564
-
565
- return CLASS_NEW_INSTANCE(
566
- RBS_AST_Members_Private,
567
- 1,
568
- &h
569
- );
570
- }
571
- case RBS_AST_MEMBERS_PUBLIC: {
572
- rbs_ast_members_public_t *node = (rbs_ast_members_public_t *) instance;
573
-
574
- VALUE h = rb_hash_new();
575
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
576
-
577
- return CLASS_NEW_INSTANCE(
578
- RBS_AST_Members_Public,
579
- 1,
580
- &h
581
- );
582
- }
583
- case RBS_AST_STRING: {
584
- rbs_ast_string_t *string_node = (rbs_ast_string_t *) instance;
585
- rbs_string_t s = string_node->string;
586
-
587
- return rb_enc_str_new(s.start, rbs_string_len(s), rb_utf8_encoding());
588
- }
589
- case RBS_AST_TYPE_PARAM: {
590
- rbs_ast_type_param_t *node = (rbs_ast_type_param_t *) instance;
591
-
592
- VALUE h = rb_hash_new();
593
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
594
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
595
- rb_hash_aset(h, ID2SYM(rb_intern("variance")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->variance)); // rbs_keyword
596
- rb_hash_aset(h, ID2SYM(rb_intern("upper_bound")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->upper_bound)); // rbs_node
597
- rb_hash_aset(h, ID2SYM(rb_intern("default_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->default_type)); // rbs_node
598
- rb_hash_aset(h, ID2SYM(rb_intern("unchecked")), node->unchecked ? Qtrue : Qfalse);
599
-
600
- return CLASS_NEW_INSTANCE(
601
- RBS_AST_TypeParam,
602
- 1,
603
- &h
604
- );
605
- }
606
- case RBS_METHOD_TYPE: {
607
- rbs_method_type_t *node = (rbs_method_type_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("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
612
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
613
- rb_hash_aset(h, ID2SYM(rb_intern("block")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->block)); // rbs_types_block
614
-
615
- rb_funcall(
616
- RBS_AST_TypeParam,
617
- rb_intern("resolve_variables"),
618
- 1,
619
- rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
620
- );
621
- return CLASS_NEW_INSTANCE(
622
- RBS_MethodType,
623
- 1,
624
- &h
625
- );
626
- }
627
- case RBS_NAMESPACE: {
628
- rbs_namespace_t *node = (rbs_namespace_t *) instance;
629
-
630
- VALUE h = rb_hash_new();
631
- rb_hash_aset(h, ID2SYM(rb_intern("path")), rbs_node_list_to_ruby_array(ctx, node->path));
632
- rb_hash_aset(h, ID2SYM(rb_intern("absolute")), node->absolute ? Qtrue : Qfalse);
633
-
634
- return CLASS_NEW_INSTANCE(
635
- RBS_Namespace,
636
- 1,
637
- &h
638
- );
639
- }
640
- case RBS_SIGNATURE: {
641
- rbs_signature_t *signature = (rbs_signature_t *) instance;
642
-
643
- VALUE array = rb_ary_new();
644
- rb_ary_push(array, rbs_node_list_to_ruby_array(ctx, signature->directives));
645
- rb_ary_push(array, rbs_node_list_to_ruby_array(ctx, signature->declarations));
646
- return array;
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
+ }
647
1148
  }
648
- case RBS_TYPE_NAME: {
649
- rbs_type_name_t *node = (rbs_type_name_t *) instance;
650
-
651
- VALUE h = rb_hash_new();
652
- rb_hash_aset(h, ID2SYM(rb_intern("namespace")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rbs_namespace)); // rbs_namespace
653
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
654
-
655
- return CLASS_NEW_INSTANCE(
656
- RBS_TypeName,
657
- 1,
658
- &h
659
- );
660
- }
661
- case RBS_TYPES_ALIAS: {
662
- rbs_types_alias_t *node = (rbs_types_alias_t *) instance;
663
-
664
- VALUE h = rb_hash_new();
665
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
666
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
667
- rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
668
-
669
- return CLASS_NEW_INSTANCE(
670
- RBS_Types_Alias,
671
- 1,
672
- &h
673
- );
674
- }
675
- case RBS_TYPES_BASES_ANY: {
676
- rbs_types_bases_any_t *node = (rbs_types_bases_any_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("todo")), node->todo ? Qtrue : Qfalse);
681
-
682
- return CLASS_NEW_INSTANCE(
683
- RBS_Types_Bases_Any,
684
- 1,
685
- &h
686
- );
687
- }
688
- case RBS_TYPES_BASES_BOOL: {
689
- rbs_types_bases_bool_t *node = (rbs_types_bases_bool_t *) instance;
690
-
691
- VALUE h = rb_hash_new();
692
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
693
-
694
- return CLASS_NEW_INSTANCE(
695
- RBS_Types_Bases_Bool,
696
- 1,
697
- &h
698
- );
699
- }
700
- case RBS_TYPES_BASES_BOTTOM: {
701
- rbs_types_bases_bottom_t *node = (rbs_types_bases_bottom_t *) instance;
702
-
703
- VALUE h = rb_hash_new();
704
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
705
-
706
- return CLASS_NEW_INSTANCE(
707
- RBS_Types_Bases_Bottom,
708
- 1,
709
- &h
710
- );
711
- }
712
- case RBS_TYPES_BASES_CLASS: {
713
- rbs_types_bases_class_t *node = (rbs_types_bases_class_t *) instance;
714
-
715
- VALUE h = rb_hash_new();
716
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
717
-
718
- return CLASS_NEW_INSTANCE(
719
- RBS_Types_Bases_Class,
720
- 1,
721
- &h
722
- );
723
- }
724
- case RBS_TYPES_BASES_INSTANCE: {
725
- rbs_types_bases_instance_t *node = (rbs_types_bases_instance_t *) instance;
726
-
727
- VALUE h = rb_hash_new();
728
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
729
-
730
- return CLASS_NEW_INSTANCE(
731
- RBS_Types_Bases_Instance,
732
- 1,
733
- &h
734
- );
735
- }
736
- case RBS_TYPES_BASES_NIL: {
737
- rbs_types_bases_nil_t *node = (rbs_types_bases_nil_t *) instance;
738
-
739
- VALUE h = rb_hash_new();
740
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
741
-
742
- return CLASS_NEW_INSTANCE(
743
- RBS_Types_Bases_Nil,
744
- 1,
745
- &h
746
- );
747
- }
748
- case RBS_TYPES_BASES_SELF: {
749
- rbs_types_bases_self_t *node = (rbs_types_bases_self_t *) instance;
750
-
751
- VALUE h = rb_hash_new();
752
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
753
-
754
- return CLASS_NEW_INSTANCE(
755
- RBS_Types_Bases_Self,
756
- 1,
757
- &h
758
- );
759
- }
760
- case RBS_TYPES_BASES_TOP: {
761
- rbs_types_bases_top_t *node = (rbs_types_bases_top_t *) instance;
762
-
763
- VALUE h = rb_hash_new();
764
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
765
-
766
- return CLASS_NEW_INSTANCE(
767
- RBS_Types_Bases_Top,
768
- 1,
769
- &h
770
- );
771
- }
772
- case RBS_TYPES_BASES_VOID: {
773
- rbs_types_bases_void_t *node = (rbs_types_bases_void_t *) instance;
774
-
775
- VALUE h = rb_hash_new();
776
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
777
-
778
- return CLASS_NEW_INSTANCE(
779
- RBS_Types_Bases_Void,
780
- 1,
781
- &h
782
- );
783
- }
784
- case RBS_TYPES_BLOCK: {
785
- rbs_types_block_t *node = (rbs_types_block_t *) instance;
786
-
787
- VALUE h = rb_hash_new();
788
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
789
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
790
- rb_hash_aset(h, ID2SYM(rb_intern("required")), node->required ? Qtrue : Qfalse);
791
- rb_hash_aset(h, ID2SYM(rb_intern("self_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->self_type)); // rbs_node
792
-
793
- return CLASS_NEW_INSTANCE(
794
- RBS_Types_Block,
795
- 1,
796
- &h
797
- );
798
- }
799
- case RBS_TYPES_CLASS_INSTANCE: {
800
- rbs_types_class_instance_t *node = (rbs_types_class_instance_t *) instance;
801
-
802
- VALUE h = rb_hash_new();
803
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
804
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
805
- rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
806
-
807
- return CLASS_NEW_INSTANCE(
808
- RBS_Types_ClassInstance,
809
- 1,
810
- &h
811
- );
812
- }
813
- case RBS_TYPES_CLASS_SINGLETON: {
814
- rbs_types_class_singleton_t *node = (rbs_types_class_singleton_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
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
819
-
820
- return CLASS_NEW_INSTANCE(
821
- RBS_Types_ClassSingleton,
822
- 1,
823
- &h
824
- );
825
- }
826
- case RBS_TYPES_FUNCTION: {
827
- rbs_types_function_t *node = (rbs_types_function_t *) instance;
828
-
829
- VALUE h = rb_hash_new();
830
- rb_hash_aset(h, ID2SYM(rb_intern("required_positionals")), rbs_node_list_to_ruby_array(ctx, node->required_positionals));
831
- rb_hash_aset(h, ID2SYM(rb_intern("optional_positionals")), rbs_node_list_to_ruby_array(ctx, node->optional_positionals));
832
- rb_hash_aset(h, ID2SYM(rb_intern("rest_positionals")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rest_positionals)); // rbs_node
833
- rb_hash_aset(h, ID2SYM(rb_intern("trailing_positionals")), rbs_node_list_to_ruby_array(ctx, node->trailing_positionals));
834
- rb_hash_aset(h, ID2SYM(rb_intern("required_keywords")), rbs_hash_to_ruby_hash(ctx, node->required_keywords));
835
- rb_hash_aset(h, ID2SYM(rb_intern("optional_keywords")), rbs_hash_to_ruby_hash(ctx, node->optional_keywords));
836
- rb_hash_aset(h, ID2SYM(rb_intern("rest_keywords")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rest_keywords)); // rbs_node
837
- rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
838
-
839
- return CLASS_NEW_INSTANCE(
840
- RBS_Types_Function,
841
- 1,
842
- &h
843
- );
844
- }
845
- case RBS_TYPES_FUNCTION_PARAM: {
846
- rbs_types_function_param_t *node = (rbs_types_function_param_t *) instance;
847
-
848
- VALUE h = rb_hash_new();
849
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
850
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
851
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
852
-
853
- return CLASS_NEW_INSTANCE(
854
- RBS_Types_Function_Param,
855
- 1,
856
- &h
857
- );
858
- }
859
- case RBS_TYPES_INTERFACE: {
860
- rbs_types_interface_t *node = (rbs_types_interface_t *) instance;
861
-
862
- VALUE h = rb_hash_new();
863
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
864
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
865
- rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
866
-
867
- return CLASS_NEW_INSTANCE(
868
- RBS_Types_Interface,
869
- 1,
870
- &h
871
- );
872
- }
873
- case RBS_TYPES_INTERSECTION: {
874
- rbs_types_intersection_t *node = (rbs_types_intersection_t *) instance;
875
-
876
- VALUE h = rb_hash_new();
877
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
878
- rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
879
-
880
- return CLASS_NEW_INSTANCE(
881
- RBS_Types_Intersection,
882
- 1,
883
- &h
884
- );
885
- }
886
- case RBS_TYPES_LITERAL: {
887
- rbs_types_literal_t *node = (rbs_types_literal_t *) instance;
888
-
889
- VALUE h = rb_hash_new();
890
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
891
- rb_hash_aset(h, ID2SYM(rb_intern("literal")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->literal)); // rbs_node
892
-
893
- return CLASS_NEW_INSTANCE(
894
- RBS_Types_Literal,
895
- 1,
896
- &h
897
- );
898
- }
899
- case RBS_TYPES_OPTIONAL: {
900
- rbs_types_optional_t *node = (rbs_types_optional_t *) instance;
901
-
902
- VALUE h = rb_hash_new();
903
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
904
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
905
-
906
- return CLASS_NEW_INSTANCE(
907
- RBS_Types_Optional,
908
- 1,
909
- &h
910
- );
911
- }
912
- case RBS_TYPES_PROC: {
913
- rbs_types_proc_t *node = (rbs_types_proc_t *) instance;
914
-
915
- VALUE h = rb_hash_new();
916
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
917
- rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
918
- rb_hash_aset(h, ID2SYM(rb_intern("block")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->block)); // rbs_types_block
919
- rb_hash_aset(h, ID2SYM(rb_intern("self_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->self_type)); // rbs_node
920
-
921
- return CLASS_NEW_INSTANCE(
922
- RBS_Types_Proc,
923
- 1,
924
- &h
925
- );
926
- }
927
- case RBS_TYPES_RECORD: {
928
- rbs_types_record_t *node = (rbs_types_record_t *) instance;
929
-
930
- VALUE h = rb_hash_new();
931
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
932
- rb_hash_aset(h, ID2SYM(rb_intern("all_fields")), rbs_hash_to_ruby_hash(ctx, node->all_fields));
933
-
934
- return CLASS_NEW_INSTANCE(
935
- RBS_Types_Record,
936
- 1,
937
- &h
938
- );
939
- }
940
- case RBS_TYPES_RECORD_FIELD_TYPE: {
941
- rbs_types_record_field_type_t *record_fieldtype = (rbs_types_record_field_type_t *) instance;
942
-
943
- VALUE array = rb_ary_new();
944
- rb_ary_push(array, rbs_struct_to_ruby_value(ctx, record_fieldtype->type));
945
- rb_ary_push(array, record_fieldtype->required ? Qtrue : Qfalse);
946
- return array;
947
- }
948
- case RBS_TYPES_TUPLE: {
949
- rbs_types_tuple_t *node = (rbs_types_tuple_t *) instance;
950
-
951
- VALUE h = rb_hash_new();
952
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
953
- rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
954
-
955
- return CLASS_NEW_INSTANCE(
956
- RBS_Types_Tuple,
957
- 1,
958
- &h
959
- );
960
- }
961
- case RBS_TYPES_UNION: {
962
- rbs_types_union_t *node = (rbs_types_union_t *) instance;
963
-
964
- VALUE h = rb_hash_new();
965
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
966
- rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
967
-
968
- return CLASS_NEW_INSTANCE(
969
- RBS_Types_Union,
970
- 1,
971
- &h
972
- );
973
- }
974
- case RBS_TYPES_UNTYPED_FUNCTION: {
975
- rbs_types_untyped_function_t *node = (rbs_types_untyped_function_t *) instance;
976
-
977
- VALUE h = rb_hash_new();
978
- rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
979
-
980
- return CLASS_NEW_INSTANCE(
981
- RBS_Types_UntypedFunction,
982
- 1,
983
- &h
984
- );
985
- }
986
- case RBS_TYPES_VARIABLE: {
987
- rbs_types_variable_t *node = (rbs_types_variable_t *) instance;
988
-
989
- VALUE h = rb_hash_new();
990
- rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
991
- rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
992
-
993
- return CLASS_NEW_INSTANCE(
994
- RBS_Types_Variable,
995
- 1,
996
- &h
997
- );
998
- }
999
- case RBS_KEYWORD: {
1000
- rbs_constant_t *constant = rbs_constant_pool_id_to_constant(RBS_GLOBAL_CONSTANT_POOL, ((rbs_keyword_t *) instance)->constant_id);
1001
- assert(constant != NULL && "constant is NULL");
1002
- assert(constant->start != NULL && "constant->start is NULL");
1003
-
1004
- return ID2SYM(rb_intern2((const char *) constant->start, constant->length));
1005
- }
1006
- case RBS_AST_SYMBOL: {
1007
- rbs_constant_t *constant = rbs_constant_pool_id_to_constant(ctx.constant_pool, ((rbs_keyword_t *) instance)->constant_id);
1008
- assert(constant != NULL && "constant is NULL");
1009
- assert(constant->start != NULL && "constant->start is NULL");
1010
-
1011
- return ID2SYM(rb_intern3((const char *) constant->start, constant->length, ctx.encoding));
1012
- }
1013
- }
1014
-
1015
- rb_raise(rb_eRuntimeError, "Unknown node type: %d", instance->type);
1016
1149
  }