rbs 3.8.1 → 3.9.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.
- checksums.yaml +4 -4
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +26 -0
- data/.github/workflows/typecheck.yml +2 -0
- data/.github/workflows/windows.yml +15 -0
- data/.rubocop.yml +13 -1
- data/CHANGELOG.md +67 -0
- data/Rakefile +16 -3
- data/config.yml +6 -0
- data/core/data.rbs +1 -1
- data/core/enumerator.rbs +14 -2
- data/core/exception.rbs +1 -1
- data/core/gc.rbs +1 -1
- data/core/hash.rbs +2 -2
- data/core/io.rbs +7 -3
- data/core/kernel.rbs +4 -4
- data/core/method.rbs +2 -2
- data/core/module.rbs +4 -4
- data/core/object.rbs +1 -1
- data/core/proc.rbs +2 -2
- data/core/rbs/unnamed/argf.rbs +3 -3
- data/core/rubygems/version.rbs +2 -2
- data/core/string.rbs +3 -3
- data/core/unbound_method.rbs +1 -1
- data/docs/syntax.md +10 -5
- data/ext/rbs_extension/extconf.rb +2 -1
- data/ext/rbs_extension/location.c +32 -10
- data/ext/rbs_extension/location.h +4 -3
- data/ext/rbs_extension/main.c +22 -1
- data/ext/rbs_extension/parser.c +171 -150
- data/ext/rbs_extension/parserstate.c +54 -9
- data/ext/rbs_extension/parserstate.h +6 -4
- data/include/rbs/ruby_objs.h +6 -6
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/lib/rbs/ast/declarations.rb +9 -4
- data/lib/rbs/ast/directives.rb +10 -0
- data/lib/rbs/ast/members.rb +2 -0
- data/lib/rbs/ast/type_param.rb +2 -12
- data/lib/rbs/cli/validate.rb +1 -0
- data/lib/rbs/cli.rb +3 -3
- data/lib/rbs/collection/config/lockfile_generator.rb +28 -7
- data/lib/rbs/collection/sources/rubygems.rb +1 -1
- data/lib/rbs/definition.rb +46 -31
- data/lib/rbs/definition_builder/ancestor_builder.rb +2 -0
- data/lib/rbs/definition_builder.rb +86 -30
- data/lib/rbs/environment.rb +33 -18
- data/lib/rbs/errors.rb +24 -0
- data/lib/rbs/locator.rb +2 -0
- data/lib/rbs/method_type.rb +2 -0
- data/lib/rbs/parser_aux.rb +38 -1
- data/lib/rbs/prototype/rb.rb +2 -1
- data/lib/rbs/prototype/rbi.rb +2 -1
- data/lib/rbs/prototype/runtime.rb +3 -0
- data/lib/rbs/subtractor.rb +3 -3
- data/lib/rbs/test/hook.rb +2 -2
- data/lib/rbs/test/type_check.rb +7 -5
- data/lib/rbs/types.rb +45 -10
- data/lib/rbs/unit_test/spy.rb +4 -2
- data/lib/rbs/unit_test/type_assertions.rb +17 -11
- data/lib/rbs/unit_test/with_aliases.rb +3 -1
- data/lib/rbs/validator.rb +4 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +10 -5
- data/lib/rbs.rb +1 -0
- data/rbs.gemspec +1 -1
- data/sig/annotate/rdoc_source.rbs +2 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile_generator.rbs +1 -1
- data/sig/declarations.rbs +10 -3
- data/sig/definition.rbs +67 -14
- data/sig/definition_builder.rbs +17 -3
- data/sig/directives.rbs +17 -1
- data/sig/environment.rbs +2 -0
- data/sig/errors.rbs +19 -0
- data/sig/namespace.rbs +1 -1
- data/sig/parser.rbs +5 -1
- data/sig/subtractor.rbs +1 -1
- data/sig/test/type_check.rbs +2 -2
- data/sig/type_param.rbs +1 -1
- data/sig/typename.rbs +1 -1
- data/sig/types.rbs +1 -1
- data/sig/unit_test/spy.rbs +2 -0
- data/sig/unit_test/type_assertions.rbs +2 -0
- data/sig/validator.rbs +4 -0
- data/sig/writer.rbs +1 -1
- data/src/ruby_objs.c +12 -6
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/cgi/0/core.rbs +10 -0
- data/stdlib/ipaddr/0/ipaddr.rbs +8 -0
- data/stdlib/json/0/json.rbs +52 -50
- data/stdlib/net-http/0/net-http.rbs +3 -3
- data/stdlib/openssl/0/openssl.rbs +73 -73
- data/stdlib/resolv/0/resolv.rbs +8 -8
- data/stdlib/socket/0/addrinfo.rbs +1 -1
- data/stdlib/socket/0/unix_socket.rbs +4 -2
- data/stdlib/stringio/0/stringio.rbs +1 -1
- data/stdlib/uri/0/common.rbs +17 -0
- metadata +4 -7
- data/templates/include/rbs/constants.h.erb +0 -20
- data/templates/include/rbs/ruby_objs.h.erb +0 -10
- data/templates/src/constants.c.erb +0 -36
- data/templates/src/ruby_objs.c.erb +0 -27
- data/templates/template.rb +0 -122
data/ext/rbs_extension/parser.c
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
#include "rbs_extension.h"
|
2
|
+
#include "rbs/util/rbs_constant_pool.h"
|
3
|
+
|
4
|
+
#define INTERN(str) \
|
5
|
+
rbs_constant_pool_insert_constant( \
|
6
|
+
RBS_GLOBAL_CONSTANT_POOL, \
|
7
|
+
(const uint8_t *) str, \
|
8
|
+
strlen(str) \
|
9
|
+
)
|
2
10
|
|
3
11
|
#define INTERN_TOKEN(parserstate, tok) \
|
4
12
|
rb_intern3(\
|
@@ -53,6 +61,7 @@ typedef struct {
|
|
53
61
|
} method_params;
|
54
62
|
|
55
63
|
static VALUE EMPTY_ARRAY;
|
64
|
+
static VALUE EMPTY_HASH;
|
56
65
|
|
57
66
|
static inline void melt_array(VALUE *array) {
|
58
67
|
if (*array == EMPTY_ARRAY) {
|
@@ -60,6 +69,12 @@ static inline void melt_array(VALUE *array) {
|
|
60
69
|
}
|
61
70
|
}
|
62
71
|
|
72
|
+
static inline void melt_hash(VALUE *hash) {
|
73
|
+
if (*hash == EMPTY_HASH) {
|
74
|
+
*hash = rb_hash_new();
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
63
78
|
static bool rbs_is_untyped_params(method_params *params) {
|
64
79
|
return NIL_P(params->required_positionals);
|
65
80
|
}
|
@@ -277,7 +292,7 @@ static VALUE parse_function_param(parserstate *state) {
|
|
277
292
|
VALUE location = rbs_new_location(state->buffer, param_range);
|
278
293
|
rbs_loc *loc = rbs_check_location(location);
|
279
294
|
rbs_loc_alloc_children(loc, 1);
|
280
|
-
rbs_loc_add_optional_child(loc,
|
295
|
+
rbs_loc_add_optional_child(loc, INTERN("name"), NULL_RANGE);
|
281
296
|
|
282
297
|
return rbs_function_param(type, Qnil, location);
|
283
298
|
} else {
|
@@ -302,7 +317,7 @@ static VALUE parse_function_param(parserstate *state) {
|
|
302
317
|
VALUE location = rbs_new_location(state->buffer, param_range);
|
303
318
|
rbs_loc *loc = rbs_check_location(location);
|
304
319
|
rbs_loc_alloc_children(loc, 1);
|
305
|
-
rbs_loc_add_optional_child(loc,
|
320
|
+
rbs_loc_add_optional_child(loc, INTERN("name"), name_range);
|
306
321
|
|
307
322
|
return rbs_function_param(type, name, location);
|
308
323
|
}
|
@@ -335,7 +350,7 @@ static VALUE parse_keyword_key(parserstate *state) {
|
|
335
350
|
/*
|
336
351
|
keyword ::= {} keyword `:` <function_param>
|
337
352
|
*/
|
338
|
-
static void parse_keyword(parserstate *state, VALUE keywords, VALUE memo) {
|
353
|
+
static void parse_keyword(parserstate *state, VALUE *keywords, VALUE memo) {
|
339
354
|
VALUE key = parse_keyword_key(state);
|
340
355
|
|
341
356
|
if (!NIL_P(rb_hash_aref(memo, key))) {
|
@@ -351,7 +366,8 @@ static void parse_keyword(parserstate *state, VALUE keywords, VALUE memo) {
|
|
351
366
|
parser_advance_assert(state, pCOLON);
|
352
367
|
VALUE param = parse_function_param(state);
|
353
368
|
|
354
|
-
|
369
|
+
melt_hash(keywords);
|
370
|
+
rb_hash_aset(*keywords, key, param);
|
355
371
|
|
356
372
|
return;
|
357
373
|
}
|
@@ -458,7 +474,7 @@ PARSE_OPTIONAL_PARAMS:
|
|
458
474
|
parser_advance(state);
|
459
475
|
|
460
476
|
if (is_keyword(state)) {
|
461
|
-
parse_keyword(state, params->optional_keywords, memo);
|
477
|
+
parse_keyword(state, ¶ms->optional_keywords, memo);
|
462
478
|
parser_advance_if(state, pCOMMA);
|
463
479
|
goto PARSE_KEYWORDS;
|
464
480
|
}
|
@@ -525,7 +541,7 @@ PARSE_KEYWORDS:
|
|
525
541
|
case pQUESTION:
|
526
542
|
parser_advance(state);
|
527
543
|
if (is_keyword(state)) {
|
528
|
-
parse_keyword(state, params->optional_keywords, memo);
|
544
|
+
parse_keyword(state, ¶ms->optional_keywords, memo);
|
529
545
|
} else {
|
530
546
|
raise_syntax_error(
|
531
547
|
state,
|
@@ -548,7 +564,7 @@ PARSE_KEYWORDS:
|
|
548
564
|
case tBANGIDENT:
|
549
565
|
KEYWORD_CASES
|
550
566
|
if (is_keyword(state)) {
|
551
|
-
parse_keyword(state, params->required_keywords, memo);
|
567
|
+
parse_keyword(state, ¶ms->required_keywords, memo);
|
552
568
|
} else {
|
553
569
|
raise_syntax_error(
|
554
570
|
state,
|
@@ -605,8 +621,8 @@ static void initialize_method_params(method_params *params){
|
|
605
621
|
.optional_positionals = EMPTY_ARRAY,
|
606
622
|
.rest_positionals = Qnil,
|
607
623
|
.trailing_positionals = EMPTY_ARRAY,
|
608
|
-
.required_keywords =
|
609
|
-
.optional_keywords =
|
624
|
+
.required_keywords = EMPTY_HASH,
|
625
|
+
.optional_keywords = EMPTY_HASH,
|
610
626
|
.rest_keywords = Qnil,
|
611
627
|
};
|
612
628
|
}
|
@@ -645,16 +661,16 @@ static void parse_function(parserstate *state, VALUE *function, VALUE *block, VA
|
|
645
661
|
parser_advance_assert(state, pRPAREN);
|
646
662
|
}
|
647
663
|
|
648
|
-
// Untyped method parameter means it cannot have block
|
649
|
-
if (rbs_is_untyped_params(¶ms)) {
|
650
|
-
if (state->next_token.type != pARROW) {
|
651
|
-
raise_syntax_error(state, state->next_token2, "A method type with untyped method parameter cannot have block");
|
652
|
-
}
|
653
|
-
}
|
654
|
-
|
655
664
|
// Passing NULL to function_self_type means the function itself doesn't accept self type binding. (== method type)
|
656
665
|
if (function_self_type) {
|
657
666
|
*function_self_type = parse_self_type_binding(state);
|
667
|
+
} else {
|
668
|
+
// Parsing method type. untyped_params means it cannot have a block
|
669
|
+
if (rbs_is_untyped_params(¶ms)) {
|
670
|
+
if (state->next_token.type != pARROW) {
|
671
|
+
raise_syntax_error(state, state->next_token2, "A method type with untyped method parameter cannot have block");
|
672
|
+
}
|
673
|
+
}
|
658
674
|
}
|
659
675
|
|
660
676
|
VALUE required = Qtrue;
|
@@ -902,8 +918,8 @@ static VALUE parse_instance_type(parserstate *state, bool parse_alias) {
|
|
902
918
|
VALUE location = rbs_new_location(state->buffer, type_range);
|
903
919
|
rbs_loc *loc = rbs_check_location(location);
|
904
920
|
rbs_loc_alloc_children(loc, 2);
|
905
|
-
rbs_loc_add_required_child(loc,
|
906
|
-
rbs_loc_add_optional_child(loc,
|
921
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
922
|
+
rbs_loc_add_optional_child(loc, INTERN("args"), args_range);
|
907
923
|
|
908
924
|
if (kind == CLASS_NAME) {
|
909
925
|
return rbs_class_instance(typename, types, location);
|
@@ -936,7 +952,7 @@ static VALUE parse_singleton_type(parserstate *state) {
|
|
936
952
|
VALUE location = rbs_new_location(state->buffer, type_range);
|
937
953
|
rbs_loc *loc = rbs_check_location(location);
|
938
954
|
rbs_loc_alloc_children(loc, 1);
|
939
|
-
rbs_loc_add_required_child(loc,
|
955
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
940
956
|
|
941
957
|
return rbs_class_singleton(typename, location);
|
942
958
|
}
|
@@ -985,12 +1001,10 @@ static VALUE parse_simple(parserstate *state) {
|
|
985
1001
|
return rbs_bases_void(rbs_location_current_token(state));
|
986
1002
|
}
|
987
1003
|
case kUNTYPED: {
|
988
|
-
return rbs_bases_any(rbs_location_current_token(state));
|
1004
|
+
return rbs_bases_any(false, rbs_location_current_token(state));
|
989
1005
|
}
|
990
1006
|
case k__TODO__: {
|
991
|
-
|
992
|
-
rb_funcall(type, rb_intern("todo!"), 0);
|
993
|
-
return type;
|
1007
|
+
return rbs_bases_any(true, rbs_location_current_token(state));
|
994
1008
|
}
|
995
1009
|
case tINTEGER: {
|
996
1010
|
VALUE literal = rb_funcall(
|
@@ -1023,8 +1037,13 @@ static VALUE parse_simple(parserstate *state) {
|
|
1023
1037
|
return parse_symbol(state);
|
1024
1038
|
}
|
1025
1039
|
case tUIDENT: {
|
1026
|
-
|
1040
|
+
const char *name_str = peek_token(state->lexstate, state->current_token);
|
1041
|
+
size_t name_len = token_bytes(state->current_token);
|
1042
|
+
|
1043
|
+
rbs_constant_id_t name = rbs_constant_pool_find(&state->constant_pool, (const uint8_t *) name_str, name_len);
|
1044
|
+
|
1027
1045
|
if (parser_typevar_member(state, name)) {
|
1046
|
+
ID name = rb_intern3(name_str, name_len, rb_enc_get(state->lexstate->string));
|
1028
1047
|
return rbs_variable(ID2SYM(name), rbs_location_current_token(state));
|
1029
1048
|
}
|
1030
1049
|
// fallthrough for type name
|
@@ -1077,26 +1096,24 @@ static VALUE parse_simple(parserstate *state) {
|
|
1077
1096
|
| {} <optional>
|
1078
1097
|
*/
|
1079
1098
|
static VALUE parse_intersection(parserstate *state) {
|
1080
|
-
range
|
1081
|
-
rg.start = state->next_token.range.start;
|
1082
|
-
|
1099
|
+
position start = state->next_token.range.start;
|
1083
1100
|
VALUE type = parse_optional(state);
|
1084
|
-
|
1101
|
+
if (state->next_token.type != pAMP) {
|
1102
|
+
return type;
|
1103
|
+
}
|
1085
1104
|
|
1105
|
+
VALUE intersection_types = rb_ary_new();
|
1086
1106
|
rb_ary_push(intersection_types, type);
|
1087
1107
|
while (state->next_token.type == pAMP) {
|
1088
1108
|
parser_advance(state);
|
1089
1109
|
rb_ary_push(intersection_types, parse_optional(state));
|
1090
1110
|
}
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
}
|
1098
|
-
|
1099
|
-
return type;
|
1111
|
+
range rg = (range) {
|
1112
|
+
.start = start,
|
1113
|
+
.end = state->current_token.range.end,
|
1114
|
+
};
|
1115
|
+
VALUE location = rbs_new_location(state->buffer, rg);
|
1116
|
+
return rbs_intersection(intersection_types, location);
|
1100
1117
|
}
|
1101
1118
|
|
1102
1119
|
/*
|
@@ -1104,26 +1121,24 @@ static VALUE parse_intersection(parserstate *state) {
|
|
1104
1121
|
| {} <intersection>
|
1105
1122
|
*/
|
1106
1123
|
VALUE parse_type(parserstate *state) {
|
1107
|
-
range
|
1108
|
-
rg.start = state->next_token.range.start;
|
1109
|
-
|
1124
|
+
position start = state->next_token.range.start;
|
1110
1125
|
VALUE type = parse_intersection(state);
|
1111
|
-
|
1126
|
+
if (state->next_token.type != pBAR) {
|
1127
|
+
return type;
|
1128
|
+
}
|
1112
1129
|
|
1130
|
+
VALUE union_types = rb_ary_new();
|
1113
1131
|
rb_ary_push(union_types, type);
|
1114
1132
|
while (state->next_token.type == pBAR) {
|
1115
1133
|
parser_advance(state);
|
1116
1134
|
rb_ary_push(union_types, parse_intersection(state));
|
1117
1135
|
}
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
}
|
1125
|
-
|
1126
|
-
return type;
|
1136
|
+
range rg = (range) {
|
1137
|
+
.start = start,
|
1138
|
+
.end = state->current_token.range.end,
|
1139
|
+
};
|
1140
|
+
VALUE location = rbs_new_location(state->buffer, rg);
|
1141
|
+
return rbs_union(union_types, location);
|
1127
1142
|
}
|
1128
1143
|
|
1129
1144
|
/*
|
@@ -1145,7 +1160,7 @@ static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_p
|
|
1145
1160
|
rg->start = state->current_token.range.start;
|
1146
1161
|
|
1147
1162
|
while (true) {
|
1148
|
-
|
1163
|
+
VALUE unchecked = Qfalse;
|
1149
1164
|
VALUE variance = ID2SYM(rb_intern("invariant"));
|
1150
1165
|
VALUE upper_bound = Qnil;
|
1151
1166
|
VALUE default_type = Qnil;
|
@@ -1157,7 +1172,7 @@ static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_p
|
|
1157
1172
|
range unchecked_range = NULL_RANGE;
|
1158
1173
|
if (module_type_params) {
|
1159
1174
|
if (state->next_token.type == kUNCHECKED) {
|
1160
|
-
unchecked =
|
1175
|
+
unchecked = Qtrue;
|
1161
1176
|
parser_advance(state);
|
1162
1177
|
unchecked_range = state->current_token.range;
|
1163
1178
|
}
|
@@ -1182,8 +1197,13 @@ static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_p
|
|
1182
1197
|
parser_advance_assert(state, tUIDENT);
|
1183
1198
|
range name_range = state->current_token.range;
|
1184
1199
|
|
1185
|
-
|
1186
|
-
|
1200
|
+
rbs_constant_id_t id = rbs_constant_pool_insert_shared(
|
1201
|
+
&state->constant_pool,
|
1202
|
+
(const uint8_t *) peek_token(state->lexstate, state->current_token),
|
1203
|
+
token_bytes(state->current_token)
|
1204
|
+
);
|
1205
|
+
|
1206
|
+
VALUE name = ID2SYM(INTERN_TOKEN(state, state->current_token));
|
1187
1207
|
|
1188
1208
|
parser_insert_typevar(state, id);
|
1189
1209
|
|
@@ -1221,17 +1241,13 @@ static VALUE parse_type_params(parserstate *state, range *rg, bool module_type_p
|
|
1221
1241
|
VALUE location = rbs_new_location(state->buffer, param_range);
|
1222
1242
|
rbs_loc *loc = rbs_check_location(location);
|
1223
1243
|
rbs_loc_alloc_children(loc, 5);
|
1224
|
-
rbs_loc_add_required_child(loc,
|
1225
|
-
rbs_loc_add_optional_child(loc,
|
1226
|
-
rbs_loc_add_optional_child(loc,
|
1227
|
-
rbs_loc_add_optional_child(loc,
|
1228
|
-
rbs_loc_add_optional_child(loc,
|
1244
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1245
|
+
rbs_loc_add_optional_child(loc, INTERN("variance"), variance_range);
|
1246
|
+
rbs_loc_add_optional_child(loc, INTERN("unchecked"), unchecked_range);
|
1247
|
+
rbs_loc_add_optional_child(loc, INTERN("upper_bound"), upper_bound_range);
|
1248
|
+
rbs_loc_add_optional_child(loc, INTERN("default"), default_type_range);
|
1229
1249
|
|
1230
|
-
VALUE param = rbs_ast_type_param(name, variance, upper_bound, default_type, location);
|
1231
|
-
|
1232
|
-
if (unchecked) {
|
1233
|
-
rb_funcall(param, rb_intern("unchecked!"), 0);
|
1234
|
-
}
|
1250
|
+
VALUE param = rbs_ast_type_param(name, variance, upper_bound, default_type, unchecked, location);
|
1235
1251
|
|
1236
1252
|
melt_array(¶ms);
|
1237
1253
|
rb_ary_push(params, param);
|
@@ -1288,8 +1304,8 @@ VALUE parse_method_type(parserstate *state) {
|
|
1288
1304
|
VALUE location = rbs_new_location(state->buffer, rg);
|
1289
1305
|
rbs_loc *loc = rbs_check_location(location);
|
1290
1306
|
rbs_loc_alloc_children(loc, 2);
|
1291
|
-
rbs_loc_add_required_child(loc,
|
1292
|
-
rbs_loc_add_optional_child(loc,
|
1307
|
+
rbs_loc_add_required_child(loc, INTERN("type"), type_range);
|
1308
|
+
rbs_loc_add_optional_child(loc, INTERN("type_params"), params_range);
|
1293
1309
|
|
1294
1310
|
return rbs_method_type(
|
1295
1311
|
type_params,
|
@@ -1302,7 +1318,7 @@ VALUE parse_method_type(parserstate *state) {
|
|
1302
1318
|
/*
|
1303
1319
|
global_decl ::= {tGIDENT} `:` <type>
|
1304
1320
|
*/
|
1305
|
-
static VALUE parse_global_decl(parserstate *state) {
|
1321
|
+
static VALUE parse_global_decl(parserstate *state, VALUE annotations) {
|
1306
1322
|
range decl_range;
|
1307
1323
|
decl_range.start = state->current_token.range.start;
|
1308
1324
|
|
@@ -1319,16 +1335,16 @@ static VALUE parse_global_decl(parserstate *state) {
|
|
1319
1335
|
VALUE location = rbs_new_location(state->buffer, decl_range);
|
1320
1336
|
rbs_loc *loc = rbs_check_location(location);
|
1321
1337
|
rbs_loc_alloc_children(loc, 2);
|
1322
|
-
rbs_loc_add_required_child(loc,
|
1323
|
-
rbs_loc_add_required_child(loc,
|
1338
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1339
|
+
rbs_loc_add_required_child(loc, INTERN("colon"), colon_range);
|
1324
1340
|
|
1325
|
-
return rbs_ast_decl_global(typename, type, location, comment);
|
1341
|
+
return rbs_ast_decl_global(typename, type, location, comment, annotations);
|
1326
1342
|
}
|
1327
1343
|
|
1328
1344
|
/*
|
1329
1345
|
const_decl ::= {const_name} `:` <type>
|
1330
1346
|
*/
|
1331
|
-
static VALUE parse_const_decl(parserstate *state) {
|
1347
|
+
static VALUE parse_const_decl(parserstate *state, VALUE annotations) {
|
1332
1348
|
range decl_range;
|
1333
1349
|
|
1334
1350
|
decl_range.start = state->current_token.range.start;
|
@@ -1346,10 +1362,10 @@ static VALUE parse_const_decl(parserstate *state) {
|
|
1346
1362
|
VALUE location = rbs_new_location(state->buffer, decl_range);
|
1347
1363
|
rbs_loc *loc = rbs_check_location(location);
|
1348
1364
|
rbs_loc_alloc_children(loc, 2);
|
1349
|
-
rbs_loc_add_required_child(loc,
|
1350
|
-
rbs_loc_add_required_child(loc,
|
1365
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1366
|
+
rbs_loc_add_required_child(loc, INTERN("colon"), colon_range);
|
1351
1367
|
|
1352
|
-
return rbs_ast_decl_constant(typename, type, location, comment);
|
1368
|
+
return rbs_ast_decl_constant(typename, type, location, comment, annotations);
|
1353
1369
|
}
|
1354
1370
|
|
1355
1371
|
/*
|
@@ -1381,10 +1397,10 @@ static VALUE parse_type_decl(parserstate *state, position comment_pos, VALUE ann
|
|
1381
1397
|
VALUE location = rbs_new_location(state->buffer, decl_range);
|
1382
1398
|
rbs_loc *loc = rbs_check_location(location);
|
1383
1399
|
rbs_loc_alloc_children(loc, 4);
|
1384
|
-
rbs_loc_add_required_child(loc,
|
1385
|
-
rbs_loc_add_required_child(loc,
|
1386
|
-
rbs_loc_add_optional_child(loc,
|
1387
|
-
rbs_loc_add_required_child(loc,
|
1400
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
1401
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1402
|
+
rbs_loc_add_optional_child(loc, INTERN("type_params"), params_range);
|
1403
|
+
rbs_loc_add_required_child(loc, INTERN("eq"), eq_range);
|
1388
1404
|
|
1389
1405
|
parser_pop_typevar_table(state);
|
1390
1406
|
|
@@ -1726,11 +1742,11 @@ static VALUE parse_member_def(parserstate *state, bool instance_only, bool accep
|
|
1726
1742
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
1727
1743
|
rbs_loc *loc = rbs_check_location(location);
|
1728
1744
|
rbs_loc_alloc_children(loc, 5);
|
1729
|
-
rbs_loc_add_required_child(loc,
|
1730
|
-
rbs_loc_add_required_child(loc,
|
1731
|
-
rbs_loc_add_optional_child(loc,
|
1732
|
-
rbs_loc_add_optional_child(loc,
|
1733
|
-
rbs_loc_add_optional_child(loc,
|
1745
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
1746
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1747
|
+
rbs_loc_add_optional_child(loc, INTERN("kind"), kind_range);
|
1748
|
+
rbs_loc_add_optional_child(loc, INTERN("overloading"), overloading_range);
|
1749
|
+
rbs_loc_add_optional_child(loc, INTERN("visibility"), visibility_range);
|
1734
1750
|
|
1735
1751
|
return rbs_ast_members_method_definition(
|
1736
1752
|
name,
|
@@ -1826,9 +1842,9 @@ static VALUE parse_mixin_member(parserstate *state, bool from_interface, positio
|
|
1826
1842
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
1827
1843
|
rbs_loc *loc = rbs_check_location(location);
|
1828
1844
|
rbs_loc_alloc_children(loc, 3);
|
1829
|
-
rbs_loc_add_required_child(loc,
|
1830
|
-
rbs_loc_add_required_child(loc,
|
1831
|
-
rbs_loc_add_optional_child(loc,
|
1845
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1846
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
1847
|
+
rbs_loc_add_optional_child(loc, INTERN("args"), args_range);
|
1832
1848
|
|
1833
1849
|
VALUE comment = get_comment(state, comment_pos.line);
|
1834
1850
|
switch (type)
|
@@ -1889,11 +1905,11 @@ static VALUE parse_alias_member(parserstate *state, bool instance_only, position
|
|
1889
1905
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
1890
1906
|
rbs_loc *loc = rbs_check_location(location);
|
1891
1907
|
rbs_loc_alloc_children(loc, 5);
|
1892
|
-
rbs_loc_add_required_child(loc,
|
1893
|
-
rbs_loc_add_required_child(loc,
|
1894
|
-
rbs_loc_add_required_child(loc,
|
1895
|
-
rbs_loc_add_optional_child(loc,
|
1896
|
-
rbs_loc_add_optional_child(loc,
|
1908
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
1909
|
+
rbs_loc_add_required_child(loc, INTERN("new_name"), new_name_range);
|
1910
|
+
rbs_loc_add_required_child(loc, INTERN("old_name"), old_name_range);
|
1911
|
+
rbs_loc_add_optional_child(loc, INTERN("new_kind"), new_kind_range);
|
1912
|
+
rbs_loc_add_optional_child(loc, INTERN("old_kind"), old_kind_range);
|
1897
1913
|
|
1898
1914
|
return rbs_ast_members_alias(
|
1899
1915
|
new_name,
|
@@ -1939,9 +1955,9 @@ static VALUE parse_variable_member(parserstate *state, position comment_pos, VAL
|
|
1939
1955
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
1940
1956
|
rbs_loc *loc = rbs_check_location(location);
|
1941
1957
|
rbs_loc_alloc_children(loc, 3);
|
1942
|
-
rbs_loc_add_required_child(loc,
|
1943
|
-
rbs_loc_add_required_child(loc,
|
1944
|
-
rbs_loc_add_optional_child(loc,
|
1958
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1959
|
+
rbs_loc_add_required_child(loc, INTERN("colon"), colon_range);
|
1960
|
+
rbs_loc_add_optional_child(loc, INTERN("kind"), NULL_RANGE);
|
1945
1961
|
|
1946
1962
|
return rbs_ast_members_instance_variable(name, type, location, comment);
|
1947
1963
|
}
|
@@ -1960,9 +1976,9 @@ static VALUE parse_variable_member(parserstate *state, position comment_pos, VAL
|
|
1960
1976
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
1961
1977
|
rbs_loc *loc = rbs_check_location(location);
|
1962
1978
|
rbs_loc_alloc_children(loc, 3);
|
1963
|
-
rbs_loc_add_required_child(loc,
|
1964
|
-
rbs_loc_add_required_child(loc,
|
1965
|
-
rbs_loc_add_optional_child(loc,
|
1979
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
1980
|
+
rbs_loc_add_required_child(loc, INTERN("colon"), colon_range);
|
1981
|
+
rbs_loc_add_optional_child(loc, INTERN("kind"), NULL_RANGE);
|
1966
1982
|
|
1967
1983
|
return rbs_ast_members_class_variable(name, type, location, comment);
|
1968
1984
|
}
|
@@ -1989,9 +2005,9 @@ static VALUE parse_variable_member(parserstate *state, position comment_pos, VAL
|
|
1989
2005
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
1990
2006
|
rbs_loc *loc = rbs_check_location(location);
|
1991
2007
|
rbs_loc_alloc_children(loc, 3);
|
1992
|
-
rbs_loc_add_required_child(loc,
|
1993
|
-
rbs_loc_add_required_child(loc,
|
1994
|
-
rbs_loc_add_optional_child(loc,
|
2008
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
2009
|
+
rbs_loc_add_required_child(loc, INTERN("colon"), colon_range);
|
2010
|
+
rbs_loc_add_optional_child(loc, INTERN("kind"), kind_range);
|
1995
2011
|
|
1996
2012
|
return rbs_ast_members_class_instance_variable(name, type, location, comment);
|
1997
2013
|
}
|
@@ -2109,13 +2125,13 @@ static VALUE parse_attribute_member(parserstate *state, position comment_pos, VA
|
|
2109
2125
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
2110
2126
|
rbs_loc *loc = rbs_check_location(location);
|
2111
2127
|
rbs_loc_alloc_children(loc, 7);
|
2112
|
-
rbs_loc_add_required_child(loc,
|
2113
|
-
rbs_loc_add_required_child(loc,
|
2114
|
-
rbs_loc_add_required_child(loc,
|
2115
|
-
rbs_loc_add_optional_child(loc,
|
2116
|
-
rbs_loc_add_optional_child(loc,
|
2117
|
-
rbs_loc_add_optional_child(loc,
|
2118
|
-
rbs_loc_add_optional_child(loc,
|
2128
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
2129
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
2130
|
+
rbs_loc_add_required_child(loc, INTERN("colon"), colon_range);
|
2131
|
+
rbs_loc_add_optional_child(loc, INTERN("kind"), kind_range);
|
2132
|
+
rbs_loc_add_optional_child(loc, INTERN("ivar"), ivar_range);
|
2133
|
+
rbs_loc_add_optional_child(loc, INTERN("ivar_name"), ivar_name_range);
|
2134
|
+
rbs_loc_add_optional_child(loc, INTERN("visibility"), visibility_range);
|
2119
2135
|
|
2120
2136
|
switch (attr_type)
|
2121
2137
|
{
|
@@ -2211,10 +2227,10 @@ static VALUE parse_interface_decl(parserstate *state, position comment_pos, VALU
|
|
2211
2227
|
VALUE location = rbs_new_location(state->buffer, member_range);
|
2212
2228
|
rbs_loc *loc = rbs_check_location(location);
|
2213
2229
|
rbs_loc_alloc_children(loc, 4);
|
2214
|
-
rbs_loc_add_required_child(loc,
|
2215
|
-
rbs_loc_add_required_child(loc,
|
2216
|
-
rbs_loc_add_required_child(loc,
|
2217
|
-
rbs_loc_add_optional_child(loc,
|
2230
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
2231
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
2232
|
+
rbs_loc_add_required_child(loc, INTERN("end"), end_range);
|
2233
|
+
rbs_loc_add_optional_child(loc, INTERN("type_params"), type_params_range);
|
2218
2234
|
|
2219
2235
|
return rbs_ast_decl_interface(
|
2220
2236
|
name,
|
@@ -2255,8 +2271,8 @@ static void parse_module_self_types(parserstate *state, VALUE *array) {
|
|
2255
2271
|
VALUE location = rbs_new_location(state->buffer, self_range);
|
2256
2272
|
rbs_loc *loc = rbs_check_location(location);
|
2257
2273
|
rbs_loc_alloc_children(loc, 2);
|
2258
|
-
rbs_loc_add_required_child(loc,
|
2259
|
-
rbs_loc_add_optional_child(loc,
|
2274
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
2275
|
+
rbs_loc_add_optional_child(loc, INTERN("args"), args_range);
|
2260
2276
|
|
2261
2277
|
VALUE self_type = rbs_ast_decl_module_self(module_name, args, location);
|
2262
2278
|
melt_array(array);
|
@@ -2397,12 +2413,12 @@ static VALUE parse_module_decl0(parserstate *state, range keyword_range, VALUE m
|
|
2397
2413
|
VALUE location = rbs_new_location(state->buffer, decl_range);
|
2398
2414
|
rbs_loc *loc = rbs_check_location(location);
|
2399
2415
|
rbs_loc_alloc_children(loc, 6);
|
2400
|
-
rbs_loc_add_required_child(loc,
|
2401
|
-
rbs_loc_add_required_child(loc,
|
2402
|
-
rbs_loc_add_required_child(loc,
|
2403
|
-
rbs_loc_add_optional_child(loc,
|
2404
|
-
rbs_loc_add_optional_child(loc,
|
2405
|
-
rbs_loc_add_optional_child(loc,
|
2416
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
2417
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
2418
|
+
rbs_loc_add_required_child(loc, INTERN("end"), end_range);
|
2419
|
+
rbs_loc_add_optional_child(loc, INTERN("type_params"), type_params_range);
|
2420
|
+
rbs_loc_add_optional_child(loc, INTERN("colon"), colon_range);
|
2421
|
+
rbs_loc_add_optional_child(loc, INTERN("self_types"), self_types_range);
|
2406
2422
|
|
2407
2423
|
parser_pop_typevar_table(state);
|
2408
2424
|
|
@@ -2448,12 +2464,12 @@ static VALUE parse_module_decl(parserstate *state, position comment_pos, VALUE a
|
|
2448
2464
|
VALUE location = rbs_new_location(state->buffer, decl_range);
|
2449
2465
|
rbs_loc *loc = rbs_check_location(location);
|
2450
2466
|
rbs_loc_alloc_children(loc, 4);
|
2451
|
-
rbs_loc_add_required_child(loc,
|
2452
|
-
rbs_loc_add_required_child(loc,
|
2453
|
-
rbs_loc_add_required_child(loc,
|
2454
|
-
rbs_loc_add_optional_child(loc,
|
2467
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
2468
|
+
rbs_loc_add_required_child(loc, INTERN("new_name"), module_name_range);
|
2469
|
+
rbs_loc_add_required_child(loc, INTERN("eq"), eq_range);
|
2470
|
+
rbs_loc_add_optional_child(loc, INTERN("old_name"), old_name_range);
|
2455
2471
|
|
2456
|
-
return rbs_ast_decl_module_alias(module_name, old_name, location, comment);
|
2472
|
+
return rbs_ast_decl_module_alias(module_name, old_name, location, comment, annotations);
|
2457
2473
|
} else {
|
2458
2474
|
return parse_module_decl0(state, keyword_range, module_name, module_name_range, comment, annotations);
|
2459
2475
|
}
|
@@ -2480,8 +2496,8 @@ static VALUE parse_class_decl_super(parserstate *state, range *lt_range) {
|
|
2480
2496
|
VALUE location = rbs_new_location(state->buffer, super_range);
|
2481
2497
|
rbs_loc *loc = rbs_check_location(location);
|
2482
2498
|
rbs_loc_alloc_children(loc, 2);
|
2483
|
-
rbs_loc_add_required_child(loc,
|
2484
|
-
rbs_loc_add_optional_child(loc,
|
2499
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
2500
|
+
rbs_loc_add_optional_child(loc, INTERN("args"), args_range);
|
2485
2501
|
|
2486
2502
|
return rbs_ast_decl_class_super(name, args, location);
|
2487
2503
|
} else {
|
@@ -2518,11 +2534,11 @@ static VALUE parse_class_decl0(parserstate *state, range keyword_range, VALUE na
|
|
2518
2534
|
VALUE location = rbs_new_location(state->buffer, decl_range);
|
2519
2535
|
rbs_loc *loc = rbs_check_location(location);
|
2520
2536
|
rbs_loc_alloc_children(loc, 5);
|
2521
|
-
rbs_loc_add_required_child(loc,
|
2522
|
-
rbs_loc_add_required_child(loc,
|
2523
|
-
rbs_loc_add_required_child(loc,
|
2524
|
-
rbs_loc_add_optional_child(loc,
|
2525
|
-
rbs_loc_add_optional_child(loc,
|
2537
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
2538
|
+
rbs_loc_add_required_child(loc, INTERN("name"), name_range);
|
2539
|
+
rbs_loc_add_required_child(loc, INTERN("end"), end_range);
|
2540
|
+
rbs_loc_add_optional_child(loc, INTERN("type_params"), type_params_range);
|
2541
|
+
rbs_loc_add_optional_child(loc, INTERN("lt"), lt_range);
|
2526
2542
|
|
2527
2543
|
return rbs_ast_decl_class(
|
2528
2544
|
name,
|
@@ -2565,12 +2581,12 @@ static VALUE parse_class_decl(parserstate *state, position comment_pos, VALUE an
|
|
2565
2581
|
VALUE location = rbs_new_location(state->buffer, decl_range);
|
2566
2582
|
rbs_loc *loc = rbs_check_location(location);
|
2567
2583
|
rbs_loc_alloc_children(loc, 4);
|
2568
|
-
rbs_loc_add_required_child(loc,
|
2569
|
-
rbs_loc_add_required_child(loc,
|
2570
|
-
rbs_loc_add_required_child(loc,
|
2571
|
-
rbs_loc_add_optional_child(loc,
|
2584
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
2585
|
+
rbs_loc_add_required_child(loc, INTERN("new_name"), class_name_range);
|
2586
|
+
rbs_loc_add_required_child(loc, INTERN("eq"), eq_range);
|
2587
|
+
rbs_loc_add_optional_child(loc, INTERN("old_name"), old_name_range);
|
2572
2588
|
|
2573
|
-
return rbs_ast_decl_class_alias(class_name, old_name, location, comment);
|
2589
|
+
return rbs_ast_decl_class_alias(class_name, old_name, location, comment, annotations);
|
2574
2590
|
} else {
|
2575
2591
|
return parse_class_decl0(state, keyword_range, class_name, class_name_range, comment, annotations);
|
2576
2592
|
}
|
@@ -2590,11 +2606,11 @@ static VALUE parse_nested_decl(parserstate *state, const char *nested_in, positi
|
|
2590
2606
|
switch (state->current_token.type) {
|
2591
2607
|
case tUIDENT:
|
2592
2608
|
case pCOLON2: {
|
2593
|
-
decl = parse_const_decl(state);
|
2609
|
+
decl = parse_const_decl(state, annotations);
|
2594
2610
|
break;
|
2595
2611
|
}
|
2596
2612
|
case tGIDENT: {
|
2597
|
-
decl = parse_global_decl(state);
|
2613
|
+
decl = parse_global_decl(state, annotations);
|
2598
2614
|
break;
|
2599
2615
|
}
|
2600
2616
|
case kTYPE: {
|
@@ -2636,10 +2652,10 @@ static VALUE parse_decl(parserstate *state) {
|
|
2636
2652
|
switch (state->current_token.type) {
|
2637
2653
|
case tUIDENT:
|
2638
2654
|
case pCOLON2: {
|
2639
|
-
return parse_const_decl(state);
|
2655
|
+
return parse_const_decl(state, annotations);
|
2640
2656
|
}
|
2641
2657
|
case tGIDENT: {
|
2642
|
-
return parse_global_decl(state);
|
2658
|
+
return parse_global_decl(state, annotations);
|
2643
2659
|
}
|
2644
2660
|
case kTYPE: {
|
2645
2661
|
return parse_type_decl(state, annot_pos, annotations);
|
@@ -2747,9 +2763,9 @@ static void parse_use_clauses(parserstate *state, VALUE clauses) {
|
|
2747
2763
|
VALUE location = rbs_new_location(state->buffer, clause_range);
|
2748
2764
|
rbs_loc *loc = rbs_check_location(location);
|
2749
2765
|
rbs_loc_alloc_children(loc, 3);
|
2750
|
-
rbs_loc_add_required_child(loc,
|
2751
|
-
rbs_loc_add_optional_child(loc,
|
2752
|
-
rbs_loc_add_optional_child(loc,
|
2766
|
+
rbs_loc_add_required_child(loc, INTERN("type_name"), type_name_range);
|
2767
|
+
rbs_loc_add_optional_child(loc, INTERN("keyword"), keyword_range);
|
2768
|
+
rbs_loc_add_optional_child(loc, INTERN("new_name"), new_name_range);
|
2753
2769
|
|
2754
2770
|
rb_ary_push(clauses, rbs_ast_directives_use_single_clause(type_name, new_name, location));
|
2755
2771
|
|
@@ -2766,8 +2782,8 @@ static void parse_use_clauses(parserstate *state, VALUE clauses) {
|
|
2766
2782
|
VALUE location = rbs_new_location(state->buffer, clause_range);
|
2767
2783
|
rbs_loc *loc = rbs_check_location(location);
|
2768
2784
|
rbs_loc_alloc_children(loc, 2);
|
2769
|
-
rbs_loc_add_required_child(loc,
|
2770
|
-
rbs_loc_add_required_child(loc,
|
2785
|
+
rbs_loc_add_required_child(loc, INTERN("namespace"), namespace_range);
|
2786
|
+
rbs_loc_add_required_child(loc, INTERN("star"), star_range);
|
2771
2787
|
|
2772
2788
|
rb_ary_push(clauses, rbs_ast_directives_use_wildcard_clause(namespace, location));
|
2773
2789
|
|
@@ -2809,7 +2825,7 @@ static VALUE parse_use_directive(parserstate *state) {
|
|
2809
2825
|
VALUE location = rbs_new_location(state->buffer, directive_range);
|
2810
2826
|
rbs_loc *loc = rbs_check_location(location);
|
2811
2827
|
rbs_loc_alloc_children(loc, 1);
|
2812
|
-
rbs_loc_add_required_child(loc,
|
2828
|
+
rbs_loc_add_required_child(loc, INTERN("keyword"), keyword_range);
|
2813
2829
|
|
2814
2830
|
return rbs_ast_directives_use(clauses, location);
|
2815
2831
|
} else {
|
@@ -2917,12 +2933,12 @@ parse_signature_try(VALUE a) {
|
|
2917
2933
|
}
|
2918
2934
|
|
2919
2935
|
static VALUE
|
2920
|
-
rbsparser_parse_signature(VALUE self, VALUE buffer, VALUE end_pos)
|
2936
|
+
rbsparser_parse_signature(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos)
|
2921
2937
|
{
|
2922
2938
|
VALUE string = rb_funcall(buffer, rb_intern("content"), 0);
|
2923
2939
|
StringValue(string);
|
2924
|
-
lexstate *lexer = alloc_lexer(string,
|
2925
|
-
parserstate *parser = alloc_parser(buffer, lexer,
|
2940
|
+
lexstate *lexer = alloc_lexer(string, FIX2INT(start_pos), FIX2INT(end_pos));
|
2941
|
+
parserstate *parser = alloc_parser(buffer, lexer, FIX2INT(start_pos), FIX2INT(end_pos), Qnil);
|
2926
2942
|
return rb_ensure(parse_signature_try, (VALUE)parser, ensure_free_parser, (VALUE)parser);
|
2927
2943
|
}
|
2928
2944
|
|
@@ -2950,12 +2966,17 @@ rbsparser_lex(VALUE self, VALUE buffer, VALUE end_pos) {
|
|
2950
2966
|
void rbs__init_parser(void) {
|
2951
2967
|
RBS_Parser = rb_define_class_under(RBS, "Parser", rb_cObject);
|
2952
2968
|
rb_gc_register_mark_object(RBS_Parser);
|
2969
|
+
|
2953
2970
|
VALUE empty_array = rb_obj_freeze(rb_ary_new());
|
2954
2971
|
rb_gc_register_mark_object(empty_array);
|
2955
2972
|
EMPTY_ARRAY = empty_array;
|
2956
2973
|
|
2974
|
+
VALUE empty_hash = rb_obj_freeze(rb_hash_new());
|
2975
|
+
rb_gc_register_mark_object(empty_hash);
|
2976
|
+
EMPTY_HASH = empty_hash;
|
2977
|
+
|
2957
2978
|
rb_define_singleton_method(RBS_Parser, "_parse_type", rbsparser_parse_type, 5);
|
2958
2979
|
rb_define_singleton_method(RBS_Parser, "_parse_method_type", rbsparser_parse_method_type, 5);
|
2959
|
-
rb_define_singleton_method(RBS_Parser, "_parse_signature", rbsparser_parse_signature,
|
2980
|
+
rb_define_singleton_method(RBS_Parser, "_parse_signature", rbsparser_parse_signature, 3);
|
2960
2981
|
rb_define_singleton_method(RBS_Parser, "_lex", rbsparser_lex, 2);
|
2961
2982
|
}
|