rbs 3.7.0.dev.1 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/windows.yml +5 -3
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +53 -0
- data/Rakefile +23 -0
- data/config.yml +311 -0
- data/core/dir.rbs +1 -1
- data/core/kernel.rbs +2 -2
- data/core/process.rbs +1 -1
- data/core/set.rbs +1 -1
- data/docs/syntax.md +6 -4
- data/ext/rbs_extension/extconf.rb +10 -0
- data/ext/rbs_extension/parser.c +103 -110
- data/ext/rbs_extension/rbs_extension.h +1 -2
- data/{ext/rbs_extension → include/rbs}/constants.h +21 -19
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +34 -5
- data/lib/rbs/collection/config.rb +2 -2
- data/lib/rbs/environment_loader.rb +5 -0
- data/lib/rbs/prototype/rb.rb +7 -3
- data/lib/rbs/types.rb +10 -3
- data/lib/rbs/version.rb +1 -1
- data/sig/ancestor_graph.rbs +1 -1
- data/sig/collection/config/lockfile_generator.rbs +9 -1
- data/sig/definition.rbs +1 -1
- data/sig/definition_builder.rbs +1 -1
- data/sig/environment.rbs +1 -1
- data/sig/prototype/rb.rbs +1 -1
- data/sig/type_alias_dependency.rbs +2 -2
- data/sig/type_alias_regularity.rbs +1 -1
- data/sig/type_param.rbs +3 -3
- data/sig/vendorer.rbs +1 -1
- data/{ext/rbs_extension → src}/constants.c +35 -36
- data/src/ruby_objs.c +793 -0
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/csv/0/manifest.yaml +1 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
- data/stdlib/json/0/json.rbs +1 -1
- data/stdlib/minitest/0/kernel.rbs +2 -2
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
- data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
- data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/mock.rbs +9 -5
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
- data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
- data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
- data/stdlib/minitest/0/minitest/spec.rbs +1 -1
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +1 -1
- data/stdlib/minitest/0/minitest/test.rbs +7 -14
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit.rbs +1 -2
- data/stdlib/minitest/0/minitest.rbs +41 -892
- data/stdlib/open-uri/0/manifest.yaml +1 -0
- data/stdlib/openssl/0/manifest.yaml +1 -0
- data/stdlib/openssl/0/openssl.rbs +26 -1
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/templates/include/rbs/constants.h.erb +20 -0
- data/templates/include/rbs/ruby_objs.h.erb +10 -0
- data/templates/src/constants.c.erb +36 -0
- data/templates/src/ruby_objs.c.erb +27 -0
- data/templates/template.rb +122 -0
- metadata +19 -9
- data/ext/rbs_extension/ruby_objs.c +0 -602
- data/ext/rbs_extension/ruby_objs.h +0 -51
- data/stdlib/minitest/0/manifest.yaml +0 -2
- /data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +0 -0
data/ext/rbs_extension/parser.c
CHANGED
@@ -143,7 +143,7 @@ void parser_advance_no_gap(parserstate *state) {
|
|
143
143
|
| {(tUIDENT `::`)*} <tXIDENT>
|
144
144
|
| {<tXIDENT>}
|
145
145
|
*/
|
146
|
-
VALUE parse_type_name(parserstate *state, TypeNameKind kind, range *rg) {
|
146
|
+
static VALUE parse_type_name(parserstate *state, TypeNameKind kind, range *rg) {
|
147
147
|
VALUE absolute = Qfalse;
|
148
148
|
VALUE path = EMPTY_ARRAY;
|
149
149
|
VALUE namespace;
|
@@ -757,7 +757,7 @@ static void check_key_duplication(parserstate *state, VALUE fields, VALUE key) {
|
|
757
757
|
record_attribute ::= {} keyword_token `:` <type>
|
758
758
|
| {} literal_type `=>` <type>
|
759
759
|
*/
|
760
|
-
VALUE parse_record_attributes(parserstate *state) {
|
760
|
+
static VALUE parse_record_attributes(parserstate *state) {
|
761
761
|
VALUE fields = rb_hash_new();
|
762
762
|
|
763
763
|
if (state->next_token.type == pRBRACE) {
|
@@ -963,25 +963,25 @@ static VALUE parse_simple(parserstate *state) {
|
|
963
963
|
return type;
|
964
964
|
}
|
965
965
|
case kBOOL:
|
966
|
-
return
|
966
|
+
return rbs_bases_bool(rbs_location_current_token(state));
|
967
967
|
case kBOT:
|
968
|
-
return
|
968
|
+
return rbs_bases_bottom(rbs_location_current_token(state));
|
969
969
|
case kCLASS:
|
970
|
-
return
|
970
|
+
return rbs_bases_class(rbs_location_current_token(state));
|
971
971
|
case kINSTANCE:
|
972
|
-
return
|
972
|
+
return rbs_bases_instance(rbs_location_current_token(state));
|
973
973
|
case kNIL:
|
974
|
-
return
|
974
|
+
return rbs_bases_nil(rbs_location_current_token(state));
|
975
975
|
case kSELF:
|
976
|
-
return
|
976
|
+
return rbs_bases_self(rbs_location_current_token(state));
|
977
977
|
case kTOP:
|
978
|
-
return
|
978
|
+
return rbs_bases_top(rbs_location_current_token(state));
|
979
979
|
case kVOID:
|
980
|
-
return
|
980
|
+
return rbs_bases_void(rbs_location_current_token(state));
|
981
981
|
case kUNTYPED:
|
982
|
-
return
|
982
|
+
return rbs_bases_any(rbs_location_current_token(state));
|
983
983
|
case k__TODO__: {
|
984
|
-
VALUE type =
|
984
|
+
VALUE type = rbs_bases_any(rbs_location_current_token(state));
|
985
985
|
rb_funcall(type, rb_intern("todo!"), 0);
|
986
986
|
return type;
|
987
987
|
}
|
@@ -1123,7 +1123,7 @@ VALUE parse_type(parserstate *state) {
|
|
1123
1123
|
|
1124
1124
|
type_param ::= tUIDENT upper_bound? default_type? (module_type_params == false)
|
1125
1125
|
*/
|
1126
|
-
VALUE parse_type_params(parserstate *state, range *rg, bool module_type_params) {
|
1126
|
+
static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_params) {
|
1127
1127
|
VALUE params = EMPTY_ARRAY;
|
1128
1128
|
|
1129
1129
|
bool required_param_allowed = true;
|
@@ -1219,7 +1219,12 @@ VALUE parse_type_params(parserstate *state, range *rg, bool module_type_params)
|
|
1219
1219
|
rbs_loc_add_optional_child(loc, rb_intern("upper_bound"), upper_bound_range);
|
1220
1220
|
rbs_loc_add_optional_child(loc, rb_intern("default"), default_type_range);
|
1221
1221
|
|
1222
|
-
VALUE param = rbs_ast_type_param(name, variance,
|
1222
|
+
VALUE param = rbs_ast_type_param(name, variance, upper_bound, default_type, location);
|
1223
|
+
|
1224
|
+
if (unchecked) {
|
1225
|
+
rb_funcall(param, rb_intern("unchecked!"), 0);
|
1226
|
+
}
|
1227
|
+
|
1223
1228
|
melt_array(¶ms);
|
1224
1229
|
rb_ary_push(params, param);
|
1225
1230
|
|
@@ -1290,7 +1295,7 @@ VALUE parse_method_type(parserstate *state) {
|
|
1290
1295
|
/*
|
1291
1296
|
global_decl ::= {tGIDENT} `:` <type>
|
1292
1297
|
*/
|
1293
|
-
VALUE parse_global_decl(parserstate *state) {
|
1298
|
+
static VALUE parse_global_decl(parserstate *state) {
|
1294
1299
|
range decl_range;
|
1295
1300
|
range name_range, colon_range;
|
1296
1301
|
|
@@ -1325,7 +1330,7 @@ VALUE parse_global_decl(parserstate *state) {
|
|
1325
1330
|
/*
|
1326
1331
|
const_decl ::= {const_name} `:` <type>
|
1327
1332
|
*/
|
1328
|
-
VALUE parse_const_decl(parserstate *state) {
|
1333
|
+
static VALUE parse_const_decl(parserstate *state) {
|
1329
1334
|
range decl_range;
|
1330
1335
|
range name_range, colon_range;
|
1331
1336
|
|
@@ -1359,7 +1364,7 @@ VALUE parse_const_decl(parserstate *state) {
|
|
1359
1364
|
/*
|
1360
1365
|
type_decl ::= {kTYPE} alias_name `=` <type>
|
1361
1366
|
*/
|
1362
|
-
VALUE parse_type_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
1367
|
+
static VALUE parse_type_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
1363
1368
|
range decl_range;
|
1364
1369
|
range keyword_range, name_range, params_range, eq_range;
|
1365
1370
|
|
@@ -1404,7 +1409,7 @@ VALUE parse_type_decl(parserstate *state, position comment_pos, VALUE annotation
|
|
1404
1409
|
/*
|
1405
1410
|
annotation ::= {<tANNOTATION>}
|
1406
1411
|
*/
|
1407
|
-
VALUE parse_annotation(parserstate *state) {
|
1412
|
+
static VALUE parse_annotation(parserstate *state) {
|
1408
1413
|
VALUE content = rb_funcall(state->buffer, rb_intern("content"), 0);
|
1409
1414
|
rb_encoding *enc = rb_enc_get(content);
|
1410
1415
|
|
@@ -1460,7 +1465,7 @@ VALUE parse_annotation(parserstate *state) {
|
|
1460
1465
|
annotations ::= {} annotation ... <annotation>
|
1461
1466
|
| {<>}
|
1462
1467
|
*/
|
1463
|
-
void parse_annotations(parserstate *state, VALUE *annotations, position *annot_pos) {
|
1468
|
+
static void parse_annotations(parserstate *state, VALUE *annotations, position *annot_pos) {
|
1464
1469
|
*annot_pos = NullPosition;
|
1465
1470
|
|
1466
1471
|
while (true) {
|
@@ -1483,7 +1488,7 @@ void parse_annotations(parserstate *state, VALUE *annotations, position *annot_p
|
|
1483
1488
|
method_name ::= {} <IDENT | keyword>
|
1484
1489
|
| {} (IDENT | keyword)~<`?`>
|
1485
1490
|
*/
|
1486
|
-
VALUE parse_method_name(parserstate *state, range *range) {
|
1491
|
+
static VALUE parse_method_name(parserstate *state, range *range) {
|
1487
1492
|
parser_advance(state);
|
1488
1493
|
|
1489
1494
|
switch (state->current_token.type)
|
@@ -1551,7 +1556,7 @@ typedef enum {
|
|
1551
1556
|
|
1552
1557
|
@param allow_selfq `true` to accept `self?` kind.
|
1553
1558
|
*/
|
1554
|
-
InstanceSingletonKind parse_instance_singleton_kind(parserstate *state, bool allow_selfq, range *rg) {
|
1559
|
+
static InstanceSingletonKind parse_instance_singleton_kind(parserstate *state, bool allow_selfq, range *rg) {
|
1555
1560
|
InstanceSingletonKind kind = INSTANCE_KIND;
|
1556
1561
|
|
1557
1562
|
if (state->next_token.type == kSELF) {
|
@@ -1594,7 +1599,7 @@ InstanceSingletonKind parse_instance_singleton_kind(parserstate *state, bool all
|
|
1594
1599
|
* @param instance_only `true` to reject singleton method definition.
|
1595
1600
|
* @param accept_overload `true` to accept overloading (...) definition.
|
1596
1601
|
* */
|
1597
|
-
VALUE parse_member_def(parserstate *state, bool instance_only, bool accept_overload, position comment_pos, VALUE annotations) {
|
1602
|
+
static VALUE parse_member_def(parserstate *state, bool instance_only, bool accept_overload, position comment_pos, VALUE annotations) {
|
1598
1603
|
range member_range;
|
1599
1604
|
range visibility_range;
|
1600
1605
|
range keyword_range;
|
@@ -1774,31 +1779,29 @@ void class_instance_name(parserstate *state, TypeNameKind kind, VALUE *name, VAL
|
|
1774
1779
|
*
|
1775
1780
|
* @param from_interface `true` when the member is in an interface.
|
1776
1781
|
* */
|
1777
|
-
VALUE parse_mixin_member(parserstate *state, bool from_interface, position comment_pos, VALUE annotations) {
|
1782
|
+
static VALUE parse_mixin_member(parserstate *state, bool from_interface, position comment_pos, VALUE annotations) {
|
1778
1783
|
range member_range;
|
1779
1784
|
range name_range;
|
1780
1785
|
range keyword_range;
|
1781
1786
|
range args_range = NULL_RANGE;
|
1782
1787
|
bool reset_typevar_scope;
|
1788
|
+
enum TokenType type;
|
1783
1789
|
|
1784
1790
|
member_range.start = state->current_token.range.start;
|
1785
1791
|
comment_pos = nonnull_pos_or(comment_pos, member_range.start);
|
1786
1792
|
|
1793
|
+
type = state->current_token.type;
|
1787
1794
|
keyword_range = state->current_token.range;
|
1788
1795
|
|
1789
|
-
|
1790
|
-
switch (state->current_token.type)
|
1796
|
+
switch (type)
|
1791
1797
|
{
|
1792
1798
|
case kINCLUDE:
|
1793
|
-
klass = RBS_AST_Members_Include;
|
1794
1799
|
reset_typevar_scope = false;
|
1795
1800
|
break;
|
1796
1801
|
case kEXTEND:
|
1797
|
-
klass = RBS_AST_Members_Extend;
|
1798
1802
|
reset_typevar_scope = true;
|
1799
1803
|
break;
|
1800
1804
|
case kPREPEND:
|
1801
|
-
klass = RBS_AST_Members_Prepend;
|
1802
1805
|
reset_typevar_scope = false;
|
1803
1806
|
break;
|
1804
1807
|
default:
|
@@ -1836,14 +1839,18 @@ VALUE parse_mixin_member(parserstate *state, bool from_interface, position comme
|
|
1836
1839
|
rbs_loc_add_required_child(loc, rb_intern("keyword"), keyword_range);
|
1837
1840
|
rbs_loc_add_optional_child(loc, rb_intern("args"), args_range);
|
1838
1841
|
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
annotations,
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1842
|
+
VALUE comment = get_comment(state, comment_pos.line);
|
1843
|
+
switch (type)
|
1844
|
+
{
|
1845
|
+
case kINCLUDE:
|
1846
|
+
return rbs_ast_members_include(name, args, annotations, location, comment);
|
1847
|
+
case kEXTEND:
|
1848
|
+
return rbs_ast_members_extend(name, args, annotations, location, comment);
|
1849
|
+
case kPREPEND:
|
1850
|
+
return rbs_ast_members_prepend(name, args, annotations, location, comment);
|
1851
|
+
default:
|
1852
|
+
rbs_abort();
|
1853
|
+
}
|
1847
1854
|
}
|
1848
1855
|
|
1849
1856
|
/**
|
@@ -1854,7 +1861,7 @@ VALUE parse_mixin_member(parserstate *state, bool from_interface, position comme
|
|
1854
1861
|
*
|
1855
1862
|
* @param[in] instance_only `true` to reject `self.` alias.
|
1856
1863
|
* */
|
1857
|
-
VALUE parse_alias_member(parserstate *state, bool instance_only, position comment_pos, VALUE annotations) {
|
1864
|
+
static VALUE parse_alias_member(parserstate *state, bool instance_only, position comment_pos, VALUE annotations) {
|
1858
1865
|
range member_range;
|
1859
1866
|
range keyword_range, new_name_range, old_name_range;
|
1860
1867
|
range new_kind_range, old_kind_range;
|
@@ -1917,10 +1924,11 @@ VALUE parse_alias_member(parserstate *state, bool instance_only, position commen
|
|
1917
1924
|
| {kSELF} `.` tAIDENT `:` <type>
|
1918
1925
|
| {tA2IDENT} `:` <type>
|
1919
1926
|
*/
|
1920
|
-
VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE annotations) {
|
1927
|
+
static VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE annotations) {
|
1921
1928
|
range member_range;
|
1922
1929
|
range name_range, colon_range;
|
1923
1930
|
range kind_range = NULL_RANGE;
|
1931
|
+
rbs_loc *loc;
|
1924
1932
|
|
1925
1933
|
if (rb_array_len(annotations) > 0) {
|
1926
1934
|
raise_syntax_error(
|
@@ -1934,7 +1942,6 @@ VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE anno
|
|
1934
1942
|
comment_pos = nonnull_pos_or(comment_pos, member_range.start);
|
1935
1943
|
VALUE comment = get_comment(state, comment_pos.line);
|
1936
1944
|
|
1937
|
-
VALUE klass;
|
1938
1945
|
VALUE location;
|
1939
1946
|
VALUE name;
|
1940
1947
|
VALUE type;
|
@@ -1942,8 +1949,6 @@ VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE anno
|
|
1942
1949
|
switch (state->current_token.type)
|
1943
1950
|
{
|
1944
1951
|
case tAIDENT:
|
1945
|
-
klass = RBS_AST_Members_InstanceVariable;
|
1946
|
-
|
1947
1952
|
name_range = state->current_token.range;
|
1948
1953
|
name = ID2SYM(INTERN_TOKEN(state, state->current_token));
|
1949
1954
|
|
@@ -1953,11 +1958,16 @@ VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE anno
|
|
1953
1958
|
type = parse_type(state);
|
1954
1959
|
member_range.end = state->current_token.range.end;
|
1955
1960
|
|
1956
|
-
|
1961
|
+
location = rbs_new_location(state->buffer, member_range);
|
1962
|
+
loc = rbs_check_location(location);
|
1963
|
+
rbs_loc_alloc_children(loc, 3);
|
1964
|
+
rbs_loc_add_required_child(loc, rb_intern("name"), name_range);
|
1965
|
+
rbs_loc_add_required_child(loc, rb_intern("colon"), colon_range);
|
1966
|
+
rbs_loc_add_optional_child(loc, rb_intern("kind"), kind_range);
|
1957
1967
|
|
1958
|
-
|
1959
|
-
klass = RBS_AST_Members_ClassVariable;
|
1968
|
+
return rbs_ast_members_instance_variable(name, type, location, comment);
|
1960
1969
|
|
1970
|
+
case tA2IDENT:
|
1961
1971
|
name_range = state->current_token.range;
|
1962
1972
|
name = ID2SYM(INTERN_TOKEN(state, state->current_token));
|
1963
1973
|
|
@@ -1969,11 +1979,16 @@ VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE anno
|
|
1969
1979
|
parser_pop_typevar_table(state);
|
1970
1980
|
member_range.end = state->current_token.range.end;
|
1971
1981
|
|
1972
|
-
|
1982
|
+
location = rbs_new_location(state->buffer, member_range);
|
1983
|
+
loc = rbs_check_location(location);
|
1984
|
+
rbs_loc_alloc_children(loc, 3);
|
1985
|
+
rbs_loc_add_required_child(loc, rb_intern("name"), name_range);
|
1986
|
+
rbs_loc_add_required_child(loc, rb_intern("colon"), colon_range);
|
1987
|
+
rbs_loc_add_optional_child(loc, rb_intern("kind"), kind_range);
|
1973
1988
|
|
1974
|
-
|
1975
|
-
klass = RBS_AST_Members_ClassInstanceVariable;
|
1989
|
+
return rbs_ast_members_class_variable(name, type, location, comment);
|
1976
1990
|
|
1991
|
+
case kSELF:
|
1977
1992
|
kind_range.start = state->current_token.range.start;
|
1978
1993
|
kind_range.end = state->next_token.range.end;
|
1979
1994
|
|
@@ -1991,27 +2006,25 @@ VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE anno
|
|
1991
2006
|
parser_pop_typevar_table(state);
|
1992
2007
|
member_range.end = state->current_token.range.end;
|
1993
2008
|
|
1994
|
-
|
2009
|
+
location = rbs_new_location(state->buffer, member_range);
|
2010
|
+
loc = rbs_check_location(location);
|
2011
|
+
rbs_loc_alloc_children(loc, 3);
|
2012
|
+
rbs_loc_add_required_child(loc, rb_intern("name"), name_range);
|
2013
|
+
rbs_loc_add_required_child(loc, rb_intern("colon"), colon_range);
|
2014
|
+
rbs_loc_add_optional_child(loc, rb_intern("kind"), kind_range);
|
2015
|
+
|
2016
|
+
return rbs_ast_members_class_instance_variable(name, type, location, comment);
|
1995
2017
|
|
1996
2018
|
default:
|
1997
2019
|
rbs_abort();
|
1998
2020
|
}
|
1999
|
-
|
2000
|
-
location = rbs_new_location(state->buffer, member_range);
|
2001
|
-
rbs_loc *loc = rbs_check_location(location);
|
2002
|
-
rbs_loc_alloc_children(loc, 3);
|
2003
|
-
rbs_loc_add_required_child(loc, rb_intern("name"), name_range);
|
2004
|
-
rbs_loc_add_required_child(loc, rb_intern("colon"), colon_range);
|
2005
|
-
rbs_loc_add_optional_child(loc, rb_intern("kind"), kind_range);
|
2006
|
-
|
2007
|
-
return rbs_ast_members_variable(klass, name, type, location, comment);
|
2008
2021
|
}
|
2009
2022
|
|
2010
2023
|
/*
|
2011
2024
|
visibility_member ::= {<`public`>}
|
2012
2025
|
| {<`private`>}
|
2013
2026
|
*/
|
2014
|
-
VALUE parse_visibility_member(parserstate *state, VALUE annotations) {
|
2027
|
+
static VALUE parse_visibility_member(parserstate *state, VALUE annotations) {
|
2015
2028
|
if (rb_array_len(annotations) > 0) {
|
2016
2029
|
raise_syntax_error(
|
2017
2030
|
state,
|
@@ -2020,24 +2033,17 @@ VALUE parse_visibility_member(parserstate *state, VALUE annotations) {
|
|
2020
2033
|
);
|
2021
2034
|
}
|
2022
2035
|
|
2023
|
-
VALUE
|
2036
|
+
VALUE location = rbs_new_location(state->buffer, state->current_token.range);
|
2024
2037
|
|
2025
2038
|
switch (state->current_token.type)
|
2026
2039
|
{
|
2027
2040
|
case kPUBLIC:
|
2028
|
-
|
2029
|
-
break;
|
2041
|
+
return rbs_ast_members_public(location);
|
2030
2042
|
case kPRIVATE:
|
2031
|
-
|
2032
|
-
break;
|
2043
|
+
return rbs_ast_members_private(location);
|
2033
2044
|
default:
|
2034
2045
|
rbs_abort();
|
2035
2046
|
}
|
2036
|
-
|
2037
|
-
return rbs_ast_members_visibility(
|
2038
|
-
klass,
|
2039
|
-
rbs_new_location(state->buffer, state->current_token.range)
|
2040
|
-
);
|
2041
2047
|
}
|
2042
2048
|
|
2043
2049
|
/*
|
@@ -2054,13 +2060,12 @@ VALUE parse_visibility_member(parserstate *state, VALUE annotations) {
|
|
2054
2060
|
| `(` tAIDENT `)` # Ivar name
|
2055
2061
|
| `(` `)` # No variable
|
2056
2062
|
*/
|
2057
|
-
VALUE parse_attribute_member(parserstate *state, position comment_pos, VALUE annotations) {
|
2063
|
+
static VALUE parse_attribute_member(parserstate *state, position comment_pos, VALUE annotations) {
|
2058
2064
|
range member_range;
|
2059
2065
|
range keyword_range, name_range, colon_range;
|
2060
2066
|
range kind_range = NULL_RANGE, ivar_range = NULL_RANGE, ivar_name_range = NULL_RANGE, visibility_range = NULL_RANGE;
|
2061
2067
|
|
2062
2068
|
InstanceSingletonKind is_kind;
|
2063
|
-
VALUE klass;
|
2064
2069
|
VALUE kind;
|
2065
2070
|
VALUE attr_name;
|
2066
2071
|
VALUE ivar_name;
|
@@ -2069,6 +2074,7 @@ VALUE parse_attribute_member(parserstate *state, position comment_pos, VALUE ann
|
|
2069
2074
|
VALUE location;
|
2070
2075
|
VALUE visibility;
|
2071
2076
|
rbs_loc *loc;
|
2077
|
+
enum TokenType attr_type;
|
2072
2078
|
|
2073
2079
|
member_range.start = state->current_token.range.start;
|
2074
2080
|
comment_pos = nonnull_pos_or(comment_pos, member_range.start);
|
@@ -2092,21 +2098,8 @@ VALUE parse_attribute_member(parserstate *state, position comment_pos, VALUE ann
|
|
2092
2098
|
break;
|
2093
2099
|
}
|
2094
2100
|
|
2101
|
+
attr_type = state->current_token.type;
|
2095
2102
|
keyword_range = state->current_token.range;
|
2096
|
-
switch (state->current_token.type)
|
2097
|
-
{
|
2098
|
-
case kATTRREADER:
|
2099
|
-
klass = RBS_AST_Members_AttrReader;
|
2100
|
-
break;
|
2101
|
-
case kATTRWRITER:
|
2102
|
-
klass = RBS_AST_Members_AttrWriter;
|
2103
|
-
break;
|
2104
|
-
case kATTRACCESSOR:
|
2105
|
-
klass = RBS_AST_Members_AttrAccessor;
|
2106
|
-
break;
|
2107
|
-
default:
|
2108
|
-
rbs_abort();
|
2109
|
-
}
|
2110
2103
|
|
2111
2104
|
is_kind = parse_instance_singleton_kind(state, false, &kind_range);
|
2112
2105
|
if (is_kind == INSTANCE_KIND) {
|
@@ -2153,17 +2146,17 @@ VALUE parse_attribute_member(parserstate *state, position comment_pos, VALUE ann
|
|
2153
2146
|
rbs_loc_add_optional_child(loc, rb_intern("ivar_name"), ivar_name_range);
|
2154
2147
|
rbs_loc_add_optional_child(loc, rb_intern("visibility"), visibility_range);
|
2155
2148
|
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
type,
|
2160
|
-
|
2161
|
-
kind,
|
2162
|
-
|
2163
|
-
location,
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2149
|
+
switch (attr_type)
|
2150
|
+
{
|
2151
|
+
case kATTRREADER:
|
2152
|
+
return rbs_ast_members_attr_reader(attr_name, type, ivar_name, kind, annotations, location, comment, visibility);
|
2153
|
+
case kATTRWRITER:
|
2154
|
+
return rbs_ast_members_attr_writer(attr_name, type, ivar_name, kind, annotations, location, comment, visibility);
|
2155
|
+
case kATTRACCESSOR:
|
2156
|
+
return rbs_ast_members_attr_accessor(attr_name, type, ivar_name, kind, annotations, location, comment, visibility);
|
2157
|
+
default:
|
2158
|
+
rbs_abort();
|
2159
|
+
}
|
2167
2160
|
}
|
2168
2161
|
|
2169
2162
|
/*
|
@@ -2173,7 +2166,7 @@ VALUE parse_attribute_member(parserstate *state, position comment_pos, VALUE ann
|
|
2173
2166
|
| mixin_member (interface only)
|
2174
2167
|
| alias_member (instance only)
|
2175
2168
|
*/
|
2176
|
-
VALUE parse_interface_members(parserstate *state) {
|
2169
|
+
static VALUE parse_interface_members(parserstate *state) {
|
2177
2170
|
VALUE members = EMPTY_ARRAY;
|
2178
2171
|
|
2179
2172
|
while (state->next_token.type != kEND) {
|
@@ -2218,7 +2211,7 @@ VALUE parse_interface_members(parserstate *state) {
|
|
2218
2211
|
/*
|
2219
2212
|
interface_decl ::= {`interface`} interface_name module_type_params interface_members <kEND>
|
2220
2213
|
*/
|
2221
|
-
VALUE parse_interface_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
2214
|
+
static VALUE parse_interface_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
2222
2215
|
range member_range;
|
2223
2216
|
range name_range, keyword_range, end_range;
|
2224
2217
|
range type_params_range = NULL_RANGE;
|
@@ -2265,7 +2258,7 @@ VALUE parse_interface_decl(parserstate *state, position comment_pos, VALUE annot
|
|
2265
2258
|
module_self_type ::= <module_name>
|
2266
2259
|
| module_name `[` type_list <`]`>
|
2267
2260
|
*/
|
2268
|
-
void parse_module_self_types(parserstate *state, VALUE *array) {
|
2261
|
+
static void parse_module_self_types(parserstate *state, VALUE *array) {
|
2269
2262
|
while (true) {
|
2270
2263
|
range self_range;
|
2271
2264
|
range name_range;
|
@@ -2305,7 +2298,7 @@ void parse_module_self_types(parserstate *state, VALUE *array) {
|
|
2305
2298
|
}
|
2306
2299
|
}
|
2307
2300
|
|
2308
|
-
VALUE parse_nested_decl(parserstate *state, const char *nested_in, position annot_pos, VALUE annotations);
|
2301
|
+
static VALUE parse_nested_decl(parserstate *state, const char *nested_in, position annot_pos, VALUE annotations);
|
2309
2302
|
|
2310
2303
|
/*
|
2311
2304
|
module_members ::= {} ...<module_member> kEND
|
@@ -2318,7 +2311,7 @@ VALUE parse_nested_decl(parserstate *state, const char *nested_in, position anno
|
|
2318
2311
|
| `public`
|
2319
2312
|
| `private`
|
2320
2313
|
*/
|
2321
|
-
VALUE parse_module_members(parserstate *state) {
|
2314
|
+
static VALUE parse_module_members(parserstate *state) {
|
2322
2315
|
VALUE members = EMPTY_ARRAY;
|
2323
2316
|
|
2324
2317
|
while (state->next_token.type != kEND) {
|
@@ -2395,7 +2388,7 @@ VALUE parse_module_members(parserstate *state) {
|
|
2395
2388
|
module_decl ::= {module_name} module_type_params module_members <kEND>
|
2396
2389
|
| {module_name} module_name module_type_params `:` module_self_types module_members <kEND>
|
2397
2390
|
*/
|
2398
|
-
VALUE parse_module_decl0(parserstate *state, range keyword_range, VALUE module_name, range name_range, VALUE comment, VALUE annotations) {
|
2391
|
+
static VALUE parse_module_decl0(parserstate *state, range keyword_range, VALUE module_name, range name_range, VALUE comment, VALUE annotations) {
|
2399
2392
|
range decl_range;
|
2400
2393
|
range end_range;
|
2401
2394
|
range type_params_range;
|
@@ -2454,7 +2447,7 @@ VALUE parse_module_decl0(parserstate *state, range keyword_range, VALUE module_n
|
|
2454
2447
|
| {`module`} module_name module_decl0 <kEND>
|
2455
2448
|
|
2456
2449
|
*/
|
2457
|
-
VALUE parse_module_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
2450
|
+
static VALUE parse_module_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
2458
2451
|
range keyword_range = state->current_token.range;
|
2459
2452
|
range module_name_range;
|
2460
2453
|
|
@@ -2494,7 +2487,7 @@ VALUE parse_module_decl(parserstate *state, position comment_pos, VALUE annotati
|
|
2494
2487
|
class_decl_super ::= {} `<` <class_instance_name>
|
2495
2488
|
| {<>}
|
2496
2489
|
*/
|
2497
|
-
VALUE parse_class_decl_super(parserstate *state, range *lt_range) {
|
2490
|
+
static VALUE parse_class_decl_super(parserstate *state, range *lt_range) {
|
2498
2491
|
if (parser_advance_if(state, pLT)) {
|
2499
2492
|
range super_range;
|
2500
2493
|
range name_range;
|
@@ -2529,7 +2522,7 @@ VALUE parse_class_decl_super(parserstate *state, range *lt_range) {
|
|
2529
2522
|
/*
|
2530
2523
|
class_decl ::= {class_name} type_params class_decl_super class_members <`end`>
|
2531
2524
|
*/
|
2532
|
-
VALUE parse_class_decl0(parserstate *state, range keyword_range, VALUE name, range name_range, VALUE comment, VALUE annotations) {
|
2525
|
+
static VALUE parse_class_decl0(parserstate *state, range keyword_range, VALUE name, range name_range, VALUE comment, VALUE annotations) {
|
2533
2526
|
range decl_range;
|
2534
2527
|
range end_range;
|
2535
2528
|
range type_params_range;
|
@@ -2580,7 +2573,7 @@ VALUE parse_class_decl0(parserstate *state, range keyword_range, VALUE name, ran
|
|
2580
2573
|
class_decl ::= {`class`} class_name `=` <class_name>
|
2581
2574
|
| {`class`} class_name <class_decl0>
|
2582
2575
|
*/
|
2583
|
-
VALUE parse_class_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
2576
|
+
static VALUE parse_class_decl(parserstate *state, position comment_pos, VALUE annotations) {
|
2584
2577
|
range keyword_range = state->current_token.range;
|
2585
2578
|
range class_name_range;
|
2586
2579
|
|
@@ -2623,7 +2616,7 @@ VALUE parse_class_decl(parserstate *state, position comment_pos, VALUE annotatio
|
|
2623
2616
|
| {<module_decl>}
|
2624
2617
|
| {<class_decl>}
|
2625
2618
|
*/
|
2626
|
-
VALUE parse_nested_decl(parserstate *state, const char *nested_in, position annot_pos, VALUE annotations) {
|
2619
|
+
static VALUE parse_nested_decl(parserstate *state, const char *nested_in, position annot_pos, VALUE annotations) {
|
2627
2620
|
VALUE decl;
|
2628
2621
|
|
2629
2622
|
parser_push_typevar_table(state, true);
|
@@ -2661,7 +2654,7 @@ VALUE parse_nested_decl(parserstate *state, const char *nested_in, position anno
|
|
2661
2654
|
return decl;
|
2662
2655
|
}
|
2663
2656
|
|
2664
|
-
VALUE parse_decl(parserstate *state) {
|
2657
|
+
static VALUE parse_decl(parserstate *state) {
|
2665
2658
|
VALUE annotations = EMPTY_ARRAY;
|
2666
2659
|
position annot_pos = NullPosition;
|
2667
2660
|
|
@@ -2695,7 +2688,7 @@ VALUE parse_decl(parserstate *state) {
|
|
2695
2688
|
namespace ::= {} (`::`)? (`tUIDENT` `::`)* `tUIDENT` <`::`>
|
2696
2689
|
| {} <> (empty -- returns empty namespace)
|
2697
2690
|
*/
|
2698
|
-
VALUE parse_namespace(parserstate *state, range *rg) {
|
2691
|
+
static VALUE parse_namespace(parserstate *state, range *rg) {
|
2699
2692
|
bool is_absolute = false;
|
2700
2693
|
|
2701
2694
|
if (state->next_token.type == pCOLON2) {
|
@@ -2733,7 +2726,7 @@ VALUE parse_namespace(parserstate *state, range *rg) {
|
|
2733
2726
|
| {} namespace tUIDENT `as` <tUIDENT>
|
2734
2727
|
| {} namespace <tSTAR>
|
2735
2728
|
*/
|
2736
|
-
void parse_use_clauses(parserstate *state, VALUE clauses) {
|
2729
|
+
static void parse_use_clauses(parserstate *state, VALUE clauses) {
|
2737
2730
|
while (true) {
|
2738
2731
|
range namespace_range = NULL_RANGE;
|
2739
2732
|
VALUE namespace = parse_namespace(state, &namespace_range);
|
@@ -2826,7 +2819,7 @@ void parse_use_clauses(parserstate *state, VALUE clauses) {
|
|
2826
2819
|
/*
|
2827
2820
|
use_directive ::= {} `use` <clauses>
|
2828
2821
|
*/
|
2829
|
-
VALUE parse_use_directive(parserstate *state) {
|
2822
|
+
static VALUE parse_use_directive(parserstate *state) {
|
2830
2823
|
if (state->next_token.type == kUSE) {
|
2831
2824
|
parser_advance(state);
|
2832
2825
|
|
@@ -4,10 +4,9 @@
|
|
4
4
|
#include "ruby/re.h"
|
5
5
|
#include "ruby/encoding.h"
|
6
6
|
|
7
|
+
#include "rbs.h"
|
7
8
|
#include "lexer.h"
|
8
9
|
#include "parser.h"
|
9
|
-
#include "constants.h"
|
10
|
-
#include "ruby_objs.h"
|
11
10
|
|
12
11
|
/**
|
13
12
|
* Receives `parserstate` and `range`, which represents a string token or symbol token, and returns a string VALUE.
|
@@ -1,31 +1,38 @@
|
|
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/include/rbs/constants.h.erb */
|
6
|
+
/*----------------------------------------------------------------------------*/
|
7
|
+
|
1
8
|
#ifndef RBS__CONSTANTS_H
|
2
9
|
#define RBS__CONSTANTS_H
|
3
10
|
|
4
11
|
extern VALUE RBS;
|
5
12
|
|
6
13
|
extern VALUE RBS_AST;
|
14
|
+
extern VALUE RBS_AST_Declarations;
|
15
|
+
extern VALUE RBS_AST_Directives;
|
16
|
+
extern VALUE RBS_AST_Members;
|
17
|
+
extern VALUE RBS_Types;
|
18
|
+
extern VALUE RBS_Types_Bases;
|
19
|
+
extern VALUE RBS_ParsingError;
|
20
|
+
|
7
21
|
extern VALUE RBS_AST_Annotation;
|
8
22
|
extern VALUE RBS_AST_Comment;
|
9
|
-
extern VALUE RBS_AST_TypeParam;
|
10
|
-
|
11
|
-
extern VALUE RBS_AST_Declarations;
|
12
|
-
extern VALUE RBS_AST_Declarations_TypeAlias;
|
13
|
-
extern VALUE RBS_AST_Declarations_Class_Super;
|
14
23
|
extern VALUE RBS_AST_Declarations_Class;
|
24
|
+
extern VALUE RBS_AST_Declarations_Class_Super;
|
25
|
+
extern VALUE RBS_AST_Declarations_ClassAlias;
|
15
26
|
extern VALUE RBS_AST_Declarations_Constant;
|
16
27
|
extern VALUE RBS_AST_Declarations_Global;
|
17
28
|
extern VALUE RBS_AST_Declarations_Interface;
|
18
|
-
extern VALUE RBS_AST_Declarations_Module_Self;
|
19
29
|
extern VALUE RBS_AST_Declarations_Module;
|
30
|
+
extern VALUE RBS_AST_Declarations_Module_Self;
|
20
31
|
extern VALUE RBS_AST_Declarations_ModuleAlias;
|
21
|
-
extern VALUE
|
22
|
-
|
23
|
-
extern VALUE RBS_AST_Directives;
|
32
|
+
extern VALUE RBS_AST_Declarations_TypeAlias;
|
24
33
|
extern VALUE RBS_AST_Directives_Use;
|
25
34
|
extern VALUE RBS_AST_Directives_Use_SingleClause;
|
26
35
|
extern VALUE RBS_AST_Directives_Use_WildcardClause;
|
27
|
-
|
28
|
-
extern VALUE RBS_AST_Members;
|
29
36
|
extern VALUE RBS_AST_Members_Alias;
|
30
37
|
extern VALUE RBS_AST_Members_AttrAccessor;
|
31
38
|
extern VALUE RBS_AST_Members_AttrReader;
|
@@ -40,16 +47,11 @@ extern VALUE RBS_AST_Members_MethodDefinition_Overload;
|
|
40
47
|
extern VALUE RBS_AST_Members_Prepend;
|
41
48
|
extern VALUE RBS_AST_Members_Private;
|
42
49
|
extern VALUE RBS_AST_Members_Public;
|
43
|
-
|
50
|
+
extern VALUE RBS_AST_TypeParam;
|
44
51
|
extern VALUE RBS_MethodType;
|
45
52
|
extern VALUE RBS_Namespace;
|
46
|
-
|
47
|
-
extern VALUE RBS_ParsingError;
|
48
53
|
extern VALUE RBS_TypeName;
|
49
|
-
|
50
|
-
extern VALUE RBS_Types;
|
51
54
|
extern VALUE RBS_Types_Alias;
|
52
|
-
extern VALUE RBS_Types_Bases;
|
53
55
|
extern VALUE RBS_Types_Bases_Any;
|
54
56
|
extern VALUE RBS_Types_Bases_Bool;
|
55
57
|
extern VALUE RBS_Types_Bases_Bottom;
|
@@ -62,9 +64,8 @@ extern VALUE RBS_Types_Bases_Void;
|
|
62
64
|
extern VALUE RBS_Types_Block;
|
63
65
|
extern VALUE RBS_Types_ClassInstance;
|
64
66
|
extern VALUE RBS_Types_ClassSingleton;
|
65
|
-
extern VALUE RBS_Types_Function_Param;
|
66
67
|
extern VALUE RBS_Types_Function;
|
67
|
-
extern VALUE
|
68
|
+
extern VALUE RBS_Types_Function_Param;
|
68
69
|
extern VALUE RBS_Types_Interface;
|
69
70
|
extern VALUE RBS_Types_Intersection;
|
70
71
|
extern VALUE RBS_Types_Literal;
|
@@ -73,6 +74,7 @@ extern VALUE RBS_Types_Proc;
|
|
73
74
|
extern VALUE RBS_Types_Record;
|
74
75
|
extern VALUE RBS_Types_Tuple;
|
75
76
|
extern VALUE RBS_Types_Union;
|
77
|
+
extern VALUE RBS_Types_UntypedFunction;
|
76
78
|
extern VALUE RBS_Types_Variable;
|
77
79
|
|
78
80
|
void rbs__init_constants();
|