[ruby/prism] Add contains_splat flag

If we have a splat, add a flag for it named `contains_splat`.

https://github.com/ruby/prism/commit/5be97a75c8
This commit is contained in:
eileencodes 2024-08-27 16:40:48 -04:00 committed by git
parent 7462cc7743
commit 2157dcb568
14 changed files with 40 additions and 34 deletions

View File

@ -651,6 +651,8 @@ flags:
comment: "if arguments contain keywords"
- name: CONTAINS_KEYWORD_SPLAT
comment: "if arguments contain keyword splat"
- name: CONTAINS_SPLAT
comment: "if arguments contain splat"
comment: Flags for arguments nodes.
- name: ArrayNodeFlags
values:

View File

@ -2063,6 +2063,10 @@ pm_arguments_node_arguments_append(pm_arguments_node_t *node, pm_node_t *argumen
node->base.location.end = argument->location.end;
pm_node_list_append(&node->arguments, argument);
if (PM_NODE_TYPE_P(argument, PM_SPLAT_NODE)) {
pm_node_flag_set((pm_node_t *) node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT);
}
}
/**

View File

@ -1418,7 +1418,7 @@
│ │ ├── opening_loc: (108,11)-(108,12) = "["
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (108,12)-(108,13))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ SplatNode (location: (108,12)-(108,13))
│ │ │ ├── flags: ∅
@ -1476,7 +1476,7 @@
│ │ ├── opening_loc: (110,11)-(110,12) = "["
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (110,12)-(110,16))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 2)
│ │ │ ├── @ IntegerNode (location: (110,12)-(110,13))
│ │ │ │ ├── flags: static_literal, decimal
@ -1537,7 +1537,7 @@
│ │ ├── opening_loc: (112,11)-(112,12) = "["
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (112,12)-(112,18))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 2)
│ │ │ ├── @ SplatNode (location: (112,12)-(112,13))
│ │ │ │ ├── flags: ∅
@ -1598,7 +1598,7 @@
│ │ ├── opening_loc: (114,11)-(114,12) = "["
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (114,12)-(114,21))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 3)
│ │ │ ├── @ IntegerNode (location: (114,12)-(114,13))
│ │ │ │ ├── flags: static_literal, decimal
@ -1660,7 +1660,7 @@
│ │ ├── opening_loc: (116,11)-(116,12) = "["
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (116,12)-(116,13))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ SplatNode (location: (116,12)-(116,13))
│ │ │ ├── flags: ∅
@ -1722,7 +1722,7 @@
│ │ ├── opening_loc: (118,11)-(118,12) = "["
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (118,12)-(118,16))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 2)
│ │ │ ├── @ IntegerNode (location: (118,12)-(118,13))
│ │ │ │ ├── flags: static_literal, decimal
@ -1793,7 +1793,7 @@
│ │ │ │ ├── opening_loc: (120,21)-(120,22) = "["
│ │ │ │ ├── arguments:
│ │ │ │ │ @ ArgumentsNode (location: (120,22)-(120,23))
│ │ │ │ │ ├── flags:
│ │ │ │ │ ├── flags: contains_splat
│ │ │ │ │ └── arguments: (length: 1)
│ │ │ │ │ └── @ SplatNode (location: (120,22)-(120,23))
│ │ │ │ │ ├── flags: ∅
@ -1861,7 +1861,7 @@
│ │ │ ├── opening_loc: (122,21)-(122,22) = "["
│ │ │ ├── arguments:
│ │ │ │ @ ArgumentsNode (location: (122,22)-(122,26))
│ │ │ │ ├── flags:
│ │ │ │ ├── flags: contains_splat
│ │ │ │ └── arguments: (length: 2)
│ │ │ │ ├── @ IntegerNode (location: (122,22)-(122,23))
│ │ │ │ │ ├── flags: static_literal, decimal

View File

@ -99,7 +99,7 @@
│ ├── opening_loc: ∅
│ ├── arguments:
│ │ @ ArgumentsNode (location: (15,4)-(15,8))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (15,4)-(15,8))
│ │ ├── flags: ∅
@ -183,7 +183,7 @@
│ ├── opening_loc: ∅
│ ├── arguments:
│ │ @ ArgumentsNode (location: (21,9)-(21,13))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (21,9)-(21,13))
│ │ ├── flags: ∅

View File

@ -414,7 +414,7 @@
│ ├── opening_loc: (35,1)-(35,2) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (35,2)-(35,7))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (35,2)-(35,7))
│ │ ├── flags: ∅
@ -763,7 +763,7 @@
│ ├── opening_loc: (58,3)-(58,4) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (58,4)-(58,9))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (58,4)-(58,9))
│ │ ├── flags: ∅
@ -2453,7 +2453,7 @@
│ │ ├── opening_loc: ∅
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (149,12)-(149,13))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ SplatNode (location: (149,12)-(149,13))
│ │ │ ├── flags: ∅

View File

@ -1041,7 +1041,7 @@
│ │ ├── opening_loc: (110,11)-(110,12) = "("
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (110,12)-(110,13))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ SplatNode (location: (110,12)-(110,13))
│ │ │ ├── flags: ∅

View File

@ -54,7 +54,7 @@
│ ├── keyword_loc: (5,0)-(5,6) = "return"
│ └── arguments:
│ @ ArgumentsNode (location: (5,7)-(5,9))
│ ├── flags:
│ ├── flags: contains_splat
│ └── arguments: (length: 1)
│ └── @ SplatNode (location: (5,7)-(5,9))
│ ├── flags: ∅

View File

@ -399,7 +399,7 @@
│ │ │ ├── opening_loc: (15,2)-(15,3) = "["
│ │ │ ├── arguments:
│ │ │ │ @ ArgumentsNode (location: (15,3)-(15,7))
│ │ │ │ ├── flags:
│ │ │ │ ├── flags: contains_splat
│ │ │ │ └── arguments: (length: 1)
│ │ │ │ └── @ SplatNode (location: (15,3)-(15,7))
│ │ │ │ ├── flags: ∅
@ -723,7 +723,7 @@
│ ├── opening_loc: (29,3)-(29,4) = "["
│ ├── arguments:
│ │ @ ArgumentsNode (location: (29,4)-(29,19))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 2)
│ │ ├── @ SplatNode (location: (29,4)-(29,10))
│ │ │ ├── flags: ∅

View File

@ -890,7 +890,7 @@
│ ├── opening_loc: (52,3)-(52,4) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (52,4)-(52,9))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (52,4)-(52,9))
│ │ ├── flags: ∅
@ -931,7 +931,7 @@
│ ├── opening_loc: (53,3)-(53,4) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (53,4)-(53,14))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (53,4)-(53,14))
│ │ ├── flags: ∅
@ -1000,7 +1000,7 @@
│ ├── opening_loc: (56,3)-(56,4) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (56,4)-(56,14))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 2)
│ │ ├── @ CallNode (location: (56,4)-(56,7))
│ │ │ ├── flags: variable_call, ignore_visibility
@ -1123,7 +1123,7 @@
│ ├── opening_loc: (59,7)-(59,8) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (59,8)-(59,25))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 3)
│ │ ├── @ SplatNode (location: (59,8)-(59,13))
│ │ │ ├── flags: ∅
@ -1184,7 +1184,7 @@
│ ├── opening_loc: (60,7)-(60,8) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (60,8)-(60,13))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (60,8)-(60,13))
│ │ ├── flags: ∅
@ -1221,7 +1221,7 @@
│ ├── opening_loc: (61,7)-(61,8) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (61,8)-(61,18))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 2)
│ │ ├── @ SplatNode (location: (61,8)-(61,13))
│ │ │ ├── flags: ∅
@ -1415,7 +1415,7 @@
│ ├── opening_loc: (65,7)-(65,8) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (65,8)-(65,18))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 2)
│ │ ├── @ CallNode (location: (65,8)-(65,11))
│ │ │ ├── flags: variable_call, ignore_visibility
@ -1462,7 +1462,7 @@
│ ├── opening_loc: (66,7)-(66,8) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (66,8)-(66,18))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 2)
│ │ ├── @ CallNode (location: (66,8)-(66,11))
│ │ │ ├── flags: variable_call, ignore_visibility
@ -1773,7 +1773,7 @@
│ ├── opening_loc: (73,3)-(73,4) = "["
│ ├── arguments:
│ │ @ ArgumentsNode (location: (73,4)-(73,8))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (73,4)-(73,8))
│ │ ├── flags: ∅
@ -2136,7 +2136,7 @@
│ │ ├── opening_loc: (80,13)-(80,14) = "("
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (80,14)-(80,16))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ SplatNode (location: (80,14)-(80,16))
│ │ │ ├── flags: ∅

View File

@ -99,7 +99,7 @@
│ │ ├── opening_loc: (6,5)-(6,6) = "("
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (6,6)-(6,17))
│ │ │ ├── flags:
│ │ │ ├── flags: contains_splat
│ │ │ └── arguments: (length: 2)
│ │ │ ├── @ LocalVariableReadNode (location: (6,6)-(6,14))
│ │ │ │ ├── flags: ∅

View File

@ -14,7 +14,7 @@
│ ├── opening_loc: (1,3)-(1,4) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (1,4)-(1,13))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 2)
│ │ ├── @ CallNode (location: (1,4)-(1,7))
│ │ │ ├── flags: variable_call, ignore_visibility
@ -51,7 +51,7 @@
├── opening_loc: (3,3)-(3,4) = "("
├── arguments:
│ @ ArgumentsNode (location: (3,4)-(3,13))
│ ├── flags:
│ ├── flags: contains_splat
│ └── arguments: (length: 2)
│ ├── @ CallNode (location: (3,4)-(3,7))
│ │ ├── flags: variable_call, ignore_visibility

View File

@ -14,7 +14,7 @@
│ ├── opening_loc: (1,3)-(1,4) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (1,4)-(1,8))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (1,4)-(1,8))
│ │ ├── flags: ∅
@ -41,7 +41,7 @@
├── opening_loc: (3,3)-(3,4) = "("
├── arguments:
│ @ ArgumentsNode (location: (3,4)-(3,8))
│ ├── flags:
│ ├── flags: contains_splat
│ └── arguments: (length: 1)
│ └── @ SplatNode (location: (3,4)-(3,8))
│ ├── flags: ∅

View File

@ -41,7 +41,7 @@
│ ├── opening_loc: (1,25)-(1,26) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (1,26)-(1,37))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 2)
│ │ ├── @ LocalVariableReadNode (location: (1,26)-(1,34))
│ │ │ ├── flags: ∅

View File

@ -38,7 +38,7 @@
│ ├── opening_loc: (1,15)-(1,16) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (1,16)-(1,17))
│ │ ├── flags:
│ │ ├── flags: contains_splat
│ │ └── arguments: (length: 1)
│ │ └── @ SplatNode (location: (1,16)-(1,17))
│ │ ├── flags: ∅