[ruby/yarp] Constant on block parameter node

https://github.com/ruby/yarp/commit/2cd9a67150
This commit is contained in:
Kevin Newton 2023-09-06 10:46:20 -04:00 committed by git
parent 08929b344d
commit 746eede412
33 changed files with 119 additions and 76 deletions

View File

@ -644,7 +644,7 @@ module YARP
nil, nil,
[], [],
nil, nil,
BlockParameterNode(Location(), Location()) BlockParameterNode(:block, Location(), Location())
), ),
nil, nil,
[:block, :a], [:block, :a],
@ -664,7 +664,7 @@ module YARP
expected = DefNode( expected = DefNode(
Location(), Location(),
nil, nil,
ParametersNode([], [], [RequiredParameterNode(:a)], nil, [], nil, BlockParameterNode(nil, Location())), ParametersNode([], [], [RequiredParameterNode(:a)], nil, [], nil, BlockParameterNode(nil, nil, Location())),
nil, nil,
[:&, :a], [:&, :a],
Location(), Location(),
@ -1087,7 +1087,7 @@ module YARP
expected = DefNode( expected = DefNode(
Location(), Location(),
nil, nil,
ParametersNode([RequiredParameterNode(:a), RequiredParameterNode(:b)], [], [], nil, [], nil, BlockParameterNode(Location(), Location())), ParametersNode([RequiredParameterNode(:a), RequiredParameterNode(:b)], [], [], nil, [], nil, BlockParameterNode(:a, Location(), Location())),
nil, nil,
[:a, :b], [:a, :b],
Location(), Location(),

View File

@ -876,7 +876,7 @@ ProgramNode(0...1194)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(789...791)((790...791), (789...790)) BlockParameterNode(789...791)(:b, (790...791), (789...790))
), ),
nil, nil,
[:b], [:b],
@ -897,7 +897,7 @@ ProgramNode(0...1194)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(803...804)(nil, (803...804)) BlockParameterNode(803...804)(nil, nil, (803...804))
), ),
nil, nil,
[:&], [:&],

View File

@ -93,7 +93,7 @@ ProgramNode(0...266)(
[KeywordParameterNode(113...115)((113...115), nil), [KeywordParameterNode(113...115)((113...115), nil),
KeywordParameterNode(117...119)((117...119), nil)], KeywordParameterNode(117...119)((117...119), nil)],
nil, nil,
BlockParameterNode(121...123)((122...123), (121...122)) BlockParameterNode(121...123)(:e, (122...123), (121...122))
), ),
[], [],
nil, nil,
@ -120,7 +120,7 @@ ProgramNode(0...266)(
[KeywordParameterNode(149...151)((149...151), nil), [KeywordParameterNode(149...151)((149...151), nil),
KeywordParameterNode(153...155)((153...155), nil)], KeywordParameterNode(153...155)((153...155), nil)],
KeywordRestParameterNode(157...160)((157...159), (159...160)), KeywordRestParameterNode(157...160)((157...159), (159...160)),
BlockParameterNode(162...164)((163...164), (162...163)) BlockParameterNode(162...164)(:g, (163...164), (162...163))
), ),
[], [],
(134...135), (134...135),
@ -147,7 +147,7 @@ ProgramNode(0...266)(
[KeywordParameterNode(191...193)((191...193), nil), [KeywordParameterNode(191...193)((191...193), nil),
KeywordParameterNode(195...197)((195...197), nil)], KeywordParameterNode(195...197)((195...197), nil)],
KeywordRestParameterNode(199...202)((199...201), (201...202)), KeywordRestParameterNode(199...202)((199...201), (201...202)),
BlockParameterNode(204...206)((205...206), (204...205)) BlockParameterNode(204...206)(:g, (205...206), (204...205))
), ),
[], [],
(176...177), (176...177),

View File

@ -11,7 +11,7 @@ ProgramNode(0...20)(
nil, nil,
[KeywordParameterNode(6...10)((6...8), IntegerNode(9...10)())], [KeywordParameterNode(6...10)((6...8), IntegerNode(9...10)())],
nil, nil,
BlockParameterNode(12...14)((13...14), (12...13)) BlockParameterNode(12...14)(:b, (13...14), (12...13))
), ),
nil, nil,
[:a, :b], [:a, :b],

View File

@ -11,7 +11,7 @@ ProgramNode(0...13)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(6...7)(nil, (6...7)) BlockParameterNode(6...7)(nil, nil, (6...7))
), ),
nil, nil,
[:&], [:&],

View File

@ -23,7 +23,7 @@ ProgramNode(0...21)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(16...18)((17...18), (16...17)) BlockParameterNode(16...18)(:e, (17...18), (16...17))
), ),
[], [],
(4...5), (4...5),

View File

