rbs 3.9.5 → 4.0.0

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 (330) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +74 -0
  3. data/.clangd +2 -0
  4. data/.github/dependabot.yml +14 -14
  5. data/.github/workflows/bundle-update.yml +60 -0
  6. data/.github/workflows/c-check.yml +58 -0
  7. data/.github/workflows/comments.yml +5 -3
  8. data/.github/workflows/dependabot.yml +2 -2
  9. data/.github/workflows/ruby.yml +40 -32
  10. data/.github/workflows/rust.yml +95 -0
  11. data/.github/workflows/typecheck.yml +2 -2
  12. data/.github/workflows/windows.yml +3 -3
  13. data/.gitignore +4 -0
  14. data/.rubocop.yml +2 -2
  15. data/.vscode/extensions.json +5 -0
  16. data/.vscode/settings.json +19 -0
  17. data/CHANGELOG.md +284 -0
  18. data/README.md +38 -1
  19. data/Rakefile +144 -29
  20. data/Steepfile +2 -0
  21. data/config.yml +634 -62
  22. data/core/array.rbs +307 -227
  23. data/core/basic_object.rbs +9 -8
  24. data/core/binding.rbs +0 -2
  25. data/core/builtin.rbs +2 -2
  26. data/core/class.rbs +6 -5
  27. data/core/comparable.rbs +55 -34
  28. data/core/complex.rbs +104 -78
  29. data/core/dir.rbs +61 -49
  30. data/core/encoding.rbs +12 -15
  31. data/core/enumerable.rbs +188 -87
  32. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  33. data/core/enumerator.rbs +65 -2
  34. data/core/errno.rbs +11 -2
  35. data/core/errors.rbs +58 -29
  36. data/core/exception.rbs +13 -13
  37. data/core/fiber.rbs +74 -54
  38. data/core/file.rbs +280 -177
  39. data/core/file_test.rbs +3 -3
  40. data/core/float.rbs +257 -92
  41. data/core/gc.rbs +425 -281
  42. data/core/hash.rbs +1045 -739
  43. data/core/integer.rbs +135 -137
  44. data/core/io/buffer.rbs +53 -42
  45. data/core/io/wait.rbs +13 -35
  46. data/core/io.rbs +196 -148
  47. data/core/kernel.rbs +216 -155
  48. data/core/marshal.rbs +4 -4
  49. data/core/match_data.rbs +15 -13
  50. data/core/math.rbs +107 -66
  51. data/core/method.rbs +69 -33
  52. data/core/module.rbs +244 -106
  53. data/core/nil_class.rbs +7 -6
  54. data/core/numeric.rbs +74 -63
  55. data/core/object.rbs +9 -11
  56. data/core/object_space.rbs +30 -23
  57. data/core/pathname.rbs +1322 -0
  58. data/core/proc.rbs +95 -58
  59. data/core/process.rbs +222 -202
  60. data/core/ractor.rbs +371 -515
  61. data/core/random.rbs +21 -3
  62. data/core/range.rbs +159 -57
  63. data/core/rational.rbs +60 -89
  64. data/core/rbs/unnamed/argf.rbs +60 -53
  65. data/core/rbs/unnamed/env_class.rbs +19 -14
  66. data/core/rbs/unnamed/main_class.rbs +123 -0
  67. data/core/rbs/unnamed/random.rbs +11 -118
  68. data/core/regexp.rbs +258 -214
  69. data/core/ruby.rbs +53 -0
  70. data/core/ruby_vm.rbs +38 -34
  71. data/core/rubygems/config_file.rbs +5 -5
  72. data/core/rubygems/errors.rbs +4 -71
  73. data/core/rubygems/requirement.rbs +5 -5
  74. data/core/rubygems/rubygems.rbs +16 -82
  75. data/core/rubygems/version.rbs +2 -3
  76. data/core/set.rbs +490 -360
  77. data/core/signal.rbs +26 -16
  78. data/core/string.rbs +3303 -1365
  79. data/core/struct.rbs +27 -26
  80. data/core/symbol.rbs +41 -34
  81. data/core/thread.rbs +135 -74
  82. data/core/time.rbs +81 -50
  83. data/core/trace_point.rbs +41 -35
  84. data/core/true_class.rbs +2 -2
  85. data/core/unbound_method.rbs +24 -16
  86. data/core/warning.rbs +7 -7
  87. data/docs/aliases.md +79 -0
  88. data/docs/collection.md +3 -3
  89. data/docs/config.md +171 -0
  90. data/docs/encoding.md +56 -0
  91. data/docs/gem.md +0 -1
  92. data/docs/inline.md +576 -0
  93. data/docs/sigs.md +3 -3
  94. data/docs/syntax.md +46 -16
  95. data/docs/type_fingerprint.md +21 -0
  96. data/exe/rbs +1 -1
  97. data/ext/rbs_extension/ast_translation.c +1513 -0
  98. data/ext/rbs_extension/ast_translation.h +37 -0
  99. data/ext/rbs_extension/class_constants.c +185 -0
  100. data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +22 -1
  101. data/ext/rbs_extension/compat.h +10 -0
  102. data/ext/rbs_extension/extconf.rb +25 -1
  103. data/ext/rbs_extension/legacy_location.c +294 -0
  104. data/ext/rbs_extension/legacy_location.h +82 -0
  105. data/ext/rbs_extension/main.c +468 -24
  106. data/ext/rbs_extension/rbs_extension.h +6 -21
  107. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  108. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  109. data/include/rbs/ast.h +1022 -0
  110. data/include/rbs/defines.h +86 -0
  111. data/include/rbs/lexer.h +206 -0
  112. data/include/rbs/location.h +40 -0
  113. data/include/rbs/parser.h +153 -0
  114. data/include/rbs/string.h +47 -0
  115. data/include/rbs/util/rbs_allocator.h +59 -0
  116. data/include/rbs/util/rbs_assert.h +20 -0
  117. data/include/rbs/util/rbs_buffer.h +83 -0
  118. data/include/rbs/util/rbs_constant_pool.h +6 -70
  119. data/include/rbs/util/rbs_encoding.h +282 -0
  120. data/include/rbs/util/rbs_unescape.h +24 -0
  121. data/include/rbs.h +9 -2
  122. data/lib/rbs/annotate/formatter.rb +3 -13
  123. data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
  124. data/lib/rbs/annotate/rdoc_source.rb +1 -1
  125. data/lib/rbs/ast/annotation.rb +1 -1
  126. data/lib/rbs/ast/comment.rb +1 -1
  127. data/lib/rbs/ast/declarations.rb +10 -10
  128. data/lib/rbs/ast/members.rb +14 -14
  129. data/lib/rbs/ast/ruby/annotations.rb +409 -0
  130. data/lib/rbs/ast/ruby/comment_block.rb +245 -0
  131. data/lib/rbs/ast/ruby/declarations.rb +281 -0
  132. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  133. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  134. data/lib/rbs/ast/ruby/members.rb +723 -0
  135. data/lib/rbs/ast/type_param.rb +24 -4
  136. data/lib/rbs/buffer.rb +105 -20
  137. data/lib/rbs/cli/diff.rb +16 -15
  138. data/lib/rbs/cli/validate.rb +63 -126
  139. data/lib/rbs/cli.rb +56 -24
  140. data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
  141. data/lib/rbs/collection/sources/git.rb +1 -0
  142. data/lib/rbs/collection.rb +0 -1
  143. data/lib/rbs/definition.rb +6 -1
  144. data/lib/rbs/definition_builder/ancestor_builder.rb +121 -65
  145. data/lib/rbs/definition_builder/method_builder.rb +65 -30
  146. data/lib/rbs/definition_builder.rb +177 -20
  147. data/lib/rbs/diff.rb +7 -1
  148. data/lib/rbs/environment/class_entry.rb +69 -0
  149. data/lib/rbs/environment/module_entry.rb +66 -0
  150. data/lib/rbs/environment.rb +402 -214
  151. data/lib/rbs/environment_loader.rb +2 -8
  152. data/lib/rbs/errors.rb +31 -21
  153. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  154. data/lib/rbs/inline_parser.rb +542 -0
  155. data/lib/rbs/location_aux.rb +36 -4
  156. data/lib/rbs/locator.rb +5 -1
  157. data/lib/rbs/method_type.rb +5 -3
  158. data/lib/rbs/namespace.rb +0 -7
  159. data/lib/rbs/parser_aux.rb +35 -7
  160. data/lib/rbs/prototype/helpers.rb +57 -0
  161. data/lib/rbs/prototype/rb.rb +3 -28
  162. data/lib/rbs/prototype/rbi.rb +3 -20
  163. data/lib/rbs/prototype/runtime.rb +10 -2
  164. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  165. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  166. data/lib/rbs/source.rb +99 -0
  167. data/lib/rbs/subtractor.rb +7 -4
  168. data/lib/rbs/test/type_check.rb +19 -2
  169. data/lib/rbs/type_name.rb +1 -8
  170. data/lib/rbs/types.rb +91 -79
  171. data/lib/rbs/unit_test/convertibles.rb +1 -0
  172. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  173. data/lib/rbs/validator.rb +2 -2
  174. data/lib/rbs/version.rb +1 -1
  175. data/lib/rbs.rb +13 -2
  176. data/lib/rdoc/discover.rb +1 -1
  177. data/lib/rdoc_plugin/parser.rb +3 -3
  178. data/rbs.gemspec +4 -2
  179. data/rust/.gitignore +1 -0
  180. data/rust/Cargo.lock +378 -0
  181. data/rust/Cargo.toml +7 -0
  182. data/rust/ruby-rbs/Cargo.toml +22 -0
  183. data/rust/ruby-rbs/build.rs +764 -0
  184. data/rust/ruby-rbs/examples/locations.rs +60 -0
  185. data/rust/ruby-rbs/src/lib.rs +1 -0
  186. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  187. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  188. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  189. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  190. data/rust/ruby-rbs-sys/build.rs +204 -0
  191. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  192. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  193. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  194. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  195. data/schema/typeParam.json +17 -1
  196. data/sig/ancestor_builder.rbs +1 -1
  197. data/sig/annotate/formatter.rbs +2 -2
  198. data/sig/annotate/rdoc_annotater.rbs +1 -1
  199. data/sig/ast/ruby/annotations.rbs +421 -0
  200. data/sig/ast/ruby/comment_block.rbs +127 -0
  201. data/sig/ast/ruby/declarations.rbs +158 -0
  202. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  203. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  204. data/sig/ast/ruby/members.rbs +178 -0
  205. data/sig/buffer.rbs +63 -5
  206. data/sig/cli/diff.rbs +5 -11
  207. data/sig/cli/validate.rbs +12 -8
  208. data/sig/cli.rbs +18 -18
  209. data/sig/definition.rbs +6 -0
  210. data/sig/definition_builder.rbs +3 -1
  211. data/sig/environment/class_entry.rbs +50 -0
  212. data/sig/environment/module_entry.rbs +50 -0
  213. data/sig/environment.rbs +94 -87
  214. data/sig/errors.rbs +26 -20
  215. data/sig/inline_parser/comment_association.rbs +71 -0
  216. data/sig/inline_parser.rbs +124 -0
  217. data/sig/location.rbs +32 -7
  218. data/sig/locator.rbs +0 -2
  219. data/sig/manifest.yaml +0 -1
  220. data/sig/method_builder.rbs +9 -4
  221. data/sig/namespace.rbs +0 -5
  222. data/sig/parser.rbs +67 -13
  223. data/sig/prototype/helpers.rbs +2 -0
  224. data/sig/resolver/type_name_resolver.rbs +35 -7
  225. data/sig/source.rbs +48 -0
  226. data/sig/type_param.rbs +13 -8
  227. data/sig/typename.rbs +0 -5
  228. data/sig/types.rbs +10 -8
  229. data/sig/unit_test/spy.rbs +0 -8
  230. data/sig/unit_test/type_assertions.rbs +11 -0
  231. data/src/ast.c +1604 -0
  232. data/src/lexer.c +3194 -0
  233. data/src/lexer.re +154 -0
  234. data/src/lexstate.c +212 -0
  235. data/src/location.c +31 -0
  236. data/src/parser.c +4205 -0
  237. data/src/string.c +41 -0
  238. data/src/util/rbs_allocator.c +165 -0
  239. data/src/util/rbs_assert.c +19 -0
  240. data/src/util/rbs_buffer.c +54 -0
  241. data/src/util/rbs_constant_pool.c +18 -92
  242. data/src/util/rbs_encoding.c +21308 -0
  243. data/src/util/rbs_unescape.c +167 -0
  244. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  245. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  246. data/stdlib/cgi/0/core.rbs +9 -393
  247. data/stdlib/cgi/0/manifest.yaml +1 -0
  248. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  249. data/stdlib/coverage/0/coverage.rbs +7 -4
  250. data/stdlib/date/0/date.rbs +92 -79
  251. data/stdlib/date/0/date_time.rbs +25 -24
  252. data/stdlib/delegate/0/delegator.rbs +10 -7
  253. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  254. data/stdlib/digest/0/digest.rbs +110 -0
  255. data/stdlib/erb/0/erb.rbs +748 -347
  256. data/stdlib/etc/0/etc.rbs +55 -50
  257. data/stdlib/fileutils/0/fileutils.rbs +158 -139
  258. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  259. data/stdlib/io-console/0/io-console.rbs +2 -2
  260. data/stdlib/json/0/json.rbs +226 -179
  261. data/stdlib/monitor/0/monitor.rbs +3 -3
  262. data/stdlib/net-http/0/net-http.rbs +162 -134
  263. data/stdlib/objspace/0/objspace.rbs +17 -34
  264. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  265. data/stdlib/open3/0/open3.rbs +469 -10
  266. data/stdlib/openssl/0/openssl.rbs +475 -357
  267. data/stdlib/optparse/0/optparse.rbs +26 -17
  268. data/stdlib/pathname/0/pathname.rbs +11 -1381
  269. data/stdlib/pp/0/pp.rbs +9 -8
  270. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  271. data/stdlib/pstore/0/pstore.rbs +35 -30
  272. data/stdlib/psych/0/psych.rbs +65 -12
  273. data/stdlib/psych/0/store.rbs +2 -4
  274. data/stdlib/pty/0/pty.rbs +9 -6
  275. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  276. data/stdlib/rdoc/0/code_object.rbs +4 -3
  277. data/stdlib/rdoc/0/comment.rbs +2 -0
  278. data/stdlib/rdoc/0/options.rbs +76 -0
  279. data/stdlib/rdoc/0/parser.rbs +1 -1
  280. data/stdlib/rdoc/0/rdoc.rbs +7 -5
  281. data/stdlib/rdoc/0/store.rbs +2 -2
  282. data/stdlib/resolv/0/resolv.rbs +25 -68
  283. data/stdlib/ripper/0/ripper.rbs +25 -19
  284. data/stdlib/securerandom/0/manifest.yaml +2 -0
  285. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  286. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  287. data/stdlib/singleton/0/singleton.rbs +3 -0
  288. data/stdlib/socket/0/addrinfo.rbs +9 -9
  289. data/stdlib/socket/0/basic_socket.rbs +3 -3
  290. data/stdlib/socket/0/ip_socket.rbs +10 -8
  291. data/stdlib/socket/0/socket.rbs +23 -10
  292. data/stdlib/socket/0/tcp_server.rbs +1 -1
  293. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  294. data/stdlib/socket/0/udp_socket.rbs +1 -1
  295. data/stdlib/socket/0/unix_server.rbs +1 -1
  296. data/stdlib/stringio/0/stringio.rbs +1177 -85
  297. data/stdlib/strscan/0/string_scanner.rbs +27 -25
  298. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  299. data/stdlib/time/0/time.rbs +8 -6
  300. data/stdlib/timeout/0/timeout.rbs +63 -7
  301. data/stdlib/tsort/0/cyclic.rbs +3 -0
  302. data/stdlib/tsort/0/tsort.rbs +7 -6
  303. data/stdlib/uri/0/common.rbs +42 -20
  304. data/stdlib/uri/0/file.rbs +3 -3
  305. data/stdlib/uri/0/generic.rbs +26 -18
  306. data/stdlib/uri/0/http.rbs +2 -2
  307. data/stdlib/uri/0/ldap.rbs +2 -2
  308. data/stdlib/uri/0/mailto.rbs +3 -3
  309. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  310. data/stdlib/zlib/0/deflate.rbs +4 -3
  311. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  312. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  313. data/stdlib/zlib/0/inflate.rbs +1 -1
  314. data/stdlib/zlib/0/need_dict.rbs +1 -1
  315. data/stdlib/zlib/0/zstream.rbs +1 -0
  316. metadata +121 -18
  317. data/ext/rbs_extension/lexer.c +0 -2728
  318. data/ext/rbs_extension/lexer.h +0 -179
  319. data/ext/rbs_extension/lexer.re +0 -147
  320. data/ext/rbs_extension/lexstate.c +0 -175
  321. data/ext/rbs_extension/location.c +0 -325
  322. data/ext/rbs_extension/location.h +0 -85
  323. data/ext/rbs_extension/parser.c +0 -2982
  324. data/ext/rbs_extension/parser.h +0 -18
  325. data/ext/rbs_extension/parserstate.c +0 -411
  326. data/ext/rbs_extension/parserstate.h +0 -163
  327. data/ext/rbs_extension/unescape.c +0 -32
  328. data/include/rbs/ruby_objs.h +0 -72
  329. data/src/constants.c +0 -153
  330. data/src/ruby_objs.c +0 -799
