rbs 4.0.0.dev.4 → 4.0.0.dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +11 -8
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +17 -34
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/valgrind.yml +42 -0
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +1 -1
- data/README.md +1 -1
- data/Rakefile +32 -5
- data/config.yml +46 -0
- data/core/array.rbs +96 -46
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +55 -41
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +7 -10
- data/core/enumerable.rbs +90 -3
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +63 -1
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +40 -20
- data/core/file.rbs +108 -78
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +225 -69
- data/core/gc.rbs +417 -281
- data/core/hash.rbs +1023 -727
- data/core/integer.rbs +104 -110
- data/core/io/buffer.rbs +21 -10
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +82 -19
- data/core/kernel.rbs +70 -59
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +63 -27
- data/core/module.rbs +103 -26
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +43 -35
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +21 -15
- data/core/pathname.rbs +1272 -0
- data/core/proc.rbs +30 -25
- data/core/process.rbs +4 -2
- data/core/ractor.rbs +361 -509
- data/core/random.rbs +17 -0
- data/core/range.rbs +113 -16
- data/core/rational.rbs +56 -85
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -113
- data/core/regexp.rbs +25 -20
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +488 -359
- data/core/signal.rbs +24 -14
- data/core/string.rbs +3171 -1241
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +17 -11
- data/core/thread.rbs +95 -33
- data/core/time.rbs +35 -9
- data/core/trace_point.rbs +7 -4
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +470 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +33 -4
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +77 -3
- data/ext/rbs_extension/ast_translation.h +3 -0
- data/ext/rbs_extension/class_constants.c +8 -2
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/extconf.rb +5 -1
- data/ext/rbs_extension/legacy_location.c +5 -5
- data/ext/rbs_extension/main.c +37 -20
- data/include/rbs/ast.h +85 -38
- data/include/rbs/defines.h +27 -0
- data/include/rbs/lexer.h +30 -11
- data/include/rbs/parser.h +6 -6
- data/include/rbs/string.h +0 -2
- data/include/rbs/util/rbs_allocator.h +34 -13
- data/include/rbs/util/rbs_assert.h +12 -1
- data/include/rbs/util/rbs_encoding.h +2 -0
- data/include/rbs/util/rbs_unescape.h +2 -1
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +137 -0
- data/lib/rbs/ast/ruby/comment_block.rb +24 -0
- data/lib/rbs/ast/ruby/declarations.rb +198 -3
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/members.rb +159 -1
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +20 -15
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -51
- data/lib/rbs/cli.rb +52 -19
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
- data/lib/rbs/definition_builder/method_builder.rb +20 -0
- data/lib/rbs/definition_builder.rb +91 -2
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +227 -74
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -7
- data/lib/rbs/inline_parser.rb +341 -5
- data/lib/rbs/location_aux.rb +1 -1
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/parser_aux.rb +2 -2
- data/lib/rbs/prototype/rb.rb +2 -2
- data/lib/rbs/prototype/rbi.rb +2 -0
- data/lib/rbs/prototype/runtime.rb +8 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +116 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +16 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +27 -27
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +3 -2
- data/schema/typeParam.json +17 -1
- data/sig/ast/ruby/annotations.rbs +124 -0
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +87 -1
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +13 -4
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -1
- data/sig/environment.rbs +70 -12
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser.rbs +39 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -1
- data/sig/method_builder.rbs +3 -1
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +16 -2
- data/sig/resolver/type_name_resolver.rbs +35 -7
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- data/sig/types.rbs +4 -4
- data/src/ast.c +80 -1
- data/src/lexer.c +1392 -1313
- data/src/lexer.re +3 -0
- data/src/lexstate.c +58 -37
- data/src/location.c +4 -4
- data/src/parser.c +412 -145
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -71
- data/src/util/rbs_assert.c +1 -1
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +10 -10
- data/src/util/rbs_encoding.c +4 -8
- data/src/util/rbs_unescape.c +56 -20
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +20 -14
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +82 -28
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +9 -27
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/open3/0/open3.rbs +459 -1
- data/stdlib/openssl/0/openssl.rbs +331 -228
- data/stdlib/optparse/0/optparse.rbs +8 -3
- data/stdlib/pathname/0/pathname.rbs +9 -1379
- data/stdlib/psych/0/psych.rbs +4 -4
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +2 -2
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +6 -19
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +1176 -85
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +16 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +24 -16
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/gzip_reader.rbs +2 -2
- data/stdlib/zlib/0/gzip_writer.rbs +1 -1
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +30 -4
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
#include "rbs_string_bridging.h"
|
|
12
12
|
#include "legacy_location.h"
|
|
13
13
|
|
|
14
|
+
VALUE EMPTY_ARRAY;
|
|
15
|
+
VALUE EMPTY_HASH;
|
|
16
|
+
|
|
14
17
|
#define RBS_LOC_CHILDREN_SIZE(cap) (sizeof(rbs_loc_children) + sizeof(rbs_loc_entry) * ((cap) - 1))
|
|
15
18
|
|
|
16
19
|
rbs_translation_context_t rbs_translation_context_create(rbs_constant_pool_t *constant_pool, VALUE buffer, rb_encoding *ruby_encoding) {
|
|
@@ -32,6 +35,10 @@ VALUE rbs_node_list_to_ruby_array(rbs_translation_context_t ctx, rbs_node_list_t
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
VALUE rbs_hash_to_ruby_hash(rbs_translation_context_t ctx, rbs_hash_t *rbs_hash) {
|
|
38
|
+
if (!rbs_hash->head) {
|
|
39
|
+
return EMPTY_HASH;
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
VALUE ruby_hash = rb_hash_new();
|
|
36
43
|
|
|
37
44
|
for (rbs_hash_node_t *n = rbs_hash->head; n != NULL; n = n->next) {
|
|
@@ -60,12 +67,12 @@ VALUE rbs_loc_to_ruby_location(rbs_translation_context_t ctx, rbs_location_t *so
|
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
VALUE rbs_location_list_to_ruby_array(rbs_translation_context_t ctx, rbs_location_list_t *list) {
|
|
63
|
-
VALUE ruby_array = rb_ary_new();
|
|
64
|
-
|
|
65
70
|
if (list == NULL) {
|
|
66
|
-
return
|
|
71
|
+
return EMPTY_ARRAY;
|
|
67
72
|
}
|
|
68
73
|
|
|
74
|
+
VALUE ruby_array = rb_ary_new();
|
|
75
|
+
|
|
69
76
|
for (rbs_location_list_node_t *n = list->head; n != NULL; n = n->next) {
|
|
70
77
|
rb_ary_push(ruby_array, rbs_loc_to_ruby_location(ctx, n->loc));
|
|
71
78
|
}
|
|
@@ -573,6 +580,22 @@ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instan
|
|
|
573
580
|
&h
|
|
574
581
|
);
|
|
575
582
|
}
|
|
583
|
+
case RBS_AST_RUBY_ANNOTATIONS_CLASS_ALIAS_ANNOTATION: {
|
|
584
|
+
rbs_ast_ruby_annotations_class_alias_annotation_t *node = (rbs_ast_ruby_annotations_class_alias_annotation_t *) instance;
|
|
585
|
+
|
|
586
|
+
VALUE h = rb_hash_new();
|
|
587
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
|
588
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
|
589
|
+
rb_hash_aset(h, ID2SYM(rb_intern("keyword_location")), rbs_loc_to_ruby_location(ctx, node->keyword_location));
|
|
590
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_name)); // rbs_type_name
|
|
591
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_name_location")), rbs_loc_to_ruby_location(ctx, node->type_name_location));
|
|
592
|
+
|
|
593
|
+
return CLASS_NEW_INSTANCE(
|
|
594
|
+
RBS_AST_Ruby_Annotations_ClassAliasAnnotation,
|
|
595
|
+
1,
|
|
596
|
+
&h
|
|
597
|
+
);
|
|
598
|
+
}
|
|
576
599
|
case RBS_AST_RUBY_ANNOTATIONS_COLON_METHOD_TYPE_ANNOTATION: {
|
|
577
600
|
rbs_ast_ruby_annotations_colon_method_type_annotation_t *node = (rbs_ast_ruby_annotations_colon_method_type_annotation_t *) instance;
|
|
578
601
|
|
|
@@ -588,6 +611,24 @@ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instan
|
|
|
588
611
|
&h
|
|
589
612
|
);
|
|
590
613
|
}
|
|
614
|
+
case RBS_AST_RUBY_ANNOTATIONS_INSTANCE_VARIABLE_ANNOTATION: {
|
|
615
|
+
rbs_ast_ruby_annotations_instance_variable_annotation_t *node = (rbs_ast_ruby_annotations_instance_variable_annotation_t *) instance;
|
|
616
|
+
|
|
617
|
+
VALUE h = rb_hash_new();
|
|
618
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
|
619
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
|
620
|
+
rb_hash_aset(h, ID2SYM(rb_intern("ivar_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->ivar_name)); // rbs_ast_symbol
|
|
621
|
+
rb_hash_aset(h, ID2SYM(rb_intern("ivar_name_location")), rbs_loc_to_ruby_location(ctx, node->ivar_name_location));
|
|
622
|
+
rb_hash_aset(h, ID2SYM(rb_intern("colon_location")), rbs_loc_to_ruby_location(ctx, node->colon_location));
|
|
623
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type)); // rbs_node
|
|
624
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comment_location")), rbs_loc_to_ruby_location(ctx, node->comment_location));
|
|
625
|
+
|
|
626
|
+
return CLASS_NEW_INSTANCE(
|
|
627
|
+
RBS_AST_Ruby_Annotations_InstanceVariableAnnotation,
|
|
628
|
+
1,
|
|
629
|
+
&h
|
|
630
|
+
);
|
|
631
|
+
}
|
|
591
632
|
case RBS_AST_RUBY_ANNOTATIONS_METHOD_TYPES_ANNOTATION: {
|
|
592
633
|
rbs_ast_ruby_annotations_method_types_annotation_t *node = (rbs_ast_ruby_annotations_method_types_annotation_t *) instance;
|
|
593
634
|
|
|
@@ -603,6 +644,22 @@ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instan
|
|
|
603
644
|
&h
|
|
604
645
|
);
|
|
605
646
|
}
|
|
647
|
+
case RBS_AST_RUBY_ANNOTATIONS_MODULE_ALIAS_ANNOTATION: {
|
|
648
|
+
rbs_ast_ruby_annotations_module_alias_annotation_t *node = (rbs_ast_ruby_annotations_module_alias_annotation_t *) instance;
|
|
649
|
+
|
|
650
|
+
VALUE h = rb_hash_new();
|
|
651
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
|
652
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
|
653
|
+
rb_hash_aset(h, ID2SYM(rb_intern("keyword_location")), rbs_loc_to_ruby_location(ctx, node->keyword_location));
|
|
654
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->type_name)); // rbs_type_name
|
|
655
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_name_location")), rbs_loc_to_ruby_location(ctx, node->type_name_location));
|
|
656
|
+
|
|
657
|
+
return CLASS_NEW_INSTANCE(
|
|
658
|
+
RBS_AST_Ruby_Annotations_ModuleAliasAnnotation,
|
|
659
|
+
1,
|
|
660
|
+
&h
|
|
661
|
+
);
|
|
662
|
+
}
|
|
606
663
|
case RBS_AST_RUBY_ANNOTATIONS_NODE_TYPE_ASSERTION: {
|
|
607
664
|
rbs_ast_ruby_annotations_node_type_assertion_t *node = (rbs_ast_ruby_annotations_node_type_assertion_t *) instance;
|
|
608
665
|
|
|
@@ -649,6 +706,22 @@ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instan
|
|
|
649
706
|
&h
|
|
650
707
|
);
|
|
651
708
|
}
|
|
709
|
+
case RBS_AST_RUBY_ANNOTATIONS_TYPE_APPLICATION_ANNOTATION: {
|
|
710
|
+
rbs_ast_ruby_annotations_type_application_annotation_t *node = (rbs_ast_ruby_annotations_type_application_annotation_t *) instance;
|
|
711
|
+
|
|
712
|
+
VALUE h = rb_hash_new();
|
|
713
|
+
rb_hash_aset(h, ID2SYM(rb_intern("location")), rbs_loc_to_ruby_location(ctx, node->base.location));
|
|
714
|
+
rb_hash_aset(h, ID2SYM(rb_intern("prefix_location")), rbs_loc_to_ruby_location(ctx, node->prefix_location));
|
|
715
|
+
rb_hash_aset(h, ID2SYM(rb_intern("type_args")), rbs_node_list_to_ruby_array(ctx, node->type_args));
|
|
716
|
+
rb_hash_aset(h, ID2SYM(rb_intern("close_bracket_location")), rbs_loc_to_ruby_location(ctx, node->close_bracket_location));
|
|
717
|
+
rb_hash_aset(h, ID2SYM(rb_intern("comma_locations")), rbs_location_list_to_ruby_array(ctx, node->comma_locations));
|
|
718
|
+
|
|
719
|
+
return CLASS_NEW_INSTANCE(
|
|
720
|
+
RBS_AST_Ruby_Annotations_TypeApplicationAnnotation,
|
|
721
|
+
1,
|
|
722
|
+
&h
|
|
723
|
+
);
|
|
724
|
+
}
|
|
652
725
|
case RBS_AST_STRING: {
|
|
653
726
|
rbs_ast_string_t *string_node = (rbs_ast_string_t *) instance;
|
|
654
727
|
rbs_string_t s = string_node->string;
|
|
@@ -663,6 +736,7 @@ VALUE rbs_struct_to_ruby_value(rbs_translation_context_t ctx, rbs_node_t *instan
|
|
|
663
736
|
rb_hash_aset(h, ID2SYM(rb_intern("name")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->name)); // rbs_ast_symbol
|
|
664
737
|
rb_hash_aset(h, ID2SYM(rb_intern("variance")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->variance)); // rbs_keyword
|
|
665
738
|
rb_hash_aset(h, ID2SYM(rb_intern("upper_bound")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->upper_bound)); // rbs_node
|
|
739
|
+
rb_hash_aset(h, ID2SYM(rb_intern("lower_bound")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->lower_bound)); // rbs_node
|
|
666
740
|
rb_hash_aset(h, ID2SYM(rb_intern("default_type")), rbs_struct_to_ruby_value(ctx, (rbs_node_t *) node->default_type)); // rbs_node
|
|
667
741
|
rb_hash_aset(h, ID2SYM(rb_intern("unchecked")), node->unchecked ? Qtrue : Qfalse);
|
|
668
742
|
|
|
@@ -31,4 +31,7 @@ VALUE rbs_node_list_to_ruby_array(rbs_translation_context_t, rbs_node_list_t *li
|
|
|
31
31
|
VALUE rbs_hash_to_ruby_hash(rbs_translation_context_t, rbs_hash_t *hash);
|
|
32
32
|
VALUE rbs_struct_to_ruby_value(rbs_translation_context_t, rbs_node_t *instance);
|
|
33
33
|
|
|
34
|
+
extern VALUE EMPTY_ARRAY;
|
|
35
|
+
extern VALUE EMPTY_HASH;
|
|
36
|
+
|
|
34
37
|
#endif
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#include "rbs_extension.h"
|
|
9
9
|
|
|
10
|
-
VALUE RBS_Parser;
|
|
11
|
-
|
|
12
10
|
VALUE RBS;
|
|
13
11
|
VALUE RBS_AST;
|
|
14
12
|
VALUE RBS_AST_Declarations;
|
|
@@ -49,11 +47,15 @@ VALUE RBS_AST_Members_MethodDefinition_Overload;
|
|
|
49
47
|
VALUE RBS_AST_Members_Prepend;
|
|
50
48
|
VALUE RBS_AST_Members_Private;
|
|
51
49
|
VALUE RBS_AST_Members_Public;
|
|
50
|
+
VALUE RBS_AST_Ruby_Annotations_ClassAliasAnnotation;
|
|
52
51
|
VALUE RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation;
|
|
52
|
+
VALUE RBS_AST_Ruby_Annotations_InstanceVariableAnnotation;
|
|
53
53
|
VALUE RBS_AST_Ruby_Annotations_MethodTypesAnnotation;
|
|
54
|
+
VALUE RBS_AST_Ruby_Annotations_ModuleAliasAnnotation;
|
|
54
55
|
VALUE RBS_AST_Ruby_Annotations_NodeTypeAssertion;
|
|
55
56
|
VALUE RBS_AST_Ruby_Annotations_ReturnTypeAnnotation;
|
|
56
57
|
VALUE RBS_AST_Ruby_Annotations_SkipAnnotation;
|
|
58
|
+
VALUE RBS_AST_Ruby_Annotations_TypeApplicationAnnotation;
|
|
57
59
|
VALUE RBS_AST_TypeParam;
|
|
58
60
|
VALUE RBS_MethodType;
|
|
59
61
|
VALUE RBS_Namespace;
|
|
@@ -134,11 +136,15 @@ void rbs__init_constants(void) {
|
|
|
134
136
|
IMPORT_CONSTANT(RBS_AST_Members_Prepend, RBS_AST_Members, "Prepend");
|
|
135
137
|
IMPORT_CONSTANT(RBS_AST_Members_Private, RBS_AST_Members, "Private");
|
|
136
138
|
IMPORT_CONSTANT(RBS_AST_Members_Public, RBS_AST_Members, "Public");
|
|
139
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_ClassAliasAnnotation, RBS_AST_Ruby_Annotations, "ClassAliasAnnotation");
|
|
137
140
|
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation, RBS_AST_Ruby_Annotations, "ColonMethodTypeAnnotation");
|
|
141
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_InstanceVariableAnnotation, RBS_AST_Ruby_Annotations, "InstanceVariableAnnotation");
|
|
138
142
|
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_MethodTypesAnnotation, RBS_AST_Ruby_Annotations, "MethodTypesAnnotation");
|
|
143
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_ModuleAliasAnnotation, RBS_AST_Ruby_Annotations, "ModuleAliasAnnotation");
|
|
139
144
|
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_NodeTypeAssertion, RBS_AST_Ruby_Annotations, "NodeTypeAssertion");
|
|
140
145
|
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_ReturnTypeAnnotation, RBS_AST_Ruby_Annotations, "ReturnTypeAnnotation");
|
|
141
146
|
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_SkipAnnotation, RBS_AST_Ruby_Annotations, "SkipAnnotation");
|
|
147
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_TypeApplicationAnnotation, RBS_AST_Ruby_Annotations, "TypeApplicationAnnotation");
|
|
142
148
|
IMPORT_CONSTANT(RBS_AST_TypeParam, RBS_AST, "TypeParam");
|
|
143
149
|
IMPORT_CONSTANT(RBS_MethodType, RBS, "MethodType");
|
|
144
150
|
IMPORT_CONSTANT(RBS_Namespace, RBS, "Namespace");
|
|
@@ -55,11 +55,15 @@ extern VALUE RBS_AST_Members_MethodDefinition_Overload;
|
|
|
55
55
|
extern VALUE RBS_AST_Members_Prepend;
|
|
56
56
|
extern VALUE RBS_AST_Members_Private;
|
|
57
57
|
extern VALUE RBS_AST_Members_Public;
|
|
58
|
+
extern VALUE RBS_AST_Ruby_Annotations_ClassAliasAnnotation;
|
|
58
59
|
extern VALUE RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation;
|
|
60
|
+
extern VALUE RBS_AST_Ruby_Annotations_InstanceVariableAnnotation;
|
|
59
61
|
extern VALUE RBS_AST_Ruby_Annotations_MethodTypesAnnotation;
|
|
62
|
+
extern VALUE RBS_AST_Ruby_Annotations_ModuleAliasAnnotation;
|
|
60
63
|
extern VALUE RBS_AST_Ruby_Annotations_NodeTypeAssertion;
|
|
61
64
|
extern VALUE RBS_AST_Ruby_Annotations_ReturnTypeAnnotation;
|
|
62
65
|
extern VALUE RBS_AST_Ruby_Annotations_SkipAnnotation;
|
|
66
|
+
extern VALUE RBS_AST_Ruby_Annotations_TypeApplicationAnnotation;
|
|
63
67
|
extern VALUE RBS_AST_TypeParam;
|
|
64
68
|
extern VALUE RBS_MethodType;
|
|
65
69
|
extern VALUE RBS_Namespace;
|
|
@@ -18,7 +18,11 @@ append_cflags [
|
|
|
18
18
|
'-Wc++-compat',
|
|
19
19
|
]
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
if ENV['DEBUG']
|
|
22
|
+
append_cflags ['-O0', '-pg']
|
|
23
|
+
else
|
|
24
|
+
append_cflags ['-DNDEBUG']
|
|
25
|
+
end
|
|
22
26
|
if ENV["TEST_NO_C23"]
|
|
23
27
|
puts "Adding -Wc2x-extensions to CFLAGS"
|
|
24
28
|
$CFLAGS << " -Werror -Wc2x-extensions"
|
|
@@ -33,7 +33,7 @@ void rbs_loc_legacy_alloc_children(rbs_loc *loc, unsigned short cap) {
|
|
|
33
33
|
check_children_max(cap);
|
|
34
34
|
|
|
35
35
|
size_t s = RBS_LOC_CHILDREN_SIZE(cap);
|
|
36
|
-
loc->children = malloc(s);
|
|
36
|
+
loc->children = (rbs_loc_children *) malloc(s);
|
|
37
37
|
|
|
38
38
|
*loc->children = (rbs_loc_children) {
|
|
39
39
|
.len = 0,
|
|
@@ -50,7 +50,7 @@ static void check_children_cap(rbs_loc *loc) {
|
|
|
50
50
|
if (loc->children->len == loc->children->cap) {
|
|
51
51
|
check_children_max(loc->children->cap + 1);
|
|
52
52
|
size_t s = RBS_LOC_CHILDREN_SIZE(++loc->children->cap);
|
|
53
|
-
loc->children = realloc(loc->children, s);
|
|
53
|
+
loc->children = (rbs_loc_children *) realloc(loc->children, s);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -86,12 +86,12 @@ void rbs_loc_free(rbs_loc *loc) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
static void rbs_loc_mark(void *ptr) {
|
|
89
|
-
rbs_loc *loc = ptr;
|
|
89
|
+
rbs_loc *loc = (rbs_loc *) ptr;
|
|
90
90
|
rb_gc_mark(loc->buffer);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
static size_t rbs_loc_memsize(const void *ptr) {
|
|
94
|
-
const rbs_loc *loc = ptr;
|
|
94
|
+
const rbs_loc *loc = (const rbs_loc *) ptr;
|
|
95
95
|
if (loc->children == NULL) {
|
|
96
96
|
return sizeof(rbs_loc);
|
|
97
97
|
} else {
|
|
@@ -117,7 +117,7 @@ static VALUE location_s_allocate(VALUE klass) {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
rbs_loc *rbs_check_location(VALUE obj) {
|
|
120
|
-
return rb_check_typeddata(obj, &location_type);
|
|
120
|
+
return (rbs_loc *) rb_check_typeddata(obj, &location_type);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
static VALUE location_initialize(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos) {
|
data/ext/rbs_extension/main.c
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
* */
|
|
18
18
|
static NORETURN(void) raise_error(rbs_error_t *error, VALUE buffer) {
|
|
19
|
-
|
|
19
|
+
RBS_ASSERT(error != NULL, "raise_error() called with NULL error");
|
|
20
20
|
|
|
21
21
|
if (!error->syntax_error) {
|
|
22
22
|
rb_raise(rb_eRuntimeError, "Unexpected error");
|
|
@@ -85,6 +85,22 @@ struct parse_type_arg {
|
|
|
85
85
|
rb_encoding *encoding;
|
|
86
86
|
rbs_parser_t *parser;
|
|
87
87
|
VALUE require_eof;
|
|
88
|
+
VALUE void_allowed;
|
|
89
|
+
VALUE self_allowed;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
struct parse_method_type_arg {
|
|
93
|
+
VALUE buffer;
|
|
94
|
+
rb_encoding *encoding;
|
|
95
|
+
rbs_parser_t *parser;
|
|
96
|
+
VALUE require_eof;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
struct parse_signature_arg {
|
|
100
|
+
VALUE buffer;
|
|
101
|
+
rb_encoding *encoding;
|
|
102
|
+
rbs_parser_t *parser;
|
|
103
|
+
VALUE require_eof;
|
|
88
104
|
};
|
|
89
105
|
|
|
90
106
|
static VALUE ensure_free_parser(VALUE parser) {
|
|
@@ -100,8 +116,11 @@ static VALUE parse_type_try(VALUE a) {
|
|
|
100
116
|
return Qnil;
|
|
101
117
|
}
|
|
102
118
|
|
|
119
|
+
bool void_allowed = RTEST(arg->void_allowed);
|
|
120
|
+
bool self_allowed = RTEST(arg->self_allowed);
|
|
121
|
+
|
|
103
122
|
rbs_node_t *type;
|
|
104
|
-
rbs_parse_type(parser, &type);
|
|
123
|
+
rbs_parse_type(parser, &type, void_allowed, self_allowed);
|
|
105
124
|
|
|
106
125
|
raise_error_if_any(parser, arg->buffer);
|
|
107
126
|
|
|
@@ -157,7 +176,7 @@ static rbs_parser_t *alloc_parser_from_buffer(VALUE buffer, int start_pos, int e
|
|
|
157
176
|
);
|
|
158
177
|
}
|
|
159
178
|
|
|
160
|
-
static VALUE rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE require_eof) {
|
|
179
|
+
static VALUE rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE require_eof, VALUE void_allowed, VALUE self_allowed) {
|
|
161
180
|
VALUE string = rb_funcall(buffer, rb_intern("content"), 0);
|
|
162
181
|
StringValue(string);
|
|
163
182
|
rb_encoding *encoding = rb_enc_get(string);
|
|
@@ -168,7 +187,9 @@ static VALUE rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VAL
|
|
|
168
187
|
.buffer = buffer,
|
|
169
188
|
.encoding = encoding,
|
|
170
189
|
.parser = parser,
|
|
171
|
-
.require_eof = require_eof
|
|
190
|
+
.require_eof = require_eof,
|
|
191
|
+
.void_allowed = void_allowed,
|
|
192
|
+
.self_allowed = self_allowed
|
|
172
193
|
};
|
|
173
194
|
|
|
174
195
|
VALUE result = rb_ensure(parse_type_try, (VALUE) &arg, ensure_free_parser, (VALUE) parser);
|
|
@@ -179,7 +200,7 @@ static VALUE rbsparser_parse_type(VALUE self, VALUE buffer, VALUE start_pos, VAL
|
|
|
179
200
|
}
|
|
180
201
|
|
|
181
202
|
static VALUE parse_method_type_try(VALUE a) {
|
|
182
|
-
struct
|
|
203
|
+
struct parse_method_type_arg *arg = (struct parse_method_type_arg *) a;
|
|
183
204
|
rbs_parser_t *parser = arg->parser;
|
|
184
205
|
|
|
185
206
|
if (parser->next_token.type == pEOF) {
|
|
@@ -187,18 +208,10 @@ static VALUE parse_method_type_try(VALUE a) {
|
|
|
187
208
|
}
|
|
188
209
|
|
|
189
210
|
rbs_method_type_t *method_type = NULL;
|
|
190
|
-
rbs_parse_method_type(parser, &method_type);
|
|
211
|
+
rbs_parse_method_type(parser, &method_type, RB_TEST(arg->require_eof));
|
|
191
212
|
|
|
192
213
|
raise_error_if_any(parser, arg->buffer);
|
|
193
214
|
|
|
194
|
-
if (RB_TEST(arg->require_eof)) {
|
|
195
|
-
rbs_parser_advance(parser);
|
|
196
|
-
if (parser->current_token.type != pEOF) {
|
|
197
|
-
rbs_parser_set_error(parser, parser->current_token, true, "expected a token `%s`", rbs_token_type_str(pEOF));
|
|
198
|
-
raise_error(parser->error, arg->buffer);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
215
|
rbs_translation_context_t ctx = rbs_translation_context_create(
|
|
203
216
|
&parser->constant_pool,
|
|
204
217
|
arg->buffer,
|
|
@@ -215,7 +228,7 @@ static VALUE rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE start_p
|
|
|
215
228
|
|
|
216
229
|
rbs_parser_t *parser = alloc_parser_from_buffer(buffer, FIX2INT(start_pos), FIX2INT(end_pos));
|
|
217
230
|
declare_type_variables(parser, variables, buffer);
|
|
218
|
-
struct
|
|
231
|
+
struct parse_method_type_arg arg = {
|
|
219
232
|
.buffer = buffer,
|
|
220
233
|
.encoding = encoding,
|
|
221
234
|
.parser = parser,
|
|
@@ -230,7 +243,7 @@ static VALUE rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE start_p
|
|
|
230
243
|
}
|
|
231
244
|
|
|
232
245
|
static VALUE parse_signature_try(VALUE a) {
|
|
233
|
-
struct
|
|
246
|
+
struct parse_signature_arg *arg = (struct parse_signature_arg *) a;
|
|
234
247
|
rbs_parser_t *parser = arg->parser;
|
|
235
248
|
|
|
236
249
|
rbs_signature_t *signature = NULL;
|
|
@@ -253,7 +266,7 @@ static VALUE rbsparser_parse_signature(VALUE self, VALUE buffer, VALUE start_pos
|
|
|
253
266
|
rb_encoding *encoding = rb_enc_get(string);
|
|
254
267
|
|
|
255
268
|
rbs_parser_t *parser = alloc_parser_from_buffer(buffer, FIX2INT(start_pos), FIX2INT(end_pos));
|
|
256
|
-
struct
|
|
269
|
+
struct parse_signature_arg arg = {
|
|
257
270
|
.buffer = buffer,
|
|
258
271
|
.encoding = encoding,
|
|
259
272
|
.parser = parser,
|
|
@@ -429,10 +442,14 @@ static VALUE rbsparser_lex(VALUE self, VALUE buffer, VALUE end_pos) {
|
|
|
429
442
|
void rbs__init_parser(void) {
|
|
430
443
|
RBS_Parser = rb_define_class_under(RBS, "Parser", rb_cObject);
|
|
431
444
|
rb_gc_register_mark_object(RBS_Parser);
|
|
432
|
-
VALUE empty_array = rb_obj_freeze(rb_ary_new());
|
|
433
|
-
rb_gc_register_mark_object(empty_array);
|
|
434
445
|
|
|
435
|
-
|
|
446
|
+
EMPTY_ARRAY = rb_obj_freeze(rb_ary_new());
|
|
447
|
+
rb_gc_register_mark_object(EMPTY_ARRAY);
|
|
448
|
+
|
|
449
|
+
EMPTY_HASH = rb_obj_freeze(rb_hash_new());
|
|
450
|
+
rb_gc_register_mark_object(EMPTY_HASH);
|
|
451
|
+
|
|
452
|
+
rb_define_singleton_method(RBS_Parser, "_parse_type", rbsparser_parse_type, 7);
|
|
436
453
|
rb_define_singleton_method(RBS_Parser, "_parse_method_type", rbsparser_parse_method_type, 5);
|
|
437
454
|
rb_define_singleton_method(RBS_Parser, "_parse_signature", rbsparser_parse_signature, 3);
|
|
438
455
|
rb_define_singleton_method(RBS_Parser, "_parse_type_params", rbsparser_parse_type_params, 4);
|
data/include/rbs/ast.h
CHANGED
|
@@ -45,43 +45,47 @@ enum rbs_node_type {
|
|
|
45
45
|
RBS_AST_MEMBERS_PREPEND = 29,
|
|
46
46
|
RBS_AST_MEMBERS_PRIVATE = 30,
|
|
47
47
|
RBS_AST_MEMBERS_PUBLIC = 31,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
48
|
+
RBS_AST_RUBY_ANNOTATIONS_CLASS_ALIAS_ANNOTATION = 32,
|
|
49
|
+
RBS_AST_RUBY_ANNOTATIONS_COLON_METHOD_TYPE_ANNOTATION = 33,
|
|
50
|
+
RBS_AST_RUBY_ANNOTATIONS_INSTANCE_VARIABLE_ANNOTATION = 34,
|
|
51
|
+
RBS_AST_RUBY_ANNOTATIONS_METHOD_TYPES_ANNOTATION = 35,
|
|
52
|
+
RBS_AST_RUBY_ANNOTATIONS_MODULE_ALIAS_ANNOTATION = 36,
|
|
53
|
+
RBS_AST_RUBY_ANNOTATIONS_NODE_TYPE_ASSERTION = 37,
|
|
54
|
+
RBS_AST_RUBY_ANNOTATIONS_RETURN_TYPE_ANNOTATION = 38,
|
|
55
|
+
RBS_AST_RUBY_ANNOTATIONS_SKIP_ANNOTATION = 39,
|
|
56
|
+
RBS_AST_RUBY_ANNOTATIONS_TYPE_APPLICATION_ANNOTATION = 40,
|
|
57
|
+
RBS_AST_STRING = 41,
|
|
58
|
+
RBS_AST_TYPE_PARAM = 42,
|
|
59
|
+
RBS_METHOD_TYPE = 43,
|
|
60
|
+
RBS_NAMESPACE = 44,
|
|
61
|
+
RBS_SIGNATURE = 45,
|
|
62
|
+
RBS_TYPE_NAME = 46,
|
|
63
|
+
RBS_TYPES_ALIAS = 47,
|
|
64
|
+
RBS_TYPES_BASES_ANY = 48,
|
|
65
|
+
RBS_TYPES_BASES_BOOL = 49,
|
|
66
|
+
RBS_TYPES_BASES_BOTTOM = 50,
|
|
67
|
+
RBS_TYPES_BASES_CLASS = 51,
|
|
68
|
+
RBS_TYPES_BASES_INSTANCE = 52,
|
|
69
|
+
RBS_TYPES_BASES_NIL = 53,
|
|
70
|
+
RBS_TYPES_BASES_SELF = 54,
|
|
71
|
+
RBS_TYPES_BASES_TOP = 55,
|
|
72
|
+
RBS_TYPES_BASES_VOID = 56,
|
|
73
|
+
RBS_TYPES_BLOCK = 57,
|
|
74
|
+
RBS_TYPES_CLASS_INSTANCE = 58,
|
|
75
|
+
RBS_TYPES_CLASS_SINGLETON = 59,
|
|
76
|
+
RBS_TYPES_FUNCTION = 60,
|
|
77
|
+
RBS_TYPES_FUNCTION_PARAM = 61,
|
|
78
|
+
RBS_TYPES_INTERFACE = 62,
|
|
79
|
+
RBS_TYPES_INTERSECTION = 63,
|
|
80
|
+
RBS_TYPES_LITERAL = 64,
|
|
81
|
+
RBS_TYPES_OPTIONAL = 65,
|
|
82
|
+
RBS_TYPES_PROC = 66,
|
|
83
|
+
RBS_TYPES_RECORD = 67,
|
|
84
|
+
RBS_TYPES_RECORD_FIELD_TYPE = 68,
|
|
85
|
+
RBS_TYPES_TUPLE = 69,
|
|
86
|
+
RBS_TYPES_UNION = 70,
|
|
87
|
+
RBS_TYPES_UNTYPED_FUNCTION = 71,
|
|
88
|
+
RBS_TYPES_VARIABLE = 72,
|
|
85
89
|
RBS_KEYWORD,
|
|
86
90
|
RBS_AST_SYMBOL,
|
|
87
91
|
};
|
|
@@ -397,6 +401,15 @@ typedef struct rbs_ast_members_public {
|
|
|
397
401
|
|
|
398
402
|
} rbs_ast_members_public_t;
|
|
399
403
|
|
|
404
|
+
typedef struct rbs_ast_ruby_annotations_class_alias_annotation {
|
|
405
|
+
rbs_node_t base;
|
|
406
|
+
|
|
407
|
+
struct rbs_location *prefix_location;
|
|
408
|
+
struct rbs_location *keyword_location;
|
|
409
|
+
struct rbs_type_name *type_name;
|
|
410
|
+
struct rbs_location *type_name_location;
|
|
411
|
+
} rbs_ast_ruby_annotations_class_alias_annotation_t;
|
|
412
|
+
|
|
400
413
|
typedef struct rbs_ast_ruby_annotations_colon_method_type_annotation {
|
|
401
414
|
rbs_node_t base;
|
|
402
415
|
|
|
@@ -405,6 +418,17 @@ typedef struct rbs_ast_ruby_annotations_colon_method_type_annotation {
|
|
|
405
418
|
struct rbs_node *method_type;
|
|
406
419
|
} rbs_ast_ruby_annotations_colon_method_type_annotation_t;
|
|
407
420
|
|
|
421
|
+
typedef struct rbs_ast_ruby_annotations_instance_variable_annotation {
|
|
422
|
+
rbs_node_t base;
|
|
423
|
+
|
|
424
|
+
struct rbs_location *prefix_location;
|
|
425
|
+
struct rbs_ast_symbol *ivar_name;
|
|
426
|
+
struct rbs_location *ivar_name_location;
|
|
427
|
+
struct rbs_location *colon_location;
|
|
428
|
+
struct rbs_node *type;
|
|
429
|
+
struct rbs_location *comment_location;
|
|
430
|
+
} rbs_ast_ruby_annotations_instance_variable_annotation_t;
|
|
431
|
+
|
|
408
432
|
typedef struct rbs_ast_ruby_annotations_method_types_annotation {
|
|
409
433
|
rbs_node_t base;
|
|
410
434
|
|
|
@@ -413,6 +437,15 @@ typedef struct rbs_ast_ruby_annotations_method_types_annotation {
|
|
|
413
437
|
struct rbs_location_list *vertical_bar_locations;
|
|
414
438
|
} rbs_ast_ruby_annotations_method_types_annotation_t;
|
|
415
439
|
|
|
440
|
+
typedef struct rbs_ast_ruby_annotations_module_alias_annotation {
|
|
441
|
+
rbs_node_t base;
|
|
442
|
+
|
|
443
|
+
struct rbs_location *prefix_location;
|
|
444
|
+
struct rbs_location *keyword_location;
|
|
445
|
+
struct rbs_type_name *type_name;
|
|
446
|
+
struct rbs_location *type_name_location;
|
|
447
|
+
} rbs_ast_ruby_annotations_module_alias_annotation_t;
|
|
448
|
+
|
|
416
449
|
typedef struct rbs_ast_ruby_annotations_node_type_assertion {
|
|
417
450
|
rbs_node_t base;
|
|
418
451
|
|
|
@@ -438,6 +471,15 @@ typedef struct rbs_ast_ruby_annotations_skip_annotation {
|
|
|
438
471
|
struct rbs_location *comment_location;
|
|
439
472
|
} rbs_ast_ruby_annotations_skip_annotation_t;
|
|
440
473
|
|
|
474
|
+
typedef struct rbs_ast_ruby_annotations_type_application_annotation {
|
|
475
|
+
rbs_node_t base;
|
|
476
|
+
|
|
477
|
+
struct rbs_location *prefix_location;
|
|
478
|
+
struct rbs_node_list *type_args;
|
|
479
|
+
struct rbs_location *close_bracket_location;
|
|
480
|
+
struct rbs_location_list *comma_locations;
|
|
481
|
+
} rbs_ast_ruby_annotations_type_application_annotation_t;
|
|
482
|
+
|
|
441
483
|
typedef struct rbs_ast_string {
|
|
442
484
|
rbs_node_t base;
|
|
443
485
|
|
|
@@ -450,6 +492,7 @@ typedef struct rbs_ast_type_param {
|
|
|
450
492
|
struct rbs_ast_symbol *name;
|
|
451
493
|
struct rbs_keyword *variance;
|
|
452
494
|
struct rbs_node *upper_bound;
|
|
495
|
+
struct rbs_node *lower_bound;
|
|
453
496
|
struct rbs_node *default_type;
|
|
454
497
|
bool unchecked;
|
|
455
498
|
} rbs_ast_type_param_t;
|
|
@@ -706,13 +749,17 @@ rbs_ast_members_method_definition_overload_t *rbs_ast_members_method_definition_
|
|
|
706
749
|
rbs_ast_members_prepend_t *rbs_ast_members_prepend_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_type_name_t *name, rbs_node_list_t *args, rbs_node_list_t *annotations, rbs_ast_comment_t *comment);
|
|
707
750
|
rbs_ast_members_private_t *rbs_ast_members_private_new(rbs_allocator_t *allocator, rbs_location_t *location);
|
|
708
751
|
rbs_ast_members_public_t *rbs_ast_members_public_new(rbs_allocator_t *allocator, rbs_location_t *location);
|
|
752
|
+
rbs_ast_ruby_annotations_class_alias_annotation_t *rbs_ast_ruby_annotations_class_alias_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_location_t *keyword_location, rbs_type_name_t *type_name, rbs_location_t *type_name_location);
|
|
709
753
|
rbs_ast_ruby_annotations_colon_method_type_annotation_t *rbs_ast_ruby_annotations_colon_method_type_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_node_list_t *annotations, rbs_node_t *method_type);
|
|
754
|
+
rbs_ast_ruby_annotations_instance_variable_annotation_t *rbs_ast_ruby_annotations_instance_variable_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_ast_symbol_t *ivar_name, rbs_location_t *ivar_name_location, rbs_location_t *colon_location, rbs_node_t *type, rbs_location_t *comment_location);
|
|
710
755
|
rbs_ast_ruby_annotations_method_types_annotation_t *rbs_ast_ruby_annotations_method_types_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_node_list_t *overloads, rbs_location_list_t *vertical_bar_locations);
|
|
756
|
+
rbs_ast_ruby_annotations_module_alias_annotation_t *rbs_ast_ruby_annotations_module_alias_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_location_t *keyword_location, rbs_type_name_t *type_name, rbs_location_t *type_name_location);
|
|
711
757
|
rbs_ast_ruby_annotations_node_type_assertion_t *rbs_ast_ruby_annotations_node_type_assertion_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_node_t *type);
|
|
712
758
|
rbs_ast_ruby_annotations_return_type_annotation_t *rbs_ast_ruby_annotations_return_type_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_location_t *return_location, rbs_location_t *colon_location, rbs_node_t *return_type, rbs_location_t *comment_location);
|
|
713
759
|
rbs_ast_ruby_annotations_skip_annotation_t *rbs_ast_ruby_annotations_skip_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_location_t *skip_location, rbs_location_t *comment_location);
|
|
760
|
+
rbs_ast_ruby_annotations_type_application_annotation_t *rbs_ast_ruby_annotations_type_application_annotation_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_location_t *prefix_location, rbs_node_list_t *type_args, rbs_location_t *close_bracket_location, rbs_location_list_t *comma_locations);
|
|
714
761
|
rbs_ast_string_t *rbs_ast_string_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_string_t string);
|
|
715
|
-
rbs_ast_type_param_t *rbs_ast_type_param_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_ast_symbol_t *name, rbs_keyword_t *variance, rbs_node_t *upper_bound, rbs_node_t *default_type, bool unchecked);
|
|
762
|
+
rbs_ast_type_param_t *rbs_ast_type_param_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_ast_symbol_t *name, rbs_keyword_t *variance, rbs_node_t *upper_bound, rbs_node_t *lower_bound, rbs_node_t *default_type, bool unchecked);
|
|
716
763
|
rbs_method_type_t *rbs_method_type_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_node_list_t *type_params, rbs_node_t *type, rbs_types_block_t *block);
|
|
717
764
|
rbs_namespace_t *rbs_namespace_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_node_list_t *path, bool absolute);
|
|
718
765
|
rbs_signature_t *rbs_signature_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_node_list_t *directives, rbs_node_list_t *declarations);
|
data/include/rbs/defines.h
CHANGED
|
@@ -32,6 +32,24 @@
|
|
|
32
32
|
#define RBS_ATTRIBUTE_FORMAT(string_index, argument_index)
|
|
33
33
|
#endif
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Support RBS_LIKELY and RBS_UNLIKELY to help the compiler optimize its
|
|
37
|
+
* branch predication.
|
|
38
|
+
*/
|
|
39
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
40
|
+
/** The compiler should predicate that this branch will be taken. */
|
|
41
|
+
#define RBS_LIKELY(x) __builtin_expect(!!(x), 1)
|
|
42
|
+
|
|
43
|
+
/** The compiler should predicate that this branch will not be taken. */
|
|
44
|
+
#define RBS_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
|
45
|
+
#else
|
|
46
|
+
/** Void because this platform does not support branch prediction hints. */
|
|
47
|
+
#define RBS_LIKELY(x) (x)
|
|
48
|
+
|
|
49
|
+
/** Void because this platform does not support branch prediction hints. */
|
|
50
|
+
#define RBS_UNLIKELY(x) (x)
|
|
51
|
+
#endif
|
|
52
|
+
|
|
35
53
|
/**
|
|
36
54
|
* We use -Wimplicit-fallthrough to guard potentially unintended fall-through between cases of a switch.
|
|
37
55
|
* Use RBS_FALLTHROUGH to explicitly annotate cases where the fallthrough is intentional.
|
|
@@ -56,4 +74,13 @@
|
|
|
56
74
|
#define NODISCARD __attribute__((warn_unused_result))
|
|
57
75
|
#endif
|
|
58
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Mark a function or variable as potentially unused to suppress compiler warnings.
|
|
79
|
+
*/
|
|
80
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
81
|
+
#define RBS_ATTRIBUTE_UNUSED __attribute__((unused))
|
|
82
|
+
#else
|
|
83
|
+
#define RBS_ATTRIBUTE_UNUSED
|
|
84
|
+
#endif
|
|
85
|
+
|
|
59
86
|
#endif
|