@ -23,7 +23,7 @@ ProgramNode(0...25)(
RestParameterNode(13...15)((13...14), (14...15)), RestParameterNode(13...15)((13...14), (14...15)),
[], [],
nil, nil,
BlockParameterNode(20...22)((21...22), (20...21)) BlockParameterNode(20...22)(:f, (21...22), (20...21))
), ),
[], [],
(4...5), (4...5),

View File

@ -29,7 +29,7 @@ ProgramNode(0...42)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(24...26)((25...26), (24...25)) BlockParameterNode(24...26)(:d, (25...26), (24...25))
), ),
[], [],
(4...5), (4...5),

View File

@ -23,7 +23,7 @@ ProgramNode(0...22)(
RestParameterNode(10...12)((10...11), (11...12)), RestParameterNode(10...12)((10...11), (11...12)),
[], [],
nil, nil,
BlockParameterNode(17...19)((18...19), (17...18)) BlockParameterNode(17...19)(:e, (18...19), (17...18))
), ),
[], [],
(4...5), (4...5),

View File

@ -18,7 +18,7 @@ ProgramNode(0...17)(
RestParameterNode(5...7)((5...6), (6...7)), RestParameterNode(5...7)((5...6), (6...7)),
[], [],
nil, nil,
BlockParameterNode(12...14)((13...14), (12...13)) BlockParameterNode(12...14)(:c, (13...14), (12...13))
), ),
[], [],
(4...5), (4...5),

View File

@ -23,7 +23,7 @@ ProgramNode(0...25)(
RestParameterNode(16...18)((16...17), (17...18)), RestParameterNode(16...18)((16...17), (17...18)),
[], [],
nil, nil,
BlockParameterNode(20...22)((21...22), (20...21)) BlockParameterNode(20...22)(:d, (21...22), (20...21))
), ),
[], [],
(4...5), (4...5),

View File

@ -23,7 +23,7 @@ ProgramNode(0...28)(
RestParameterNode(16...18)((16...17), (17...18)), RestParameterNode(16...18)((16...17), (17...18)),
[], [],
nil, nil,
BlockParameterNode(23...25)((24...25), (23...24)) BlockParameterNode(23...25)(:e, (24...25), (23...24))
), ),
[], [],
(4...5), (4...5),

View File

@ -18,7 +18,7 @@ ProgramNode(0...13)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(8...10)((9...10), (8...9)) BlockParameterNode(8...10)(:b, (9...10), (8...9))
), ),
[], [],
(4...5), (4...5),

View File

@ -23,7 +23,7 @@ ProgramNode(0...22)(
RestParameterNode(13...15)((13...14), (14...15)), RestParameterNode(13...15)((13...14), (14...15)),
[], [],
nil, nil,
BlockParameterNode(17...19)((18...19), (17...18)) BlockParameterNode(17...19)(:c, (18...19), (17...18))
), ),
[], [],
(4...5), (4...5),

View File

@ -23,7 +23,7 @@ ProgramNode(0...25)(
RestParameterNode(13...15)((13...14), (14...15)), RestParameterNode(13...15)((13...14), (14...15)),
[], [],
nil, nil,
BlockParameterNode(20...22)((21...22), (20...21)) BlockParameterNode(20...22)(:d, (21...22), (20...21))
), ),
[], [],
(4...5), (4...5),

View File

@ -23,7 +23,7 @@ ProgramNode(0...21)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(16...18)((17...18), (16...17)) BlockParameterNode(16...18)(:c, (17...18), (16...17))
), ),
[], [],
(4...5), (4...5),

View File

@ -19,7 +19,7 @@ ProgramNode(0...23)(
RestParameterNode(11...13)((11...12), (12...13)), RestParameterNode(11...13)((11...12), (12...13)),
[], [],
nil, nil,
BlockParameterNode(18...20)((19...20), (18...19)) BlockParameterNode(18...20)(:f, (19...20), (18...19))
), ),
[], [],
(2...3), (2...3),

View File

