diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-09-06 12:19:38 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-09-06 16:19:43 +0000 |
commit | dee383b2625187ee2e9d27799aa83c2afe91caa2 (patch) | |
tree | 506eff683d6cf2a322ed044805ee88ad01470952 /yarp | |
parent | 1d4d9a016a5e38d07cff7581c0bf82df784e5617 (diff) |
[ruby/yarp] Constants on classes and modules
(https://github.com/ruby/yarp/pull/1409)
https://github.com/ruby/yarp/commit/0a11ec579f
Diffstat (limited to 'yarp')
-rw-r--r-- | yarp/config.yml | 4 | ||||
-rw-r--r-- | yarp/yarp.c | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/yarp/config.yml b/yarp/config.yml index 354c90abcd..164e96101f 100644 --- a/yarp/config.yml +++ b/yarp/config.yml @@ -779,7 +779,7 @@ nodes: - name: end_keyword_loc type: location - name: name - type: string + type: constant - name: name_constant type: constant comment: | @@ -1739,7 +1739,7 @@ nodes: - name: end_keyword_loc type: location - name: name - type: string + type: constant - name: name_constant type: constant comment: | diff --git a/yarp/yarp.c b/yarp/yarp.c index 78b3907308..4e291637f1 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -1647,6 +1647,7 @@ yp_case_node_end_keyword_loc_set(yp_case_node_t *node, const yp_token_t *end_key static yp_class_node_t * yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, yp_node_t *constant_path, const yp_token_t *name, const yp_token_t *inheritance_operator, yp_node_t *superclass, yp_node_t *body, const yp_token_t *end_keyword) { yp_class_node_t *node = YP_ALLOC_NODE(parser, yp_class_node_t); + yp_constant_id_t name_constant = yp_parser_constant_id_token(parser, name); *node = (yp_class_node_t) { { @@ -1660,11 +1661,10 @@ yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const y .superclass = superclass, .body = body, .end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword), - .name = YP_EMPTY_STRING, - .name_constant = yp_parser_constant_id_token(parser, name) + .name = name_constant, + .name_constant = name_constant }; - yp_string_shared_init(&node->name, name->start, name->end); return node; } @@ -3297,6 +3297,7 @@ yp_match_required_node_create(yp_parser_t *parser, yp_node_t *value, yp_node_t * static yp_module_node_t * yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *module_keyword, yp_node_t *constant_path, const yp_token_t *name, yp_node_t *body, const yp_token_t *end_keyword) { yp_module_node_t *node = YP_ALLOC_NODE(parser, yp_module_node_t); + yp_constant_id_t name_constant = yp_parser_constant_id_token(parser, name); *node = (yp_module_node_t) { { @@ -3311,11 +3312,10 @@ yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const .constant_path = constant_path, .body = body, .end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword), - .name = YP_EMPTY_STRING, - .name_constant = yp_parser_constant_id_token(parser, name) + .name = name_constant, + .name_constant = name_constant }; - yp_string_shared_init(&node->name, name->start, name->end); return node; } |