@@ -0,0 +1,1513 @@
1
+ /*----------------------------------------------------------------------------*/
2
+ /* This file is generated by the templates/template.rb script and should not */
3
+ /* be modified manually. */
4
+ /* To change the template see */
5
+ /* templates/ext/rbs_extension/ast_translation.c.erb */
6
+ /*----------------------------------------------------------------------------*/
7
+
8
+ #include "ast_translation.h"
9
+
10
+ #include "class_constants.h"
11
+ #include "rbs_string_bridging.h"
12
+ #include "legacy_location.h"
13
+
14
+ VALUE EMPTY_ARRAY;
15
+ VALUE EMPTY_HASH;
16
+
17
+ #define RBS_LOCATION_CHILDREN_SIZE(cap) (sizeof(rbs_location_children) + sizeof(rbs_location_entry) * ((cap) - 1))
18
+ #define RBS_LOCATION_REQUIRED_P(loc, i) ((loc)->children->required_p & (1 << (i)))
19
+ #define RBS_LOCATION_OPTIONAL_P(loc, i) (!RBS_LOCATION_REQUIRED_P((loc), (i)))
20
+
21
+ rbs_translation_context_t rbs_translation_context_create(rbs_constant_pool_t *constant_pool, VALUE buffer, rb_encoding *ruby_encoding) {
22
+ return (rbs_translation_context_t) {
23
+ .constant_pool = constant_pool,
24
+ .buffer = buffer,
25
+ .encoding = ruby_encoding,
26
+ };
27
+ }
28
+
29
+ VALUE rbs_node_list_to_ruby_array(rbs_translation_context_t ctx, rbs_node_list_t *list) {
30
+ VALUE ruby_array = rb_ary_new();
31
+
32
+ for (rbs_node_list_node_t *n = list->head; n != NULL; n = n->next) {
33
+ rb_ary_push(ruby_array, rbs_struct_to_ruby_value(ctx, n->node));
34
+ }
35
+
36
+ return ruby_array;
37
+ }
38
+
39
+ VALUE rbs_hash_to_ruby_hash(rbs_translation_context_t ctx, rbs_hash_t *rbs_hash) {
40
+ if (!rbs_hash->head) {
41
+ return EMPTY_HASH;
42
+ }
43
+
44
+ VALUE ruby_hash = rb_hash_new();
45
+
46
+ for (rbs_hash_node_t *n = rbs_hash->head; n != NULL; n = n->next) {
47
+ VALUE key = rbs_struct_to_ruby_value(ctx, n->key);
48
+ VALUE value = rbs_struct_to_ruby_value(ctx, n->value);
49
+ rb_hash_aset(ruby_hash, key, value);
50
+ }
51
+
52
+ return ruby_hash;
53
+ }
54
+
55
+ VALUE rbs_location_range_to_ruby_location(rbs_translation_context_t ctx, rbs_location_range range) {
56
+ if (RBS_LOCATION_NULL_RANGE_P(range)) {
57
+ return Qnil;
58
+ }
59
+
60
+ return rbs_new_location2(ctx.buffer, range.start_char, range.end_char);
61
+ }
62
+
63
+ VALUE rbs_location_range_list_to_ruby_array(rbs_translation_context_t ctx, rbs_location_range_list_t *list) {
64
+ if (list == NULL) {
65
+ return EMPTY_ARRAY;
66
+ }
67
+
68
+ VALUE ruby_array = rb_ary_new();
69
+
70
+ for (rbs_location_range_list_node_t *n = list->head; n != NULL; n = n->next) {
71
+ rb_ary_push(ruby_array, rbs_location_range_to_ruby_location(ctx, n->range));
72
+ }
73
+
74
+ return ruby_array;
75
+ }
76
+
77
+ VALUE rbs_attr_ivar_name_to_ruby(rbs_translation_context_t ctx, rbs_attr_ivar_name_t ivar_name) {
78
+ switch (ivar_name.tag) {
79
+ case RBS_ATTR_IVAR_NAME_TAG_NAME: {
80
+ rbs_constant_t *constant = rbs_constant_pool_id_to_constant(ctx.constant_pool, ivar_name.name);
81
+ assert(constant != NULL && "constant is NULL");
82
+ assert(constant->start != NULL && "constant->start is NULL");
83
+
84
+ return ID2SYM(rb_intern3((const char *) constant->start, constant->length, ctx.encoding));
85
+ }
86
+ case RBS_ATTR_IVAR_NAME_TAG_UNSPECIFIED:
87
+ return Qnil;
88
+ case RBS_ATTR_IVAR_NAME_TAG_EMPTY:
89
+ return Qfalse;
90
+ default:
91
+ rb_fatal("unknown enum rbs_attr_ivar_name_tag ivar_name.tag: %d", ivar_name.tag);
92
+ }
93
+ }
94
+
95
+ VALUE rbs_attribute_visibility_to_ruby(enum rbs_attribute_visibility value) {
96
+ switch (value) {
97
+ case RBS_ATTRIBUTE_VISIBILITY_UNSPECIFIED:
98
+ return Qnil;
99
+ case RBS_ATTRIBUTE_VISIBILITY_PUBLIC:
100
+ return rb_id2sym(rb_intern("public"));
101
+ case RBS_ATTRIBUTE_VISIBILITY_PRIVATE:
102
+ return rb_id2sym(rb_intern("private"));
103
+ default:
104
+ rb_fatal("unknown enum rbs_attribute_visibility value: %d", value);
105
+ }
106
+ }
107
+
108
+ VALUE rbs_attribute_kind_to_ruby(enum rbs_attribute_kind value) {
109
+ switch (value) {
110
+ case RBS_ATTRIBUTE_KIND_INSTANCE:
111
+ return rb_id2sym(rb_intern("instance"));
112
+ case RBS_ATTRIBUTE_KIND_SINGLETON:
113
+ return rb_id2sym(rb_intern("singleton"));
114
+ default:
115
+ rb_fatal("unknown enum rbs_attribute_kind value: %d", value);
116
+ }
117
+ }
118
+
119
+ VALUE rbs_alias_kind_to_ruby(enum rbs_alias_kind value) {
120
+ switch (value) {
121
+ case RBS_ALIAS_KIND_INSTANCE:
122
+ return rb_id2sym(rb_intern("instance"));
123
+ case RBS_ALIAS_KIND_SINGLETON:
124
+ return rb_id2sym(rb_intern("singleton"));
125
+ default:
126
+ rb_fatal("unknown enum rbs_alias_kind value: %d", value);
127
+ }
128
+ }
129
+
130
+ VALUE rbs_method_definition_kind_to_ruby(enum rbs_method_definition_kind value) {
131
+ switch (value) {
132
+ case RBS_METHOD_DEFINITION_KIND_INSTANCE:
133
+ return rb_id2sym(rb_intern("instance"));
134
+ case RBS_METHOD_DEFINITION_KIND_SINGLETON:
135
+ return rb_id2sym(rb_intern("singleton"));
136
+ case RBS_METHOD_DEFINITION_KIND_SINGLETON_INSTANCE:
137
+ return rb_id2sym(rb_intern("singleton_instance"));
138
+ default:
139
+ rb_fatal("unknown enum rbs_method_definition_kind value: %d", value);
140
+ }
141
+ }
142
+
143
+ VALUE rbs_method_definition_visibility_to_ruby(enum rbs_method_definition_visibility value) {
144
+ switch (value) {
145
+ case RBS_METHOD_DEFINITION_VISIBILITY_UNSPECIFIED:
146
+ return Qnil;
147
+ case RBS_METHOD_DEFINITION_VISIBILITY_PUBLIC:
148
+ return rb_id2sym(rb_intern("public"));
149
+ case RBS_METHOD_DEFINITION_VISIBILITY_PRIVATE:
150
+ return rb_id2sym(rb_intern("private"));
151
+ default:
152
+ rb_fatal("unknown enum rbs_method_definition_visibility value: %d", value);
153
+ }
154
+ }
155
+
156
+ VALUE rbs_type_param_variance_to_ruby(enum rbs_type_param_variance value) {
157
+ switch (value) {
158
+ case RBS_TYPE_PARAM_VARIANCE_INVARIANT:
159
+ return rb_id2sym(rb_intern("invariant"));
160
+ case RBS_TYPE_PARAM_VARIANCE_COVARIANT:
161
+ return rb_id2sym(rb_intern("covariant"));
162
+ case RBS_TYPE_PARAM_VARIANCE_CONTRAVARIANT:
163
+ return rb_id2sym(rb_intern("contravariant"));
164
+ default:
165
+ rb_fatal("unknown enum rbs_type_param_variance value: %d", value);
166
+ }
167
+ }
168
+
169
+ #ifdef RB_PASS_KEYWORDS
170
+ // Ruby 2.7 or later
171
+ #define CLASS_NEW_INSTANCE(klass, argc, argv) \
172
+ rb_class_new_instance_kw(argc, argv, klass, RB_PASS_KEYWORDS)
173
+ #else
174
+ // Ruby 2.6
175
+ #define CLASS_NEW_INSTANCE(receiver, argc, argv) \
176
+ rb_class_new_instance(argc, argv, receiver)
177
+ #endif
178
+
179
+ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instance) {
180
+ if (instance == NULL) return Qnil;
181
+
182
+ switch (instance->type) {
183
+ case RBS_AST_ANNOTATION: {
184
+ rbs_ast_annotation_t *node = (rbs_ast_annotation_t *) instance;
185
+
186
+ VALUE h = rb_hash_new();
187
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
188
+ rb_hash_aset(h, ID2SYM(rb_intern("string")), rbs_string_to_ruby_string(&node->string, ctx.encoding));
189
+
190
+ return CLASS_NEW_INSTANCE(
191
+ RBS_AST_Annotation,
192
+ 1,
193
+ &h
194
+ );
195
+ }
196
+ case RBS_AST_BOOL: {
197
+ return ((rbs_ast_bool_t *) instance)->value ? Qtrue : Qfalse;
198
+ }
199
+ case RBS_AST_COMMENT: {
200
+ rbs_ast_comment_t *node = (rbs_ast_comment_t *) instance;
201
+
202
+ VALUE h = rb_hash_new();
203
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
204
+ rb_hash_aset(h, ID2SYM(rb_intern("string")), rbs_string_to_ruby_string(&node->string, ctx.encoding));
205
+
206
+ return CLASS_NEW_INSTANCE(
207
+ RBS_AST_Comment,
208
+ 1,
209
+ &h
210
+ );
211
+ }
212
+ case RBS_AST_DECLARATIONS_CLASS: {
213
+ rbs_ast_declarations_class_t *node = (rbs_ast_declarations_class_t *) instance;
214
+
215
+ VALUE h = rb_hash_new();
216
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
217
+ rbs_loc *loc = rbs_check_location(location);
218
+ rbs_loc_legacy_alloc_children(loc, 5);
219
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
220
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
221
+ rbs_loc_legacy_add_required_child(loc, rb_intern("end"), (rbs_loc_range) { .start = node->end_range.start_char, .end = node->end_range.end_char });
222
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("type_params"), (rbs_loc_range) { .start = node->type_params_range.start_char, .end = node->type_params_range.end_char });
223
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("lt"), (rbs_loc_range) { .start = node->lt_range.start_char, .end = node->lt_range.end_char });
224
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
225
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
226
+ rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
227
+ 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
228
+ rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
229
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
230
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
231
+
232
+ rb_funcall(
233
+ RBS_AST_TypeParam,
234
+ rb_intern("resolve_variables"),
235
+ 1,
236
+ rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
237
+ );
238
+ return CLASS_NEW_INSTANCE(
239
+ RBS_AST_Declarations_Class,
240
+ 1,
241
+ &h
242
+ );
243
+ }
244
+ case RBS_AST_DECLARATIONS_CLASS_SUPER: {
245
+ rbs_ast_declarations_class_super_t *node = (rbs_ast_declarations_class_super_t *) instance;
246
+
247
+ VALUE h = rb_hash_new();
248
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
249
+ rbs_loc *loc = rbs_check_location(location);
250
+ rbs_loc_legacy_alloc_children(loc, 2);
251
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
252
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
253
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
254
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
255
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
256
+
257
+ return CLASS_NEW_INSTANCE(
258
+ RBS_AST_Declarations_Class_Super,
259
+ 1,
260
+ &h
261
+ );
262
+ }
263
+ case RBS_AST_DECLARATIONS_CLASS_ALIAS: {
264
+ rbs_ast_declarations_class_alias_t *node = (rbs_ast_declarations_class_alias_t *) instance;
265
+
266
+ VALUE h = rb_hash_new();
267
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
268
+ rbs_loc *loc = rbs_check_location(location);
269
+ rbs_loc_legacy_alloc_children(loc, 4);
270
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
271
+ rbs_loc_legacy_add_required_child(loc, rb_intern("new_name"), (rbs_loc_range) { .start = node->new_name_range.start_char, .end = node->new_name_range.end_char });
272
+ rbs_loc_legacy_add_required_child(loc, rb_intern("eq"), (rbs_loc_range) { .start = node->eq_range.start_char, .end = node->eq_range.end_char });
273
+ rbs_loc_legacy_add_required_child(loc, rb_intern("old_name"), (rbs_loc_range) { .start = node->old_name_range.start_char, .end = node->old_name_range.end_char });
274
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
275
+ rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_type_name
276
+ rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_type_name
277
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
278
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
279
+
280
+ return CLASS_NEW_INSTANCE(
281
+ RBS_AST_Declarations_ClassAlias,
282
+ 1,
283
+ &h
284
+ );
285
+ }
286
+ case RBS_AST_DECLARATIONS_CONSTANT: {
287
+ rbs_ast_declarations_constant_t *node = (rbs_ast_declarations_constant_t *) instance;
288
+
289
+ VALUE h = rb_hash_new();
290
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
291
+ rbs_loc *loc = rbs_check_location(location);
292
+ rbs_loc_legacy_alloc_children(loc, 2);
293
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
294
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
295
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
296
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
297
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
298
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
299
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
300
+
301
+ return CLASS_NEW_INSTANCE(
302
+ RBS_AST_Declarations_Constant,
303
+ 1,
304
+ &h
305
+ );
306
+ }
307
+ case RBS_AST_DECLARATIONS_GLOBAL: {
308
+ rbs_ast_declarations_global_t *node = (rbs_ast_declarations_global_t *) instance;
309
+
310
+ VALUE h = rb_hash_new();
311
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
312
+ rbs_loc *loc = rbs_check_location(location);
313
+ rbs_loc_legacy_alloc_children(loc, 2);
314
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
315
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
316
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
317
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
318
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
319
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
320
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
321
+
322
+ return CLASS_NEW_INSTANCE(
323
+ RBS_AST_Declarations_Global,
324
+ 1,
325
+ &h
326
+ );
327
+ }
328
+ case RBS_AST_DECLARATIONS_INTERFACE: {
329
+ rbs_ast_declarations_interface_t *node = (rbs_ast_declarations_interface_t *) instance;
330
+
331
+ VALUE h = rb_hash_new();
332
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
333
+ rbs_loc *loc = rbs_check_location(location);
334
+ rbs_loc_legacy_alloc_children(loc, 4);
335
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
336
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
337
+ rbs_loc_legacy_add_required_child(loc, rb_intern("end"), (rbs_loc_range) { .start = node->end_range.start_char, .end = node->end_range.end_char });
338
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("type_params"), (rbs_loc_range) { .start = node->type_params_range.start_char, .end = node->type_params_range.end_char });
339
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
340
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
341
+ rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
342
+ rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
343
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
344
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
345
+
346
+ rb_funcall(
347
+ RBS_AST_TypeParam,
348
+ rb_intern("resolve_variables"),
349
+ 1,
350
+ rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
351
+ );
352
+ return CLASS_NEW_INSTANCE(
353
+ RBS_AST_Declarations_Interface,
354
+ 1,
355
+ &h
356
+ );
357
+ }
358
+ case RBS_AST_DECLARATIONS_MODULE: {
359
+ rbs_ast_declarations_module_t *node = (rbs_ast_declarations_module_t *) instance;
360
+
361
+ VALUE h = rb_hash_new();
362
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
363
+ rbs_loc *loc = rbs_check_location(location);
364
+ rbs_loc_legacy_alloc_children(loc, 6);
365
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
366
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
367
+ rbs_loc_legacy_add_required_child(loc, rb_intern("end"), (rbs_loc_range) { .start = node->end_range.start_char, .end = node->end_range.end_char });
368
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("type_params"), (rbs_loc_range) { .start = node->type_params_range.start_char, .end = node->type_params_range.end_char });
369
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
370
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("self_types"), (rbs_loc_range) { .start = node->self_types_range.start_char, .end = node->self_types_range.end_char });
371
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
372
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
373
+ rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
374
+ rb_hash_aset(h, ID2SYM(rb_intern("self_types")), rbs_node_list_to_ruby_array(ctx, node->self_types));
375
+ rb_hash_aset(h, ID2SYM(rb_intern("members")), rbs_node_list_to_ruby_array(ctx, node->members));
376
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
377
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
378
+
379
+ rb_funcall(
380
+ RBS_AST_TypeParam,
381
+ rb_intern("resolve_variables"),
382
+ 1,
383
+ rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
384
+ );
385
+ return CLASS_NEW_INSTANCE(
386
+ RBS_AST_Declarations_Module,
387
+ 1,
388
+ &h
389
+ );
390
+ }
391
+ case RBS_AST_DECLARATIONS_MODULE_SELF: {
392
+ rbs_ast_declarations_module_self_t *node = (rbs_ast_declarations_module_self_t *) instance;
393
+
394
+ VALUE h = rb_hash_new();
395
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
396
+ rbs_loc *loc = rbs_check_location(location);
397
+ rbs_loc_legacy_alloc_children(loc, 2);
398
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
399
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
400
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
401
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
402
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
403
+
404
+ return CLASS_NEW_INSTANCE(
405
+ RBS_AST_Declarations_Module_Self,
406
+ 1,
407
+ &h
408
+ );
409
+ }
410
+ case RBS_AST_DECLARATIONS_MODULE_ALIAS: {
411
+ rbs_ast_declarations_module_alias_t *node = (rbs_ast_declarations_module_alias_t *) instance;
412
+
413
+ VALUE h = rb_hash_new();
414
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
415
+ rbs_loc *loc = rbs_check_location(location);
416
+ rbs_loc_legacy_alloc_children(loc, 4);
417
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
418
+ rbs_loc_legacy_add_required_child(loc, rb_intern("new_name"), (rbs_loc_range) { .start = node->new_name_range.start_char, .end = node->new_name_range.end_char });
419
+ rbs_loc_legacy_add_required_child(loc, rb_intern("eq"), (rbs_loc_range) { .start = node->eq_range.start_char, .end = node->eq_range.end_char });
420
+ rbs_loc_legacy_add_required_child(loc, rb_intern("old_name"), (rbs_loc_range) { .start = node->old_name_range.start_char, .end = node->old_name_range.end_char });
421
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
422
+ rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_type_name
423
+ rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_type_name
424
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
425
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
426
+
427
+ return CLASS_NEW_INSTANCE(
428
+ RBS_AST_Declarations_ModuleAlias,
429
+ 1,
430
+ &h
431
+ );
432
+ }
433
+ case RBS_AST_DECLARATIONS_TYPE_ALIAS: {
434
+ rbs_ast_declarations_type_alias_t *node = (rbs_ast_declarations_type_alias_t *) instance;
435
+
436
+ VALUE h = rb_hash_new();
437
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
438
+ rbs_loc *loc = rbs_check_location(location);
439
+ rbs_loc_legacy_alloc_children(loc, 4);
440
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
441
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
442
+ rbs_loc_legacy_add_required_child(loc, rb_intern("eq"), (rbs_loc_range) { .start = node->eq_range.start_char, .end = node->eq_range.end_char });
443
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("type_params"), (rbs_loc_range) { .start = node->type_params_range.start_char, .end = node->type_params_range.end_char });
444
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
445
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
446
+ rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
447
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
448
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
449
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
450
+
451
+ rb_funcall(
452
+ RBS_AST_TypeParam,
453
+ rb_intern("resolve_variables"),
454
+ 1,
455
+ rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
456
+ );
457
+ return CLASS_NEW_INSTANCE(
458
+ RBS_AST_Declarations_TypeAlias,
459
+ 1,
460
+ &h
461
+ );
462
+ }
463
+ case RBS_AST_DIRECTIVES_USE: {
464
+ rbs_ast_directives_use_t *node = (rbs_ast_directives_use_t *) instance;
465
+
466
+ VALUE h = rb_hash_new();
467
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
468
+ rbs_loc *loc = rbs_check_location(location);
469
+ rbs_loc_legacy_alloc_children(loc, 1);
470
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
471
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
472
+ rb_hash_aset(h, ID2SYM(rb_intern("clauses")), rbs_node_list_to_ruby_array(ctx, node->clauses));
473
+
474
+ return CLASS_NEW_INSTANCE(
475
+ RBS_AST_Directives_Use,
476
+ 1,
477
+ &h
478
+ );
479
+ }
480
+ case RBS_AST_DIRECTIVES_USE_SINGLE_CLAUSE: {
481
+ rbs_ast_directives_use_single_clause_t *node = (rbs_ast_directives_use_single_clause_t *) instance;
482
+
483
+ VALUE h = rb_hash_new();
484
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
485
+ rbs_loc *loc = rbs_check_location(location);
486
+ rbs_loc_legacy_alloc_children(loc, 3);
487
+ rbs_loc_legacy_add_required_child(loc, rb_intern("type_name"), (rbs_loc_range) { .start = node->type_name_range.start_char, .end = node->type_name_range.end_char });
488
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
489
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("new_name"), (rbs_loc_range) { .start = node->new_name_range.start_char, .end = node->new_name_range.end_char });
490
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
491
+ rb_hash_aset(h, ID2SYM(rb_intern("type_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_name)); // rbs_type_name
492
+ rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_ast_symbol
493
+
494
+ return CLASS_NEW_INSTANCE(
495
+ RBS_AST_Directives_Use_SingleClause,
496
+ 1,
497
+ &h
498
+ );
499
+ }
500
+ case RBS_AST_DIRECTIVES_USE_WILDCARD_CLAUSE: {
501
+ rbs_ast_directives_use_wildcard_clause_t *node = (rbs_ast_directives_use_wildcard_clause_t *) instance;
502
+
503
+ VALUE h = rb_hash_new();
504
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
505
+ rbs_loc *loc = rbs_check_location(location);
506
+ rbs_loc_legacy_alloc_children(loc, 2);
507
+ rbs_loc_legacy_add_required_child(loc, rb_intern("namespace"), (rbs_loc_range) { .start = node->namespace_range.start_char, .end = node->namespace_range.end_char });
508
+ rbs_loc_legacy_add_required_child(loc, rb_intern("star"), (rbs_loc_range) { .start = node->star_range.start_char, .end = node->star_range.end_char });
509
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
510
+ rb_hash_aset(h, ID2SYM(rb_intern("namespace")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rbs_namespace)); // rbs_namespace
511
+
512
+ return CLASS_NEW_INSTANCE(
513
+ RBS_AST_Directives_Use_WildcardClause,
514
+ 1,
515
+ &h
516
+ );
517
+ }
518
+ case RBS_AST_INTEGER: {
519
+ rbs_ast_integer_t *integer_node = (rbs_ast_integer_t *) instance;
520
+ rbs_string_t string_repr = integer_node->string_representation;
521
+
522
+ VALUE str = rb_enc_str_new(string_repr.start, rbs_string_len(string_repr), rb_utf8_encoding());
523
+
524
+ return rb_funcall(str, rb_intern("to_i"), 0);
525
+ }
526
+ case RBS_AST_MEMBERS_ALIAS: {
527
+ rbs_ast_members_alias_t *node = (rbs_ast_members_alias_t *) instance;
528
+
529
+ VALUE h = rb_hash_new();
530
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
531
+ rbs_loc *loc = rbs_check_location(location);
532
+ rbs_loc_legacy_alloc_children(loc, 5);
533
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
534
+ rbs_loc_legacy_add_required_child(loc, rb_intern("new_name"), (rbs_loc_range) { .start = node->new_name_range.start_char, .end = node->new_name_range.end_char });
535
+ rbs_loc_legacy_add_required_child(loc, rb_intern("old_name"), (rbs_loc_range) { .start = node->old_name_range.start_char, .end = node->old_name_range.end_char });
536
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("new_kind"), (rbs_loc_range) { .start = node->new_kind_range.start_char, .end = node->new_kind_range.end_char });
537
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("old_kind"), (rbs_loc_range) { .start = node->old_kind_range.start_char, .end = node->old_kind_range.end_char });
538
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
539
+ rb_hash_aset(h, ID2SYM(rb_intern("new_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->new_name)); // rbs_ast_symbol
540
+ rb_hash_aset(h, ID2SYM(rb_intern("old_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->old_name)); // rbs_ast_symbol
541
+ rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_alias_kind_to_ruby(node->kind)); // alias_kind
542
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
543
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
544
+
545
+ return CLASS_NEW_INSTANCE(
546
+ RBS_AST_Members_Alias,
547
+ 1,
548
+ &h
549
+ );
550
+ }
551
+ case RBS_AST_MEMBERS_ATTR_ACCESSOR: {
552
+ rbs_ast_members_attr_accessor_t *node = (rbs_ast_members_attr_accessor_t *) instance;
553
+
554
+ VALUE h = rb_hash_new();
555
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
556
+ rbs_loc *loc = rbs_check_location(location);
557
+ rbs_loc_legacy_alloc_children(loc, 7);
558
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
559
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
560
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
561
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("kind"), (rbs_loc_range) { .start = node->kind_range.start_char, .end = node->kind_range.end_char });
562
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("ivar"), (rbs_loc_range) { .start = node->ivar_range.start_char, .end = node->ivar_range.end_char });
563
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("ivar_name"), (rbs_loc_range) { .start = node->ivar_name_range.start_char, .end = node->ivar_name_range.end_char });
564
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("visibility"), (rbs_loc_range) { .start = node->visibility_range.start_char, .end = node->visibility_range.end_char });
565
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
566
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
567
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
568
+ rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_attr_ivar_name_to_ruby(ctx, node->ivar_name)); // rbs_attr_ivar_name_t
569
+ rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_attribute_kind_to_ruby(node->kind)); // attribute_kind
570
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
571
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
572
+ rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_attribute_visibility_to_ruby(node->visibility)); // attribute_visibility
573
+
574
+ return CLASS_NEW_INSTANCE(
575
+ RBS_AST_Members_AttrAccessor,
576
+ 1,
577
+ &h
578
+ );
579
+ }
580
+ case RBS_AST_MEMBERS_ATTR_READER: {
581
+ rbs_ast_members_attr_reader_t *node = (rbs_ast_members_attr_reader_t *) instance;
582
+
583
+ VALUE h = rb_hash_new();
584
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
585
+ rbs_loc *loc = rbs_check_location(location);
586
+ rbs_loc_legacy_alloc_children(loc, 7);
587
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
588
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
589
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
590
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("kind"), (rbs_loc_range) { .start = node->kind_range.start_char, .end = node->kind_range.end_char });
591
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("ivar"), (rbs_loc_range) { .start = node->ivar_range.start_char, .end = node->ivar_range.end_char });
592
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("ivar_name"), (rbs_loc_range) { .start = node->ivar_name_range.start_char, .end = node->ivar_name_range.end_char });
593
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("visibility"), (rbs_loc_range) { .start = node->visibility_range.start_char, .end = node->visibility_range.end_char });
594
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
595
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
596
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
597
+ rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_attr_ivar_name_to_ruby(ctx, node->ivar_name)); // rbs_attr_ivar_name_t
598
+ rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_attribute_kind_to_ruby(node->kind)); // attribute_kind
599
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
600
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
601
+ rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_attribute_visibility_to_ruby(node->visibility)); // attribute_visibility
602
+
603
+ return CLASS_NEW_INSTANCE(
604
+ RBS_AST_Members_AttrReader,
605
+ 1,
606
+ &h
607
+ );
608
+ }
609
+ case RBS_AST_MEMBERS_ATTR_WRITER: {
610
+ rbs_ast_members_attr_writer_t *node = (rbs_ast_members_attr_writer_t *) instance;
611
+
612
+ VALUE h = rb_hash_new();
613
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
614
+ rbs_loc *loc = rbs_check_location(location);
615
+ rbs_loc_legacy_alloc_children(loc, 7);
616
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
617
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
618
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
619
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("kind"), (rbs_loc_range) { .start = node->kind_range.start_char, .end = node->kind_range.end_char });
620
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("ivar"), (rbs_loc_range) { .start = node->ivar_range.start_char, .end = node->ivar_range.end_char });
621
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("ivar_name"), (rbs_loc_range) { .start = node->ivar_name_range.start_char, .end = node->ivar_name_range.end_char });
622
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("visibility"), (rbs_loc_range) { .start = node->visibility_range.start_char, .end = node->visibility_range.end_char });
623
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
624
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
625
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
626
+ rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_attr_ivar_name_to_ruby(ctx, node->ivar_name)); // rbs_attr_ivar_name_t
627
+ rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_attribute_kind_to_ruby(node->kind)); // attribute_kind
628
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
629
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
630
+ rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_attribute_visibility_to_ruby(node->visibility)); // attribute_visibility
631
+
632
+ return CLASS_NEW_INSTANCE(
633
+ RBS_AST_Members_AttrWriter,
634
+ 1,
635
+ &h
636
+ );
637
+ }
638
+ case RBS_AST_MEMBERS_CLASS_INSTANCE_VARIABLE: {
639
+ rbs_ast_members_class_instance_variable_t *node = (rbs_ast_members_class_instance_variable_t *) instance;
640
+
641
+ VALUE h = rb_hash_new();
642
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
643
+ rbs_loc *loc = rbs_check_location(location);
644
+ rbs_loc_legacy_alloc_children(loc, 3);
645
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
646
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
647
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("kind"), (rbs_loc_range) { .start = node->kind_range.start_char, .end = node->kind_range.end_char });
648
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
649
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
650
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
651
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
652
+
653
+ return CLASS_NEW_INSTANCE(
654
+ RBS_AST_Members_ClassInstanceVariable,
655
+ 1,
656
+ &h
657
+ );
658
+ }
659
+ case RBS_AST_MEMBERS_CLASS_VARIABLE: {
660
+ rbs_ast_members_class_variable_t *node = (rbs_ast_members_class_variable_t *) instance;
661
+
662
+ VALUE h = rb_hash_new();
663
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
664
+ rbs_loc *loc = rbs_check_location(location);
665
+ rbs_loc_legacy_alloc_children(loc, 3);
666
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
667
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
668
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("kind"), (rbs_loc_range) { .start = node->kind_range.start_char, .end = node->kind_range.end_char });
669
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
670
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
671
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
672
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
673
+
674
+ return CLASS_NEW_INSTANCE(
675
+ RBS_AST_Members_ClassVariable,
676
+ 1,
677
+ &h
678
+ );
679
+ }
680
+ case RBS_AST_MEMBERS_EXTEND: {
681
+ rbs_ast_members_extend_t *node = (rbs_ast_members_extend_t *) instance;
682
+
683
+ VALUE h = rb_hash_new();
684
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
685
+ rbs_loc *loc = rbs_check_location(location);
686
+ rbs_loc_legacy_alloc_children(loc, 3);
687
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
688
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
689
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
690
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
691
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
692
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
693
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
694
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
695
+
696
+ return CLASS_NEW_INSTANCE(
697
+ RBS_AST_Members_Extend,
698
+ 1,
699
+ &h
700
+ );
701
+ }
702
+ case RBS_AST_MEMBERS_INCLUDE: {
703
+ rbs_ast_members_include_t *node = (rbs_ast_members_include_t *) instance;
704
+
705
+ VALUE h = rb_hash_new();
706
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
707
+ rbs_loc *loc = rbs_check_location(location);
708
+ rbs_loc_legacy_alloc_children(loc, 3);
709
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
710
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
711
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
712
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
713
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
714
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
715
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
716
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
717
+
718
+ return CLASS_NEW_INSTANCE(
719
+ RBS_AST_Members_Include,
720
+ 1,
721
+ &h
722
+ );
723
+ }
724
+ case RBS_AST_MEMBERS_INSTANCE_VARIABLE: {
725
+ rbs_ast_members_instance_variable_t *node = (rbs_ast_members_instance_variable_t *) instance;
726
+
727
+ VALUE h = rb_hash_new();
728
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
729
+ rbs_loc *loc = rbs_check_location(location);
730
+ rbs_loc_legacy_alloc_children(loc, 3);
731
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
732
+ rbs_loc_legacy_add_required_child(loc, rb_intern("colon"), (rbs_loc_range) { .start = node->colon_range.start_char, .end = node->colon_range.end_char });
733
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("kind"), (rbs_loc_range) { .start = node->kind_range.start_char, .end = node->kind_range.end_char });
734
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
735
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
736
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
737
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
738
+
739
+ return CLASS_NEW_INSTANCE(
740
+ RBS_AST_Members_InstanceVariable,
741
+ 1,
742
+ &h
743
+ );
744
+ }
745
+ case RBS_AST_MEMBERS_METHOD_DEFINITION: {
746
+ rbs_ast_members_method_definition_t *node = (rbs_ast_members_method_definition_t *) instance;
747
+
748
+ VALUE h = rb_hash_new();
749
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
750
+ rbs_loc *loc = rbs_check_location(location);
751
+ rbs_loc_legacy_alloc_children(loc, 5);
752
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
753
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
754
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("kind"), (rbs_loc_range) { .start = node->kind_range.start_char, .end = node->kind_range.end_char });
755
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("overloading"), (rbs_loc_range) { .start = node->overloading_range.start_char, .end = node->overloading_range.end_char });
756
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("visibility"), (rbs_loc_range) { .start = node->visibility_range.start_char, .end = node->visibility_range.end_char });
757
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
758
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
759
+ rb_hash_aset(h, ID2SYM(rb_intern("kind")), rbs_method_definition_kind_to_ruby(node->kind)); // method_definition_kind
760
+ rb_hash_aset(h, ID2SYM(rb_intern("overloads")), rbs_node_list_to_ruby_array(ctx, node->overloads));
761
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
762
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
763
+ rb_hash_aset(h, ID2SYM(rb_intern("overloading")), node->overloading ? Qtrue : Qfalse);
764
+ rb_hash_aset(h, ID2SYM(rb_intern("visibility")), rbs_method_definition_visibility_to_ruby(node->visibility)); // method_definition_visibility
765
+
766
+ return CLASS_NEW_INSTANCE(
767
+ RBS_AST_Members_MethodDefinition,
768
+ 1,
769
+ &h
770
+ );
771
+ }
772
+ case RBS_AST_MEMBERS_METHOD_DEFINITION_OVERLOAD: {
773
+ rbs_ast_members_method_definition_overload_t *node = (rbs_ast_members_method_definition_overload_t *) instance;
774
+
775
+ VALUE h = rb_hash_new();
776
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
777
+ rb_hash_aset(h, ID2SYM(rb_intern("method_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->method_type)); // rbs_node
778
+
779
+ return CLASS_NEW_INSTANCE(
780
+ RBS_AST_Members_MethodDefinition_Overload,
781
+ 1,
782
+ &h
783
+ );
784
+ }
785
+ case RBS_AST_MEMBERS_PREPEND: {
786
+ rbs_ast_members_prepend_t *node = (rbs_ast_members_prepend_t *) instance;
787
+
788
+ VALUE h = rb_hash_new();
789
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
790
+ rbs_loc *loc = rbs_check_location(location);
791
+ rbs_loc_legacy_alloc_children(loc, 3);
792
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
793
+ rbs_loc_legacy_add_required_child(loc, rb_intern("keyword"), (rbs_loc_range) { .start = node->keyword_range.start_char, .end = node->keyword_range.end_char });
794
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
795
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
796
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
797
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
798
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
799
+ rb_hash_aset(h, ID2SYM(rb_intern("comment")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->comment)); // rbs_ast_comment
800
+
801
+ return CLASS_NEW_INSTANCE(
802
+ RBS_AST_Members_Prepend,
803
+ 1,
804
+ &h
805
+ );
806
+ }
807
+ case RBS_AST_MEMBERS_PRIVATE: {
808
+ rbs_ast_members_private_t *node = (rbs_ast_members_private_t *) instance;
809
+
810
+ VALUE h = rb_hash_new();
811
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
812
+
813
+ return CLASS_NEW_INSTANCE(
814
+ RBS_AST_Members_Private,
815
+ 1,
816
+ &h
817
+ );
818
+ }
819
+ case RBS_AST_MEMBERS_PUBLIC: {
820
+ rbs_ast_members_public_t *node = (rbs_ast_members_public_t *) instance;
821
+
822
+ VALUE h = rb_hash_new();
823
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
824
+
825
+ return CLASS_NEW_INSTANCE(
826
+ RBS_AST_Members_Public,
827
+ 1,
828
+ &h
829
+ );
830
+ }
831
+ case RBS_AST_RUBY_ANNOTATIONS_BLOCK_PARAM_TYPE_ANNOTATION: {
832
+ rbs_ast_ruby_annotations_block_param_type_annotation_t *node = (rbs_ast_ruby_annotations_block_param_type_annotation_t *) instance;
833
+
834
+ VALUE h = rb_hash_new();
835
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
836
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
837
+ rb_hash_aset(h, ID2SYM(rb_intern("ampersand_location")), rbs_location_range_to_ruby_location(ctx, node->ampersand_location));
838
+ rb_hash_aset(h, ID2SYM(rb_intern("name_location")), rbs_location_range_to_ruby_location(ctx, node->name_location)); // optional
839
+ rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_location_range_to_ruby_location(ctx, node->colon_location));
840
+ rb_hash_aset(h, ID2SYM(rb_intern("question_location")), rbs_location_range_to_ruby_location(ctx, node->question_location)); // optional
841
+ rb_hash_aset(h, ID2SYM(rb_intern("type_location")), rbs_location_range_to_ruby_location(ctx, node->type_location));
842
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_)); // rbs_node
843
+ rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_location_range_to_ruby_location(ctx, node->comment_location)); // optional
844
+
845
+ return CLASS_NEW_INSTANCE(
846
+ RBS_AST_Ruby_Annotations_BlockParamTypeAnnotation,
847
+ 1,
848
+ &h
849
+ );
850
+ }
851
+ case RBS_AST_RUBY_ANNOTATIONS_CLASS_ALIAS_ANNOTATION: {
852
+ rbs_ast_ruby_annotations_class_alias_annotation_t *node = (rbs_ast_ruby_annotations_class_alias_annotation_t *) instance;
853
+
854
+ VALUE h = rb_hash_new();
855
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
856
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
857
+ rb_hash_aset(h, ID2SYM(rb_intern("keyword_location")), rbs_location_range_to_ruby_location(ctx, node->keyword_location));
858
+ rb_hash_aset(h, ID2SYM(rb_intern("type_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_name)); // rbs_type_name
859
+ rb_hash_aset(h, ID2SYM(rb_intern("type_name_location")), rbs_location_range_to_ruby_location(ctx, node->type_name_location)); // optional
860
+
861
+ return CLASS_NEW_INSTANCE(
862
+ RBS_AST_Ruby_Annotations_ClassAliasAnnotation,
863
+ 1,
864
+ &h
865
+ );
866
+ }
867
+ case RBS_AST_RUBY_ANNOTATIONS_COLON_METHOD_TYPE_ANNOTATION: {
868
+ rbs_ast_ruby_annotations_colon_method_type_annotation_t *node = (rbs_ast_ruby_annotations_colon_method_type_annotation_t *) instance;
869
+
870
+ VALUE h = rb_hash_new();
871
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
872
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
873
+ rb_hash_aset(h, ID2SYM(rb_intern("annotations")), rbs_node_list_to_ruby_array(ctx, node->annotations));
874
+ rb_hash_aset(h, ID2SYM(rb_intern("method_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->method_type)); // rbs_node
875
+
876
+ return CLASS_NEW_INSTANCE(
877
+ RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation,
878
+ 1,
879
+ &h
880
+ );
881
+ }
882
+ case RBS_AST_RUBY_ANNOTATIONS_DOUBLE_SPLAT_PARAM_TYPE_ANNOTATION: {
883
+ rbs_ast_ruby_annotations_double_splat_param_type_annotation_t *node = (rbs_ast_ruby_annotations_double_splat_param_type_annotation_t *) instance;
884
+
885
+ VALUE h = rb_hash_new();
886
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
887
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
888
+ rb_hash_aset(h, ID2SYM(rb_intern("star2_location")), rbs_location_range_to_ruby_location(ctx, node->star2_location));
889
+ rb_hash_aset(h, ID2SYM(rb_intern("name_location")), rbs_location_range_to_ruby_location(ctx, node->name_location)); // optional
890
+ rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_location_range_to_ruby_location(ctx, node->colon_location));
891
+ rb_hash_aset(h, ID2SYM(rb_intern("param_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->param_type)); // rbs_node
892
+ rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_location_range_to_ruby_location(ctx, node->comment_location)); // optional
893
+
894
+ return CLASS_NEW_INSTANCE(
895
+ RBS_AST_Ruby_Annotations_DoubleSplatParamTypeAnnotation,
896
+ 1,
897
+ &h
898
+ );
899
+ }
900
+ case RBS_AST_RUBY_ANNOTATIONS_INSTANCE_VARIABLE_ANNOTATION: {
901
+ rbs_ast_ruby_annotations_instance_variable_annotation_t *node = (rbs_ast_ruby_annotations_instance_variable_annotation_t *) instance;
902
+
903
+ VALUE h = rb_hash_new();
904
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
905
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
906
+ rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_ast_symbol
907
+ rb_hash_aset(h, ID2SYM(rb_intern("ivar_name_location")), rbs_location_range_to_ruby_location(ctx, node->ivar_name_location));
908
+ rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_location_range_to_ruby_location(ctx, node->colon_location));
909
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
910
+ rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_location_range_to_ruby_location(ctx, node->comment_location)); // optional
911
+
912
+ return CLASS_NEW_INSTANCE(
913
+ RBS_AST_Ruby_Annotations_InstanceVariableAnnotation,
914
+ 1,
915
+ &h
916
+ );
917
+ }
918
+ case RBS_AST_RUBY_ANNOTATIONS_METHOD_TYPES_ANNOTATION: {
919
+ rbs_ast_ruby_annotations_method_types_annotation_t *node = (rbs_ast_ruby_annotations_method_types_annotation_t *) instance;
920
+
921
+ VALUE h = rb_hash_new();
922
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
923
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
924
+ rb_hash_aset(h, ID2SYM(rb_intern("overloads")), rbs_node_list_to_ruby_array(ctx, node->overloads));
925
+ rb_hash_aset(h, ID2SYM(rb_intern("vertical_bar_locations")), rbs_location_range_list_to_ruby_array(ctx, node->vertical_bar_locations));
926
+ rb_hash_aset(h, ID2SYM(rb_intern("dot3_location")), rbs_location_range_to_ruby_location(ctx, node->dot3_location)); // optional
927
+
928
+ return CLASS_NEW_INSTANCE(
929
+ RBS_AST_Ruby_Annotations_MethodTypesAnnotation,
930
+ 1,
931
+ &h
932
+ );
933
+ }
934
+ case RBS_AST_RUBY_ANNOTATIONS_MODULE_ALIAS_ANNOTATION: {
935
+ rbs_ast_ruby_annotations_module_alias_annotation_t *node = (rbs_ast_ruby_annotations_module_alias_annotation_t *) instance;
936
+
937
+ VALUE h = rb_hash_new();
938
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
939
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
940
+ rb_hash_aset(h, ID2SYM(rb_intern("keyword_location")), rbs_location_range_to_ruby_location(ctx, node->keyword_location));
941
+ rb_hash_aset(h, ID2SYM(rb_intern("type_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_name)); // rbs_type_name
942
+ rb_hash_aset(h, ID2SYM(rb_intern("type_name_location")), rbs_location_range_to_ruby_location(ctx, node->type_name_location)); // optional
943
+
944
+ return CLASS_NEW_INSTANCE(
945
+ RBS_AST_Ruby_Annotations_ModuleAliasAnnotation,
946
+ 1,
947
+ &h
948
+ );
949
+ }
950
+ case RBS_AST_RUBY_ANNOTATIONS_NODE_TYPE_ASSERTION: {
951
+ rbs_ast_ruby_annotations_node_type_assertion_t *node = (rbs_ast_ruby_annotations_node_type_assertion_t *) instance;
952
+
953
+ VALUE h = rb_hash_new();
954
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
955
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
956
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
957
+
958
+ return CLASS_NEW_INSTANCE(
959
+ RBS_AST_Ruby_Annotations_NodeTypeAssertion,
960
+ 1,
961
+ &h
962
+ );
963
+ }
964
+ case RBS_AST_RUBY_ANNOTATIONS_PARAM_TYPE_ANNOTATION: {
965
+ rbs_ast_ruby_annotations_param_type_annotation_t *node = (rbs_ast_ruby_annotations_param_type_annotation_t *) instance;
966
+
967
+ VALUE h = rb_hash_new();
968
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
969
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
970
+ rb_hash_aset(h, ID2SYM(rb_intern("name_location")), rbs_location_range_to_ruby_location(ctx, node->name_location));
971
+ rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_location_range_to_ruby_location(ctx, node->colon_location));
972
+ rb_hash_aset(h, ID2SYM(rb_intern("param_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->param_type)); // rbs_node
973
+ rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_location_range_to_ruby_location(ctx, node->comment_location)); // optional
974
+
975
+ return CLASS_NEW_INSTANCE(
976
+ RBS_AST_Ruby_Annotations_ParamTypeAnnotation,
977
+ 1,
978
+ &h
979
+ );
980
+ }
981
+ case RBS_AST_RUBY_ANNOTATIONS_RETURN_TYPE_ANNOTATION: {
982
+ rbs_ast_ruby_annotations_return_type_annotation_t *node = (rbs_ast_ruby_annotations_return_type_annotation_t *) instance;
983
+
984
+ VALUE h = rb_hash_new();
985
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
986
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
987
+ rb_hash_aset(h, ID2SYM(rb_intern("return_location")), rbs_location_range_to_ruby_location(ctx, node->return_location));
988
+ rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_location_range_to_ruby_location(ctx, node->colon_location));
989
+ rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
990
+ rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_location_range_to_ruby_location(ctx, node->comment_location)); // optional
991
+
992
+ return CLASS_NEW_INSTANCE(
993
+ RBS_AST_Ruby_Annotations_ReturnTypeAnnotation,
994
+ 1,
995
+ &h
996
+ );
997
+ }
998
+ case RBS_AST_RUBY_ANNOTATIONS_SKIP_ANNOTATION: {
999
+ rbs_ast_ruby_annotations_skip_annotation_t *node = (rbs_ast_ruby_annotations_skip_annotation_t *) instance;
1000
+
1001
+ VALUE h = rb_hash_new();
1002
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1003
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
1004
+ rb_hash_aset(h, ID2SYM(rb_intern("skip_location")), rbs_location_range_to_ruby_location(ctx, node->skip_location));
1005
+ rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_location_range_to_ruby_location(ctx, node->comment_location)); // optional
1006
+
1007
+ return CLASS_NEW_INSTANCE(
1008
+ RBS_AST_Ruby_Annotations_SkipAnnotation,
1009
+ 1,
1010
+ &h
1011
+ );
1012
+ }
1013
+ case RBS_AST_RUBY_ANNOTATIONS_SPLAT_PARAM_TYPE_ANNOTATION: {
1014
+ rbs_ast_ruby_annotations_splat_param_type_annotation_t *node = (rbs_ast_ruby_annotations_splat_param_type_annotation_t *) instance;
1015
+
1016
+ VALUE h = rb_hash_new();
1017
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1018
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
1019
+ rb_hash_aset(h, ID2SYM(rb_intern("star_location")), rbs_location_range_to_ruby_location(ctx, node->star_location));
1020
+ rb_hash_aset(h, ID2SYM(rb_intern("name_location")), rbs_location_range_to_ruby_location(ctx, node->name_location)); // optional
1021
+ rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_location_range_to_ruby_location(ctx, node->colon_location));
1022
+ rb_hash_aset(h, ID2SYM(rb_intern("param_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->param_type)); // rbs_node
1023
+ rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_location_range_to_ruby_location(ctx, node->comment_location)); // optional
1024
+
1025
+ return CLASS_NEW_INSTANCE(
1026
+ RBS_AST_Ruby_Annotations_SplatParamTypeAnnotation,
1027
+ 1,
1028
+ &h
1029
+ );
1030
+ }
1031
+ case RBS_AST_RUBY_ANNOTATIONS_TYPE_APPLICATION_ANNOTATION: {
1032
+ rbs_ast_ruby_annotations_type_application_annotation_t *node = (rbs_ast_ruby_annotations_type_application_annotation_t *) instance;
1033
+
1034
+ VALUE h = rb_hash_new();
1035
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1036
+ rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_location_range_to_ruby_location(ctx, node->prefix_location));
1037
+ rb_hash_aset(h, ID2SYM(rb_intern("type_args")), rbs_node_list_to_ruby_array(ctx, node->type_args));
1038
+ rb_hash_aset(h, ID2SYM(rb_intern("close_bracket_location")), rbs_location_range_to_ruby_location(ctx, node->close_bracket_location));
1039
+ rb_hash_aset(h, ID2SYM(rb_intern("comma_locations")), rbs_location_range_list_to_ruby_array(ctx, node->comma_locations));
1040
+
1041
+ return CLASS_NEW_INSTANCE(
1042
+ RBS_AST_Ruby_Annotations_TypeApplicationAnnotation,
1043
+ 1,
1044
+ &h
1045
+ );
1046
+ }
1047
+ case RBS_AST_STRING: {
1048
+ rbs_ast_string_t *string_node = (rbs_ast_string_t *) instance;
1049
+ rbs_string_t s = string_node->string;
1050
+
1051
+ return rb_enc_str_new(s.start, rbs_string_len(s), rb_utf8_encoding());
1052
+ }
1053
+ case RBS_AST_TYPE_PARAM: {
1054
+ rbs_ast_type_param_t *node = (rbs_ast_type_param_t *) instance;
1055
+
1056
+ VALUE h = rb_hash_new();
1057
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
1058
+ rbs_loc *loc = rbs_check_location(location);
1059
+ rbs_loc_legacy_alloc_children(loc, 6);
1060
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
1061
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("variance"), (rbs_loc_range) { .start = node->variance_range.start_char, .end = node->variance_range.end_char });
1062
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("unchecked"), (rbs_loc_range) { .start = node->unchecked_range.start_char, .end = node->unchecked_range.end_char });
1063
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("upper_bound"), (rbs_loc_range) { .start = node->upper_bound_range.start_char, .end = node->upper_bound_range.end_char });
1064
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("lower_bound"), (rbs_loc_range) { .start = node->lower_bound_range.start_char, .end = node->lower_bound_range.end_char });
1065
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("default"), (rbs_loc_range) { .start = node->default_range.start_char, .end = node->default_range.end_char });
1066
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
1067
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
1068
+ rb_hash_aset(h, ID2SYM(rb_intern("variance")), rbs_type_param_variance_to_ruby(node->variance)); // type_param_variance
1069
+ rb_hash_aset(h, ID2SYM(rb_intern("upper_bound")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->upper_bound)); // rbs_node
1070
+ rb_hash_aset(h, ID2SYM(rb_intern("lower_bound")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->lower_bound)); // rbs_node
1071
+ rb_hash_aset(h, ID2SYM(rb_intern("default_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->default_type)); // rbs_node
1072
+ rb_hash_aset(h, ID2SYM(rb_intern("unchecked")), node->unchecked ? Qtrue : Qfalse);
1073
+
1074
+ return CLASS_NEW_INSTANCE(
1075
+ RBS_AST_TypeParam,
1076
+ 1,
1077
+ &h
1078
+ );
1079
+ }
1080
+ case RBS_METHOD_TYPE: {
1081
+ rbs_method_type_t *node = (rbs_method_type_t *) instance;
1082
+
1083
+ VALUE h = rb_hash_new();
1084
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
1085
+ rbs_loc *loc = rbs_check_location(location);
1086
+ rbs_loc_legacy_alloc_children(loc, 2);
1087
+ rbs_loc_legacy_add_required_child(loc, rb_intern("type"), (rbs_loc_range) { .start = node->type_range.start_char, .end = node->type_range.end_char });
1088
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("type_params"), (rbs_loc_range) { .start = node->type_params_range.start_char, .end = node->type_params_range.end_char });
1089
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
1090
+ rb_hash_aset(h, ID2SYM(rb_intern("type_params")), rbs_node_list_to_ruby_array(ctx, node->type_params));
1091
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
1092
+ rb_hash_aset(h, ID2SYM(rb_intern("block")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->block)); // rbs_types_block
1093
+
1094
+ rb_funcall(
1095
+ RBS_AST_TypeParam,
1096
+ rb_intern("resolve_variables"),
1097
+ 1,
1098
+ rb_hash_lookup(h, ID2SYM(rb_intern("type_params")))
1099
+ );
1100
+ return CLASS_NEW_INSTANCE(
1101
+ RBS_MethodType,
1102
+ 1,
1103
+ &h
1104
+ );
1105
+ }
1106
+ case RBS_NAMESPACE: {
1107
+ rbs_namespace_t *node = (rbs_namespace_t *) instance;
1108
+
1109
+ VALUE h = rb_hash_new();
1110
+ rb_hash_aset(h, ID2SYM(rb_intern("path")), rbs_node_list_to_ruby_array(ctx, node->path));
1111
+ rb_hash_aset(h, ID2SYM(rb_intern("absolute")), node->absolute ? Qtrue : Qfalse);
1112
+
1113
+ return CLASS_NEW_INSTANCE(
1114
+ RBS_Namespace,
1115
+ 1,
1116
+ &h
1117
+ );
1118
+ }
1119
+ case RBS_SIGNATURE: {
1120
+ rbs_signature_t *signature = (rbs_signature_t *) instance;
1121
+
1122
+ VALUE array = rb_ary_new();
1123
+ rb_ary_push(array, rbs_node_list_to_ruby_array(ctx, signature->directives));
1124
+ rb_ary_push(array, rbs_node_list_to_ruby_array(ctx, signature->declarations));
1125
+ return array;
1126
+ }
1127
+ case RBS_TYPE_NAME: {
1128
+ rbs_type_name_t *node = (rbs_type_name_t *) instance;
1129
+
1130
+ VALUE h = rb_hash_new();
1131
+ rb_hash_aset(h, ID2SYM(rb_intern("namespace")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rbs_namespace)); // rbs_namespace
1132
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
1133
+
1134
+ return CLASS_NEW_INSTANCE(
1135
+ RBS_TypeName,
1136
+ 1,
1137
+ &h
1138
+ );
1139
+ }
1140
+ case RBS_TYPES_ALIAS: {
1141
+ rbs_types_alias_t *node = (rbs_types_alias_t *) instance;
1142
+
1143
+ VALUE h = rb_hash_new();
1144
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
1145
+ rbs_loc *loc = rbs_check_location(location);
1146
+ rbs_loc_legacy_alloc_children(loc, 2);
1147
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
1148
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
1149
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
1150
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
1151
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
1152
+
1153
+ return CLASS_NEW_INSTANCE(
1154
+ RBS_Types_Alias,
1155
+ 1,
1156
+ &h
1157
+ );
1158
+ }
1159
+ case RBS_TYPES_BASES_ANY: {
1160
+ rbs_types_bases_any_t *node = (rbs_types_bases_any_t *) instance;
1161
+
1162
+ VALUE h = rb_hash_new();
1163
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1164
+ rb_hash_aset(h, ID2SYM(rb_intern("todo")), node->todo ? Qtrue : Qfalse);
1165
+
1166
+ return CLASS_NEW_INSTANCE(
1167
+ RBS_Types_Bases_Any,
1168
+ 1,
1169
+ &h
1170
+ );
1171
+ }
1172
+ case RBS_TYPES_BASES_BOOL: {
1173
+ rbs_types_bases_bool_t *node = (rbs_types_bases_bool_t *) instance;
1174
+
1175
+ VALUE h = rb_hash_new();
1176
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1177
+
1178
+ return CLASS_NEW_INSTANCE(
1179
+ RBS_Types_Bases_Bool,
1180
+ 1,
1181
+ &h
1182
+ );
1183
+ }
1184
+ case RBS_TYPES_BASES_BOTTOM: {
1185
+ rbs_types_bases_bottom_t *node = (rbs_types_bases_bottom_t *) instance;
1186
+
1187
+ VALUE h = rb_hash_new();
1188
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1189
+
1190
+ return CLASS_NEW_INSTANCE(
1191
+ RBS_Types_Bases_Bottom,
1192
+ 1,
1193
+ &h
1194
+ );
1195
+ }
1196
+ case RBS_TYPES_BASES_CLASS: {
1197
+ rbs_types_bases_class_t *node = (rbs_types_bases_class_t *) instance;
1198
+
1199
+ VALUE h = rb_hash_new();
1200
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1201
+
1202
+ return CLASS_NEW_INSTANCE(
1203
+ RBS_Types_Bases_Class,
1204
+ 1,
1205
+ &h
1206
+ );
1207
+ }
1208
+ case RBS_TYPES_BASES_INSTANCE: {
1209
+ rbs_types_bases_instance_t *node = (rbs_types_bases_instance_t *) instance;
1210
+
1211
+ VALUE h = rb_hash_new();
1212
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1213
+
1214
+ return CLASS_NEW_INSTANCE(
1215
+ RBS_Types_Bases_Instance,
1216
+ 1,
1217
+ &h
1218
+ );
1219
+ }
1220
+ case RBS_TYPES_BASES_NIL: {
1221
+ rbs_types_bases_nil_t *node = (rbs_types_bases_nil_t *) instance;
1222
+
1223
+ VALUE h = rb_hash_new();
1224
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1225
+
1226
+ return CLASS_NEW_INSTANCE(
1227
+ RBS_Types_Bases_Nil,
1228
+ 1,
1229
+ &h
1230
+ );
1231
+ }
1232
+ case RBS_TYPES_BASES_SELF: {
1233
+ rbs_types_bases_self_t *node = (rbs_types_bases_self_t *) instance;
1234
+
1235
+ VALUE h = rb_hash_new();
1236
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1237
+
1238
+ return CLASS_NEW_INSTANCE(
1239
+ RBS_Types_Bases_Self,
1240
+ 1,
1241
+ &h
1242
+ );
1243
+ }
1244
+ case RBS_TYPES_BASES_TOP: {
1245
+ rbs_types_bases_top_t *node = (rbs_types_bases_top_t *) instance;
1246
+
1247
+ VALUE h = rb_hash_new();
1248
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1249
+
1250
+ return CLASS_NEW_INSTANCE(
1251
+ RBS_Types_Bases_Top,
1252
+ 1,
1253
+ &h
1254
+ );
1255
+ }
1256
+ case RBS_TYPES_BASES_VOID: {
1257
+ rbs_types_bases_void_t *node = (rbs_types_bases_void_t *) instance;
1258
+
1259
+ VALUE h = rb_hash_new();
1260
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1261
+
1262
+ return CLASS_NEW_INSTANCE(
1263
+ RBS_Types_Bases_Void,
1264
+ 1,
1265
+ &h
1266
+ );
1267
+ }
1268
+ case RBS_TYPES_BLOCK: {
1269
+ rbs_types_block_t *node = (rbs_types_block_t *) instance;
1270
+
1271
+ VALUE h = rb_hash_new();
1272
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1273
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
1274
+ rb_hash_aset(h, ID2SYM(rb_intern("required")), node->required ? Qtrue : Qfalse);
1275
+ rb_hash_aset(h, ID2SYM(rb_intern("self_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->self_type)); // rbs_node
1276
+
1277
+ return CLASS_NEW_INSTANCE(
1278
+ RBS_Types_Block,
1279
+ 1,
1280
+ &h
1281
+ );
1282
+ }
1283
+ case RBS_TYPES_CLASS_INSTANCE: {
1284
+ rbs_types_class_instance_t *node = (rbs_types_class_instance_t *) instance;
1285
+
1286
+ VALUE h = rb_hash_new();
1287
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
1288
+ rbs_loc *loc = rbs_check_location(location);
1289
+ rbs_loc_legacy_alloc_children(loc, 2);
1290
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
1291
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
1292
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
1293
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
1294
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
1295
+
1296
+ return CLASS_NEW_INSTANCE(
1297
+ RBS_Types_ClassInstance,
1298
+ 1,
1299
+ &h
1300
+ );
1301
+ }
1302
+ case RBS_TYPES_CLASS_SINGLETON: {
1303
+ rbs_types_class_singleton_t *node = (rbs_types_class_singleton_t *) instance;
1304
+
1305
+ VALUE h = rb_hash_new();
1306
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
1307
+ rbs_loc *loc = rbs_check_location(location);
1308
+ rbs_loc_legacy_alloc_children(loc, 2);
1309
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
1310
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
1311
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
1312
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
1313
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
1314
+
1315
+ return CLASS_NEW_INSTANCE(
1316
+ RBS_Types_ClassSingleton,
1317
+ 1,
1318
+ &h
1319
+ );
1320
+ }
1321
+ case RBS_TYPES_FUNCTION: {
1322
+ rbs_types_function_t *node = (rbs_types_function_t *) instance;
1323
+
1324
+ VALUE h = rb_hash_new();
1325
+ rb_hash_aset(h, ID2SYM(rb_intern("required_positionals")), rbs_node_list_to_ruby_array(ctx, node->required_positionals));
1326
+ rb_hash_aset(h, ID2SYM(rb_intern("optional_positionals")), rbs_node_list_to_ruby_array(ctx, node->optional_positionals));
1327
+ rb_hash_aset(h, ID2SYM(rb_intern("rest_positionals")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rest_positionals)); // rbs_node
1328
+ rb_hash_aset(h, ID2SYM(rb_intern("trailing_positionals")), rbs_node_list_to_ruby_array(ctx, node->trailing_positionals));
1329
+ rb_hash_aset(h, ID2SYM(rb_intern("required_keywords")), rbs_hash_to_ruby_hash(ctx, node->required_keywords));
1330
+ rb_hash_aset(h, ID2SYM(rb_intern("optional_keywords")), rbs_hash_to_ruby_hash(ctx, node->optional_keywords));
1331
+ rb_hash_aset(h, ID2SYM(rb_intern("rest_keywords")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->rest_keywords)); // rbs_node
1332
+ rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
1333
+
1334
+ return CLASS_NEW_INSTANCE(
1335
+ RBS_Types_Function,
1336
+ 1,
1337
+ &h
1338
+ );
1339
+ }
1340
+ case RBS_TYPES_FUNCTION_PARAM: {
1341
+ rbs_types_function_param_t *node = (rbs_types_function_param_t *) instance;
1342
+
1343
+ VALUE h = rb_hash_new();
1344
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
1345
+ rbs_loc *loc = rbs_check_location(location);
1346
+ rbs_loc_legacy_alloc_children(loc, 1);
1347
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
1348
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
1349
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
1350
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
1351
+
1352
+ return CLASS_NEW_INSTANCE(
1353
+ RBS_Types_Function_Param,
1354
+ 1,
1355
+ &h
1356
+ );
1357
+ }
1358
+ case RBS_TYPES_INTERFACE: {
1359
+ rbs_types_interface_t *node = (rbs_types_interface_t *) instance;
1360
+
1361
+ VALUE h = rb_hash_new();
1362
+ VALUE location = rbs_location_range_to_ruby_location(ctx, node->base.location);
1363
+ rbs_loc *loc = rbs_check_location(location);
1364
+ rbs_loc_legacy_alloc_children(loc, 2);
1365
+ rbs_loc_legacy_add_required_child(loc, rb_intern("name"), (rbs_loc_range) { .start = node->name_range.start_char, .end = node->name_range.end_char });
1366
+ rbs_loc_legacy_add_optional_child(loc, rb_intern("args"), (rbs_loc_range) { .start = node->args_range.start_char, .end = node->args_range.end_char });
1367
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), location);
1368
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_type_name
1369
+ rb_hash_aset(h, ID2SYM(rb_intern("args")), rbs_node_list_to_ruby_array(ctx, node->args));
1370
+
1371
+ return CLASS_NEW_INSTANCE(
1372
+ RBS_Types_Interface,
1373
+ 1,
1374
+ &h
1375
+ );
1376
+ }
1377
+ case RBS_TYPES_INTERSECTION: {
1378
+ rbs_types_intersection_t *node = (rbs_types_intersection_t *) instance;
1379
+
1380
+ VALUE h = rb_hash_new();
1381
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1382
+ rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
1383
+
1384
+ return CLASS_NEW_INSTANCE(
1385
+ RBS_Types_Intersection,
1386
+ 1,
1387
+ &h
1388
+ );
1389
+ }
1390
+ case RBS_TYPES_LITERAL: {
1391
+ rbs_types_literal_t *node = (rbs_types_literal_t *) instance;
1392
+
1393
+ VALUE h = rb_hash_new();
1394
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1395
+ rb_hash_aset(h, ID2SYM(rb_intern("literal")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->literal)); // rbs_node
1396
+
1397
+ return CLASS_NEW_INSTANCE(
1398
+ RBS_Types_Literal,
1399
+ 1,
1400
+ &h
1401
+ );
1402
+ }
1403
+ case RBS_TYPES_OPTIONAL: {
1404
+ rbs_types_optional_t *node = (rbs_types_optional_t *) instance;
1405
+
1406
+ VALUE h = rb_hash_new();
1407
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1408
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
1409
+
1410
+ return CLASS_NEW_INSTANCE(
1411
+ RBS_Types_Optional,
1412
+ 1,
1413
+ &h
1414
+ );
1415
+ }
1416
+ case RBS_TYPES_PROC: {
1417
+ rbs_types_proc_t *node = (rbs_types_proc_t *) instance;
1418
+
1419
+ VALUE h = rb_hash_new();
1420
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1421
+ rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
1422
+ rb_hash_aset(h, ID2SYM(rb_intern("block")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->block)); // rbs_types_block
1423
+ rb_hash_aset(h, ID2SYM(rb_intern("self_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->self_type)); // rbs_node
1424
+
1425
+ return CLASS_NEW_INSTANCE(
1426
+ RBS_Types_Proc,
1427
+ 1,
1428
+ &h
1429
+ );
1430
+ }
1431
+ case RBS_TYPES_RECORD: {
1432
+ rbs_types_record_t *node = (rbs_types_record_t *) instance;
1433
+
1434
+ VALUE h = rb_hash_new();
1435
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1436
+ rb_hash_aset(h, ID2SYM(rb_intern("all_fields")), rbs_hash_to_ruby_hash(ctx, node->all_fields));
1437
+
1438
+ return CLASS_NEW_INSTANCE(
1439
+ RBS_Types_Record,
1440
+ 1,
1441
+ &h
1442
+ );
1443
+ }
1444
+ case RBS_TYPES_RECORD_FIELD_TYPE: {
1445
+ rbs_types_record_field_type_t *record_fieldtype = (rbs_types_record_field_type_t *) instance;
1446
+
1447
+ VALUE array = rb_ary_new();
1448
+ rb_ary_push(array, rbs_struct_to_ruby_value(ctx, record_fieldtype->type));
1449
+ rb_ary_push(array, record_fieldtype->required ? Qtrue : Qfalse);
1450
+ return array;
1451
+ }
1452
+ case RBS_TYPES_TUPLE: {
1453
+ rbs_types_tuple_t *node = (rbs_types_tuple_t *) instance;
1454
+
1455
+ VALUE h = rb_hash_new();
1456
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1457
+ rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
1458
+
1459
+ return CLASS_NEW_INSTANCE(
1460
+ RBS_Types_Tuple,
1461
+ 1,
1462
+ &h
1463
+ );
1464
+ }
1465
+ case RBS_TYPES_UNION: {
1466
+ rbs_types_union_t *node = (rbs_types_union_t *) instance;
1467
+
1468
+ VALUE h = rb_hash_new();
1469
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1470
+ rb_hash_aset(h, ID2SYM(rb_intern("types")), rbs_node_list_to_ruby_array(ctx, node->types));
1471
+
1472
+ return CLASS_NEW_INSTANCE(
1473
+ RBS_Types_Union,
1474
+ 1,
1475
+ &h
1476
+ );
1477
+ }
1478
+ case RBS_TYPES_UNTYPED_FUNCTION: {
1479
+ rbs_types_untyped_function_t *node = (rbs_types_untyped_function_t *) instance;
1480
+
1481
+ VALUE h = rb_hash_new();
1482
+ rb_hash_aset(h, ID2SYM(rb_intern("return_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->return_type)); // rbs_node
1483
+
1484
+ return CLASS_NEW_INSTANCE(
1485
+ RBS_Types_UntypedFunction,
1486
+ 1,
1487
+ &h
1488
+ );
1489
+ }
1490
+ case RBS_TYPES_VARIABLE: {
1491
+ rbs_types_variable_t *node = (rbs_types_variable_t *) instance;
1492
+
1493
+ VALUE h = rb_hash_new();
1494
+ rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_location_range_to_ruby_location(ctx, node->base.location));
1495
+ rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
1496
+
1497
+ return CLASS_NEW_INSTANCE(
1498
+ RBS_Types_Variable,
1499
+ 1,
1500
+ &h
1501
+ );
1502
+ }
1503
+ case RBS_AST_SYMBOL: {
1504
+ rbs_constant_t *constant = rbs_constant_pool_id_to_constant(ctx.constant_pool, ((rbs_ast_symbol_t *) instance)->constant_id);
1505
+ assert(constant != NULL && "constant is NULL");
1506
+ assert(constant->start != NULL && "constant->start is NULL");
1507
+
1508
+ return ID2SYM(rb_intern3((const char *) constant->start, constant->length, ctx.encoding));
1509
+ }
1510
+ }
1511
+
1512
+ rb_raise(rb_eRuntimeError, "Unknown node type: %d", instance->type);
1513
+ }