@ -781,7 +781,7 @@ ProgramNode(0...913)(
RestParameterNode(654...658)((654...655), (655...658)), RestParameterNode(654...658)((654...655), (655...658)),
[], [],
nil, nil,
BlockParameterNode(660...666)((661...666), (660...661)) BlockParameterNode(660...666)(:block, (661...666), (660...661))
), ),
StatementsNode(670...673)( StatementsNode(670...673)(
[CallNode(670...673)( [CallNode(670...673)(
@ -840,7 +840,7 @@ ProgramNode(0...913)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(729...735)((730...735), (729...730)) BlockParameterNode(729...735)(:block, (730...735), (729...730))
), ),
StatementsNode(739...742)( StatementsNode(739...742)(
[CallNode(739...742)( [CallNode(739...742)(
@ -873,7 +873,7 @@ ProgramNode(0...913)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(761...767)((762...767), (761...762)) BlockParameterNode(761...767)(:block, (762...767), (761...762))
), ),
StatementsNode(771...774)([LocalVariableReadNode(771...774)(:bar, 0)]), StatementsNode(771...774)([LocalVariableReadNode(771...774)(:bar, 0)]),
[:bar, :block], [:bar, :block],

View File

@ -11,7 +11,7 @@ ProgramNode(0...51)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(8...9)(nil, (8...9)) BlockParameterNode(8...9)(nil, nil, (8...9))
), ),
StatementsNode(13...19)( StatementsNode(13...19)(
[CallNode(13...19)( [CallNode(13...19)(
@ -46,7 +46,7 @@ ProgramNode(0...51)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(36...37)(nil, (36...37)) BlockParameterNode(36...37)(nil, nil, (36...37))
), ),
StatementsNode(41...47)( StatementsNode(41...47)(
[CallNode(41...47)( [CallNode(41...47)(

View File

@ -11,7 +11,7 @@ ProgramNode(0...23)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(8...9)(nil, (8...9)) BlockParameterNode(8...9)(nil, nil, (8...9))
), ),
StatementsNode(12...18)( StatementsNode(12...18)(
[CallNode(12...18)( [CallNode(12...18)(

View File

@ -11,7 +11,7 @@ ProgramNode(0...690)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(6...8)((7...8), (6...7)) BlockParameterNode(6...8)(:b, (7...8), (6...7))
), ),
nil, nil,
[:b], [:b],
@ -310,7 +310,7 @@ ProgramNode(0...690)(
IntegerNode(241...242)() IntegerNode(241...242)()
)], )],
nil, nil,
BlockParameterNode(244...246)((245...246), (244...245)) BlockParameterNode(244...246)(:b, (245...246), (244...245))
), ),
nil, nil,
[:foo, :b], [:foo, :b],
@ -338,7 +338,7 @@ ProgramNode(0...690)(
IntegerNode(274...275)() IntegerNode(274...275)()
)], )],
KeywordRestParameterNode(277...282)((277...279), (279...282)), KeywordRestParameterNode(277...282)((277...279), (279...282)),
BlockParameterNode(284...286)((285...286), (284...285)) BlockParameterNode(284...286)(:b, (285...286), (284...285))
), ),
nil, nil,
[:foo, :bar, :baz, :b], [:foo, :bar, :baz, :b],
@ -359,7 +359,7 @@ ProgramNode(0...690)(
nil, nil,
[], [],
KeywordRestParameterNode(300...305)((300...302), (302...305)), KeywordRestParameterNode(300...305)((300...302), (302...305)),
BlockParameterNode(307...309)((308...309), (307...308)) BlockParameterNode(307...309)(:b, (308...309), (307...308))
), ),
nil, nil,
[:baz, :b], [:baz, :b],
@ -401,7 +401,7 @@ ProgramNode(0...690)(
RestParameterNode(340...342)((340...341), (341...342)), RestParameterNode(340...342)((340...341), (341...342)),
[], [],
nil, nil,
BlockParameterNode(344...346)((345...346), (344...345)) BlockParameterNode(344...346)(:b, (345...346), (344...345))
), ),
nil, nil,
[:r, :b], [:r, :b],
@ -422,7 +422,7 @@ ProgramNode(0...690)(
RestParameterNode(359...361)((359...360), (360...361)), RestParameterNode(359...361)((359...360), (360...361)),
[], [],
nil, nil,
BlockParameterNode(366...368)((367...368), (366...367)) BlockParameterNode(366...368)(:b, (367...368), (366...367))
), ),
nil, nil,
[:r, :p, :b], [:r, :p, :b],
@ -456,7 +456,7 @@ ProgramNode(0...690)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(397...399)((398...399), (397...398)) BlockParameterNode(397...399)(:b, (398...399), (397...398))
), ),
nil, nil,
[:a, :b], [:a, :b],
@ -477,7 +477,7 @@ ProgramNode(0...690)(
RestParameterNode(415...417)((415...416), (416...417)), RestParameterNode(415...417)((415...416), (416...417)),
[], [],
nil, nil,
BlockParameterNode(419...421)((420...421), (419...420)) BlockParameterNode(419...421)(:b, (420...421), (419...420))
), ),
nil, nil,
[:a, :r, :b], [:a, :r, :b],
@ -498,7 +498,7 @@ ProgramNode(0...690)(
RestParameterNode(437...439)((437...438), (438...439)), RestParameterNode(437...439)((437...438), (438...439)),
[], [],
nil, nil,
BlockParameterNode(444...446)((445...446), (444...445)) BlockParameterNode(444...446)(:b, (445...446), (444...445))
), ),
nil, nil,
[:a, :r, :p, :b], [:a, :r, :p, :b],
@ -524,7 +524,7 @@ ProgramNode(0...690)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(467...469)((468...469), (467...468)) BlockParameterNode(467...469)(:b, (468...469), (467...468))
), ),
nil, nil,
[:a, :o, :b], [:a, :o, :b],
@ -550,7 +550,7 @@ ProgramNode(0...690)(
RestParameterNode(490...492)((490...491), (491...492)), RestParameterNode(490...492)((490...491), (491...492)),
[], [],
nil, nil,
BlockParameterNode(494...496)((495...496), (494...495)) BlockParameterNode(494...496)(:b, (495...496), (494...495))
), ),
nil, nil,
[:a, :o, :r, :b], [:a, :o, :r, :b],
@ -576,7 +576,7 @@ ProgramNode(0...690)(
RestParameterNode(517...519)((517...518), (518...519)), RestParameterNode(517...519)((517...518), (518...519)),
[], [],
nil, nil,
BlockParameterNode(524...526)((525...526), (524...525)) BlockParameterNode(524...526)(:b, (525...526), (524...525))
), ),
nil, nil,
[:a, :o, :r, :p, :b], [:a, :o, :r, :p, :b],
@ -602,7 +602,7 @@ ProgramNode(0...690)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(550...552)((551...552), (550...551)) BlockParameterNode(550...552)(:b, (551...552), (550...551))
), ),
nil, nil,
[:a, :o, :p, :b], [:a, :o, :p, :b],
@ -673,7 +673,7 @@ ProgramNode(0...690)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(609...611)((610...611), (609...610)) BlockParameterNode(609...611)(:b, (610...611), (609...610))
), ),
nil, nil,
[:o, :b], [:o, :b],
@ -699,7 +699,7 @@ ProgramNode(0...690)(
RestParameterNode(629...631)((629...630), (630...631)), RestParameterNode(629...631)((629...630), (630...631)),
[], [],
nil, nil,
BlockParameterNode(633...635)((634...635), (633...634)) BlockParameterNode(633...635)(:b, (634...635), (633...634))
), ),
nil, nil,
[:o, :r, :b], [:o, :r, :b],
@ -725,7 +725,7 @@ ProgramNode(0...690)(
RestParameterNode(653...655)((653...654), (654...655)), RestParameterNode(653...655)((653...654), (654...655)),
[], [],
nil, nil,
BlockParameterNode(660...662)((661...662), (660...661)) BlockParameterNode(660...662)(:b, (661...662), (660...661))
), ),
nil, nil,
[:o, :r, :p, :b], [:o, :r, :p, :b],
@ -751,7 +751,7 @@ ProgramNode(0...690)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(683...685)((684...685), (683...684)) BlockParameterNode(683...685)(:b, (684...685), (683...684))
), ),
nil, nil,
[:o, :p, :b], [:o, :p, :b],

View File

@ -11,7 +11,7 @@ ProgramNode(0...18)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(6...12)((7...12), (6...7)) BlockParameterNode(6...12)(:block, (7...12), (6...7))
), ),
nil, nil,
[:block], [:block],

View File

@ -46,7 +46,7 @@ ProgramNode(0...550)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(21...23)((22...23), (21...22)) BlockParameterNode(21...23)(:b, (22...23), (21...22))
), ),
[], [],
(20...21), (20...21),
@ -76,7 +76,7 @@ ProgramNode(0...550)(
nil, nil,
[], [],
KeywordRestParameterNode(32...37)((32...34), (34...37)), KeywordRestParameterNode(32...37)((32...34), (34...37)),
BlockParameterNode(39...41)((40...41), (39...40)) BlockParameterNode(39...41)(:b, (40...41), (39...40))
), ),
[], [],
(31...32), (31...32),
@ -106,7 +106,7 @@ ProgramNode(0...550)(
RestParameterNode(50...51)((50...51), nil), RestParameterNode(50...51)((50...51), nil),
[], [],
nil, nil,
BlockParameterNode(53...55)((54...55), (53...54)) BlockParameterNode(53...55)(:b, (54...55), (53...54))
), ),
[], [],
(49...50), (49...50),
@ -136,7 +136,7 @@ ProgramNode(0...550)(
RestParameterNode(64...66)((64...65), (65...66)), RestParameterNode(64...66)((64...65), (65...66)),
[], [],
nil, nil,
BlockParameterNode(71...73)((72...73), (71...72)) BlockParameterNode(71...73)(:b, (72...73), (71...72))
), ),
[], [],
(63...64), (63...64),
@ -166,7 +166,7 @@ ProgramNode(0...550)(
RestParameterNode(82...84)((82...83), (83...84)), RestParameterNode(82...84)((82...83), (83...84)),
[], [],
nil, nil,
BlockParameterNode(86...88)((87...88), (86...87)) BlockParameterNode(86...88)(:b, (87...88), (86...87))
), ),
[], [],
(81...82), (81...82),
@ -300,7 +300,7 @@ ProgramNode(0...550)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(145...147)((146...147), (145...146)) BlockParameterNode(145...147)(:b, (146...147), (145...146))
), ),
[], [],
(141...142), (141...142),
@ -330,7 +330,7 @@ ProgramNode(0...550)(
RestParameterNode(159...160)((159...160), nil), RestParameterNode(159...160)((159...160), nil),
[], [],
nil, nil,
BlockParameterNode(162...164)((163...164), (162...163)) BlockParameterNode(162...164)(:b, (163...164), (162...163))
), ),
[], [],
(155...156), (155...156),
@ -360,7 +360,7 @@ ProgramNode(0...550)(
RestParameterNode(176...178)((176...177), (177...178)), RestParameterNode(176...178)((176...177), (177...178)),
[], [],
nil, nil,
BlockParameterNode(183...185)((184...185), (183...184)) BlockParameterNode(183...185)(:b, (184...185), (183...184))
), ),
[], [],
(172...173), (172...173),
@ -390,7 +390,7 @@ ProgramNode(0...550)(
RestParameterNode(197...199)((197...198), (198...199)), RestParameterNode(197...199)((197...198), (198...199)),
[], [],
nil, nil,
BlockParameterNode(201...203)((202...203), (201...202)) BlockParameterNode(201...203)(:b, (202...203), (201...202))
), ),
[], [],
(193...194), (193...194),
@ -547,7 +547,7 @@ ProgramNode(0...550)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(274...276)((275...276), (274...275)) BlockParameterNode(274...276)(:b, (275...276), (274...275))
), ),
[], [],
(265...266), (265...266),
@ -582,7 +582,7 @@ ProgramNode(0...550)(
RestParameterNode(293...295)((293...294), (294...295)), RestParameterNode(293...295)((293...294), (294...295)),
[], [],
nil, nil,
BlockParameterNode(300...302)((301...302), (300...301)) BlockParameterNode(300...302)(:b, (301...302), (300...301))
), ),
[], [],
(284...285), (284...285),
@ -623,7 +623,7 @@ ProgramNode(0...550)(
RestParameterNode(325...327)((325...326), (326...327)), RestParameterNode(325...327)((325...326), (326...327)),
[], [],
nil, nil,
BlockParameterNode(329...331)((330...331), (329...330)) BlockParameterNode(329...331)(:b, (330...331), (329...330))
), ),
[], [],
(310...311), (310...311),
@ -658,7 +658,7 @@ ProgramNode(0...550)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(351...353)((352...353), (351...352)) BlockParameterNode(351...353)(:b, (352...353), (351...352))
), ),
[], [],
(339...340), (339...340),
@ -811,7 +811,7 @@ ProgramNode(0...550)(
IntegerNode(408...409)() IntegerNode(408...409)()
)], )],
nil, nil,
BlockParameterNode(411...413)((412...413), (411...412)) BlockParameterNode(411...413)(:b, (412...413), (411...412))
), ),
[], [],
(402...403), (402...403),
@ -848,7 +848,7 @@ ProgramNode(0...550)(
IntegerNode(435...436)() IntegerNode(435...436)()
)], )],
KeywordRestParameterNode(438...443)((438...440), (440...443)), KeywordRestParameterNode(438...443)((438...440), (440...443)),
BlockParameterNode(445...447)((446...447), (445...446)) BlockParameterNode(445...447)(:b, (446...447), (445...446))
), ),
[], [],
(421...422), (421...422),
@ -913,7 +913,7 @@ ProgramNode(0...550)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(474...476)((475...476), (474...475)) BlockParameterNode(474...476)(:b, (475...476), (474...475))
), ),
[], [],
(468...469), (468...469),
@ -948,7 +948,7 @@ ProgramNode(0...550)(
RestParameterNode(490...492)((490...491), (491...492)), RestParameterNode(490...492)((490...491), (491...492)),
[], [],
nil, nil,
BlockParameterNode(494...496)((495...496), (494...495)) BlockParameterNode(494...496)(:b, (495...496), (494...495))
), ),
[], [],
(484...485), (484...485),
@ -983,7 +983,7 @@ ProgramNode(0...550)(
RestParameterNode(510...512)((510...511), (511...512)), RestParameterNode(510...512)((510...511), (511...512)),
[], [],
nil, nil,
BlockParameterNode(517...519)((518...519), (517...518)) BlockParameterNode(517...519)(:b, (518...519), (517...518))
), ),
[], [],
(504...505), (504...505),
@ -1018,7 +1018,7 @@ ProgramNode(0...550)(
nil, nil,
[], [],
nil, nil,
BlockParameterNode(536...538)((537...538), (536...537)) BlockParameterNode(536...538)(:b, (537...538), (536...537))
), ),
[], [],
(527...528), (527...528),

View File

@ -549,6 +549,8 @@ nodes:
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
- name: BlockParameterNode - name: BlockParameterNode
fields: fields:
- name: name
type: constant?
- name: name_loc - name: name_loc
type: location? type: location?
- name: operator_loc - name: operator_loc

View File

@ -154,6 +154,8 @@ yp_ast_new(yp_parser_t *parser, yp_node_t *node, rb_encoding *encoding) {
argv[<%= index %>] = yp_string_new(&cast-><%= field.name %>, encoding); argv[<%= index %>] = yp_string_new(&cast-><%= field.name %>, encoding);
<%- when YARP::ConstantField -%> <%- when YARP::ConstantField -%>
argv[<%= index %>] = rb_id2sym(constants[cast-><%= field.name %> - 1]); argv[<%= index %>] = rb_id2sym(constants[cast-><%= field.name %> - 1]);
<%- when YARP::OptionalConstantField -%>
argv[<%= index %>] = cast-><%= field.name %> == 0 ? Qnil : rb_id2sym(constants[cast-><%= field.name %> - 1]);
<%- when YARP::ConstantListField -%> <%- when YARP::ConstantListField -%>
argv[<%= index %>] = rb_ary_new_capa(cast-><%= field.name %>.size); argv[<%= index %>] = rb_ary_new_capa(cast-><%= field.name %>.size);
for (size_t index = 0; index < cast-><%= field.name %>.size; index++) { for (size_t index = 0; index < cast-><%= field.name %>.size; index++) {

View File

@ -95,7 +95,7 @@ typedef struct yp_<%= node.human %> {
<%= case field <%= case field
when YARP::NodeField, YARP::OptionalNodeField then "struct #{field.c_type} *#{field.name}" when YARP::NodeField, YARP::OptionalNodeField then "struct #{field.c_type} *#{field.name}"
when YARP::NodeListField then "struct yp_node_list #{field.name}" when YARP::NodeListField then "struct yp_node_list #{field.name}"
when YARP::ConstantField then "yp_constant_id_t #{field.name}" when YARP::ConstantField, YARP::OptionalConstantField then "yp_constant_id_t #{field.name}"
when YARP::ConstantListField then "yp_constant_id_list_t #{field.name}" when YARP::ConstantListField then "yp_constant_id_list_t #{field.name}"
when YARP::StringField then "yp_string_t #{field.name}" when YARP::StringField then "yp_string_t #{field.name}"
when YARP::LocationField, YARP::OptionalLocationField then "yp_location_t #{field.name}" when YARP::LocationField, YARP::OptionalLocationField then "yp_location_t #{field.name}"

View File

@ -112,7 +112,7 @@ module YARP
inspector << "<%= pointer %><%= field.name %>:\n" inspector << "<%= pointer %><%= field.name %>:\n"
inspector << <%= field.name %>.inspect(inspector.child_inspector("<%= preadd %>")).delete_prefix(inspector.prefix) inspector << <%= field.name %>.inspect(inspector.child_inspector("<%= preadd %>")).delete_prefix(inspector.prefix)
end end
<%- when YARP::ConstantField, YARP::StringField, YARP::UInt32Field -%> <%- when YARP::ConstantField, YARP::OptionalConstantField, YARP::StringField, YARP::UInt32Field -%>
inspector << "<%= pointer %><%= field.name %>: #{<%= field.name %>.inspect}\n" inspector << "<%= pointer %><%= field.name %>: #{<%= field.name %>.inspect}\n"
<%- when YARP::FlagsField -%> <%- when YARP::FlagsField -%>
<%- flag = flags.find { |flag| flag.name == field.kind }.tap { |flag| raise unless flag } -%> <%- flag = flags.find { |flag| flag.name == field.kind }.tap { |flag| raise unless flag } -%>

View File

@ -152,8 +152,7 @@ module YARP
load_location if io.getbyte != 0 load_location if io.getbyte != 0
end end
def load_constant def load_constant(index)
index = load_varint - 1
constant = constant_pool[index] constant = constant_pool[index]
unless constant unless constant
@ -169,6 +168,15 @@ module YARP
constant constant
end end
def load_required_constant
load_constant(load_varint - 1)
end
def load_optional_constant
index = load_varint
load_constant(index - 1) if index != 0
end
def load_node def load_node
type = io.getbyte type = io.getbyte
location = load_location location = load_location
@ -185,8 +193,9 @@ module YARP
when YARP::OptionalNodeField then "load_optional_node" when YARP::OptionalNodeField then "load_optional_node"
when YARP::StringField then "load_string" when YARP::StringField then "load_string"
when YARP::NodeListField then "Array.new(load_varint) { load_node }" when YARP::NodeListField then "Array.new(load_varint) { load_node }"
when YARP::ConstantField then "load_constant" when YARP::ConstantField then "load_required_constant"
when YARP::ConstantListField then "Array.new(load_varint) { load_constant }" when YARP::OptionalConstantField then "load_optional_constant"
when YARP::ConstantListField then "Array.new(load_varint) { load_required_constant }"
when YARP::LocationField then "load_location" when YARP::LocationField then "load_location"
when YARP::OptionalLocationField then "load_optional_location" when YARP::OptionalLocationField then "load_optional_location"
when YARP::UInt32Field, YARP::FlagsField then "load_varint" when YARP::UInt32Field, YARP::FlagsField then "load_varint"

View File

@ -55,12 +55,12 @@ yp_node_destroy(yp_parser_t *parser, yp_node_t *node) {
<%- nodes.each do |node| -%> <%- nodes.each do |node| -%>
#line <%= __LINE__ + 1 %> "<%= File.basename(__FILE__) %>" #line <%= __LINE__ + 1 %> "<%= File.basename(__FILE__) %>"
case <%= node.type %>: { case <%= node.type %>: {
<%- if node.fields.any? { |field| ![YARP::LocationField, YARP::OptionalLocationField, YARP::UInt32Field, YARP::FlagsField, YARP::ConstantField].include?(field.class) } -%> <%- if node.fields.any? { |field| ![YARP::LocationField, YARP::OptionalLocationField, YARP::UInt32Field, YARP::FlagsField, YARP::ConstantField, YARP::OptionalConstantField].include?(field.class) } -%>
yp_<%= node.human %>_t *cast = (yp_<%= node.human %>_t *) node; yp_<%= node.human %>_t *cast = (yp_<%= node.human %>_t *) node;
<%- end -%> <%- end -%>
<%- node.fields.each do |field| -%> <%- node.fields.each do |field| -%>
<%- case field -%> <%- case field -%>
<%- when YARP::LocationField, YARP::OptionalLocationField, YARP::UInt32Field, YARP::FlagsField, YARP::ConstantField -%> <%- when YARP::LocationField, YARP::OptionalLocationField, YARP::UInt32Field, YARP::FlagsField, YARP::ConstantField, YARP::OptionalConstantField -%>
<%- when YARP::NodeField -%> <%- when YARP::NodeField -%>
yp_node_destroy(parser, (yp_node_t *)cast-><%= field.name %>); yp_node_destroy(parser, (yp_node_t *)cast-><%= field.name %>);
<%- when YARP::OptionalNodeField -%> <%- when YARP::OptionalNodeField -%>
@ -104,7 +104,7 @@ yp_node_memsize_node(yp_node_t *node, yp_memsize_t *memsize) {
memsize->memsize += sizeof(*cast); memsize->memsize += sizeof(*cast);
<%- node.fields.each do |field| -%> <%- node.fields.each do |field| -%>
<%- case field -%> <%- case field -%>
<%- when YARP::ConstantField, YARP::UInt32Field, YARP::FlagsField, YARP::LocationField, YARP::OptionalLocationField -%> <%- when YARP::ConstantField, YARP::OptionalConstantField, YARP::UInt32Field, YARP::FlagsField, YARP::LocationField, YARP::OptionalLocationField -%>
<%- when YARP::NodeField -%> <%- when YARP::NodeField -%>
yp_node_memsize_node((yp_node_t *)cast-><%= field.name %>, memsize); yp_node_memsize_node((yp_node_t *)cast-><%= field.name %>, memsize);
<%- when YARP::OptionalNodeField -%> <%- when YARP::OptionalNodeField -%>

View File

@ -49,6 +49,14 @@ prettyprint_node(yp_buffer_t *buffer, yp_parser_t *parser, yp_node_t *node) {
char <%= field.name %>_buffer[12]; char <%= field.name %>_buffer[12];
snprintf(<%= field.name %>_buffer, sizeof(<%= field.name %>_buffer), "%u", ((yp_<%= node.human %>_t *)node)-><%= field.name %>); snprintf(<%= field.name %>_buffer, sizeof(<%= field.name %>_buffer), "%u", ((yp_<%= node.human %>_t *)node)-><%= field.name %>);
yp_buffer_append_str(buffer, <%= field.name %>_buffer, strlen(<%= field.name %>_buffer)); yp_buffer_append_str(buffer, <%= field.name %>_buffer, strlen(<%= field.name %>_buffer));
<%- when YARP::OptionalConstantField -%>
if (((yp_<%= node.human %>_t *)node)-><%= field.name %> == 0) {
yp_buffer_append_str(buffer, "nil", 3);
} else {
char <%= field.name %>_buffer[12];
snprintf(<%= field.name %>_buffer, sizeof(<%= field.name %>_buffer), "%u", ((yp_<%= node.human %>_t *)node)-><%= field.name %>);
yp_buffer_append_str(buffer, <%= field.name %>_buffer, strlen(<%= field.name %>_buffer));
}
<%- when YARP::ConstantListField -%> <%- when YARP::ConstantListField -%>
yp_buffer_append_str(buffer, "[", 1); yp_buffer_append_str(buffer, "[", 1);
for (uint32_t index = 0; index < ((yp_<%= node.human %>_t *)node)-><%= field.name %>.size; index++) { for (uint32_t index = 0; index < ((yp_<%= node.human %>_t *)node)-><%= field.name %>.size; index++) {

View File

@ -86,7 +86,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
for (uint32_t index = 0; index < <%= field.name %>_size; index++) { for (uint32_t index = 0; index < <%= field.name %>_size; index++) {
yp_serialize_node(parser, (yp_node_t *) ((yp_<%= node.human %>_t *)node)-><%= field.name %>.nodes[index], buffer); yp_serialize_node(parser, (yp_node_t *) ((yp_<%= node.human %>_t *)node)-><%= field.name %>.nodes[index], buffer);
} }
<%- when YARP::ConstantField -%> <%- when YARP::ConstantField, YARP::OptionalConstantField -%>
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_<%= node.human %>_t *)node)-><%= field.name %>)); yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_<%= node.human %>_t *)node)-><%= field.name %>));
<%- when YARP::ConstantListField -%> <%- when YARP::ConstantListField -%>
uint32_t <%= field.name %>_size = yp_sizet_to_u32(((yp_<%= node.human %>_t *)node)-><%= field.name %>.size); uint32_t <%= field.name %>_size = yp_sizet_to_u32(((yp_<%= node.human %>_t *)node)-><%= field.name %>.size);

View File

@ -85,6 +85,18 @@ module YARP
end end
end end
# This represents a field on a node that is the ID of a string interned
# through the parser's constant pool and can be optionally null.
class OptionalConstantField < Field
def rbs_class
"Symbol?"
end
def java_type
"byte[]"
end
end
# This represents a field on a node that is a list of IDs that are associated # This represents a field on a node that is a list of IDs that are associated
# with strings interned through the parser's constant pool. # with strings interned through the parser's constant pool.
class ConstantListField < Field class ConstantListField < Field
@ -195,6 +207,7 @@ module YARP
when "node[]" then NodeListField when "node[]" then NodeListField
when "string" then StringField when "string" then StringField
when "constant" then ConstantField when "constant" then ConstantField
when "constant?" then OptionalConstantField
when "constant[]" then ConstantListField when "constant[]" then ConstantListField
when "location" then LocationField when "location" then LocationField
when "location?" then OptionalLocationField when "location?" then OptionalLocationField
@ -275,7 +288,8 @@ module YARP
HEADING HEADING
heading = if File.extname(filepath.gsub(".erb", "")) == ".rb" heading =
if File.extname(filepath.gsub(".erb", "")) == ".rb"
ruby_heading ruby_heading
else else
non_ruby_heading non_ruby_heading

View File

@ -437,6 +437,13 @@ yp_parser_constant_id_token(yp_parser_t *parser, const yp_token_t *token) {
return yp_parser_constant_id_location(parser, token->start, token->end); return yp_parser_constant_id_location(parser, token->start, token->end);
} }
// Retrieve the constant pool id for the given token. If the token is not
// provided, then return 0.
static inline yp_constant_id_t
yp_parser_optional_constant_id_token(yp_parser_t *parser, const yp_token_t *token) {
return token->type == YP_TOKEN_NOT_PROVIDED ? 0 : yp_parser_constant_id_token(parser, token);
}
// Mark any range nodes in this subtree as flipflops. // Mark any range nodes in this subtree as flipflops.
static void static void
yp_flip_flop(yp_node_t *node) { yp_flip_flop(yp_node_t *node) {
@ -1134,6 +1141,7 @@ yp_block_parameter_node_create(yp_parser_t *parser, const yp_token_t *name, cons
.end = (name->type == YP_TOKEN_NOT_PROVIDED ? operator->end : name->end) .end = (name->type == YP_TOKEN_NOT_PROVIDED ? operator->end : name->end)
}, },
}, },
.name = yp_parser_optional_constant_id_token(parser, name),
.name_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(name), .name_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(name),
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator) .operator_loc = YP_LOCATION_TOKEN_VALUE(operator)
}; };