[ruby/yarp] Add instance variable names to the constant pool
https://github.com/ruby/yarp/commit/f049932c44
This commit is contained in:
parent
455153705c
commit
b435161404
@ -173,8 +173,8 @@ module YARP
|
|||||||
# @foo && @foo = bar
|
# @foo && @foo = bar
|
||||||
def visit_instance_variable_and_write_node(node)
|
def visit_instance_variable_and_write_node(node)
|
||||||
AndNode.new(
|
AndNode.new(
|
||||||
InstanceVariableReadNode.new(node.name_loc),
|
InstanceVariableReadNode.new(node.name, node.name_loc),
|
||||||
InstanceVariableWriteNode.new(node.name_loc, node.value, node.operator_loc, node.location),
|
InstanceVariableWriteNode.new(node.name, node.name_loc, node.value, node.operator_loc, node.location),
|
||||||
node.operator_loc,
|
node.operator_loc,
|
||||||
node.location
|
node.location
|
||||||
)
|
)
|
||||||
@ -187,8 +187,8 @@ module YARP
|
|||||||
# @foo || @foo = bar
|
# @foo || @foo = bar
|
||||||
def visit_instance_variable_or_write_node(node)
|
def visit_instance_variable_or_write_node(node)
|
||||||
OrNode.new(
|
OrNode.new(
|
||||||
InstanceVariableReadNode.new(node.name_loc),
|
InstanceVariableReadNode.new(node.name, node.name_loc),
|
||||||
InstanceVariableWriteNode.new(node.name_loc, node.value, node.operator_loc, node.location),
|
InstanceVariableWriteNode.new(node.name, node.name_loc, node.value, node.operator_loc, node.location),
|
||||||
node.operator_loc,
|
node.operator_loc,
|
||||||
node.location
|
node.location
|
||||||
)
|
)
|
||||||
@ -200,7 +200,7 @@ module YARP
|
|||||||
#
|
#
|
||||||
# @foo = @foo + bar
|
# @foo = @foo + bar
|
||||||
def visit_instance_variable_operator_write_node(node)
|
def visit_instance_variable_operator_write_node(node)
|
||||||
desugar_operator_write_node(node, InstanceVariableWriteNode, InstanceVariableReadNode)
|
desugar_operator_write_node(node, InstanceVariableWriteNode, InstanceVariableReadNode, arguments: [node.name])
|
||||||
end
|
end
|
||||||
|
|
||||||
# foo &&= bar
|
# foo &&= bar
|
||||||
|
@ -199,7 +199,7 @@ ProgramNode(0...1194)(
|
|||||||
),
|
),
|
||||||
DefNode(190...204)(
|
DefNode(190...204)(
|
||||||
(199...200),
|
(199...200),
|
||||||
InstanceVariableReadNode(194...198)(),
|
InstanceVariableReadNode(194...198)(:var),
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
[],
|
[],
|
||||||
|
@ -923,7 +923,7 @@ ProgramNode(0...3743)(
|
|||||||
"foo"
|
"foo"
|
||||||
),
|
),
|
||||||
PinnedVariableNode(961...966)(
|
PinnedVariableNode(961...966)(
|
||||||
InstanceVariableReadNode(962...966)(),
|
InstanceVariableReadNode(962...966)(:bar),
|
||||||
(961...962)
|
(961...962)
|
||||||
),
|
),
|
||||||
(958...960)
|
(958...960)
|
||||||
|
@ -494,7 +494,7 @@ ProgramNode(0...747)(
|
|||||||
ArrayPatternNode(627...643)(
|
ArrayPatternNode(627...643)(
|
||||||
nil,
|
nil,
|
||||||
[PinnedVariableNode(628...631)(
|
[PinnedVariableNode(628...631)(
|
||||||
InstanceVariableReadNode(629...631)(),
|
InstanceVariableReadNode(629...631)(:a),
|
||||||
(628...629)
|
(628...629)
|
||||||
),
|
),
|
||||||
PinnedVariableNode(633...636)(
|
PinnedVariableNode(633...636)(
|
||||||
|
@ -6,7 +6,7 @@ ProgramNode(0...5)(
|
|||||||
[StringNode(6...11)(nil, (6...11), nil, "foo\r"),
|
[StringNode(6...11)(nil, (6...11), nil, "foo\r"),
|
||||||
EmbeddedVariableNode(11...16)(
|
EmbeddedVariableNode(11...16)(
|
||||||
(11...12),
|
(11...12),
|
||||||
InstanceVariableReadNode(12...16)()
|
InstanceVariableReadNode(12...16)(:bar)
|
||||||
),
|
),
|
||||||
StringNode(16...17)(nil, (16...17), nil, "\n")],
|
StringNode(16...17)(nil, (16...17), nil, "\n")],
|
||||||
(17...21)
|
(17...21)
|
||||||
|
@ -6,7 +6,7 @@ ProgramNode(0...5)(
|
|||||||
[StringNode(7...12)(nil, (7...12), nil, "foo\r"),
|
[StringNode(7...12)(nil, (7...12), nil, "foo\r"),
|
||||||
EmbeddedVariableNode(12...17)(
|
EmbeddedVariableNode(12...17)(
|
||||||
(12...13),
|
(12...13),
|
||||||
InstanceVariableReadNode(13...17)()
|
InstanceVariableReadNode(13...17)(:bar)
|
||||||
),
|
),
|
||||||
StringNode(17...19)(nil, (17...19), nil, "\r\n")],
|
StringNode(17...19)(nil, (17...19), nil, "\r\n")],
|
||||||
(19...24)
|
(19...24)
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
ProgramNode(0...7)(
|
ProgramNode(0...7)(
|
||||||
[],
|
[],
|
||||||
StatementsNode(0...7)(
|
StatementsNode(0...7)(
|
||||||
[InstanceVariableWriteNode(0...7)((0...2), IntegerNode(5...7)(), (3...4))]
|
[InstanceVariableWriteNode(0...7)(
|
||||||
|
:a,
|
||||||
|
(0...2),
|
||||||
|
IntegerNode(5...7)(),
|
||||||
|
(3...4)
|
||||||
|
)]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,7 @@ ProgramNode(0...4)(
|
|||||||
nil,
|
nil,
|
||||||
(0...1),
|
(0...1),
|
||||||
nil,
|
nil,
|
||||||
ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)()]),
|
ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)(:b)]),
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
0,
|
0,
|
||||||
|
@ -6,7 +6,7 @@ ProgramNode(0...6)(
|
|||||||
nil,
|
nil,
|
||||||
(0...1),
|
(0...1),
|
||||||
(1...2),
|
(1...2),
|
||||||
ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)()]),
|
ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)(:b)]),
|
||||||
(5...6),
|
(5...6),
|
||||||
nil,
|
nil,
|
||||||
0,
|
0,
|
||||||
|
@ -185,7 +185,7 @@ ProgramNode(0...498)(
|
|||||||
(414...415),
|
(414...415),
|
||||||
[EmbeddedVariableNode(415...420)(
|
[EmbeddedVariableNode(415...420)(
|
||||||
(415...416),
|
(415...416),
|
||||||
InstanceVariableReadNode(416...420)()
|
InstanceVariableReadNode(416...420)(:foo)
|
||||||
)],
|
)],
|
||||||
(420...421)
|
(420...421)
|
||||||
),
|
),
|
||||||
|
@ -66,8 +66,8 @@ ProgramNode(0...704)(
|
|||||||
(74...75)
|
(74...75)
|
||||||
),
|
),
|
||||||
MultiWriteNode(85...102)(
|
MultiWriteNode(85...102)(
|
||||||
[InstanceVariableTargetNode(86...88)(),
|
[InstanceVariableTargetNode(86...88)(:a),
|
||||||
InstanceVariableTargetNode(90...92)()],
|
InstanceVariableTargetNode(90...92)(:b)],
|
||||||
(94...95),
|
(94...95),
|
||||||
ArrayNode(96...102)(
|
ArrayNode(96...102)(
|
||||||
[IntegerNode(97...98)(), IntegerNode(100...101)()],
|
[IntegerNode(97...98)(), IntegerNode(100...101)()],
|
||||||
@ -296,6 +296,7 @@ ProgramNode(0...704)(
|
|||||||
(306...307)
|
(306...307)
|
||||||
),
|
),
|
||||||
InstanceVariableWriteNode(310...316)(
|
InstanceVariableWriteNode(310...316)(
|
||||||
|
:a,
|
||||||
(310...312),
|
(310...312),
|
||||||
IntegerNode(315...316)(),
|
IntegerNode(315...316)(),
|
||||||
(313...314)
|
(313...314)
|
||||||
@ -605,6 +606,7 @@ ProgramNode(0...704)(
|
|||||||
(543...546)
|
(543...546)
|
||||||
),
|
),
|
||||||
InstanceVariableOrWriteNode(551...561)(
|
InstanceVariableOrWriteNode(551...561)(
|
||||||
|
:a,
|
||||||
(551...553),
|
(551...553),
|
||||||
(554...557),
|
(554...557),
|
||||||
StringNode(558...561)((558...560), (560...560), (560...561), "")
|
StringNode(558...561)((558...560), (560...560), (560...561), "")
|
||||||
@ -698,6 +700,7 @@ ProgramNode(0...704)(
|
|||||||
(665...668)
|
(665...668)
|
||||||
),
|
),
|
||||||
InstanceVariableOrWriteNode(687...704)(
|
InstanceVariableOrWriteNode(687...704)(
|
||||||
|
:a,
|
||||||
(687...689),
|
(687...689),
|
||||||
(690...693),
|
(690...693),
|
||||||
InterpolatedStringNode(694...704)(
|
InterpolatedStringNode(694...704)(
|
||||||
|
@ -3,7 +3,7 @@ ProgramNode(0...56)(
|
|||||||
StatementsNode(0...56)(
|
StatementsNode(0...56)(
|
||||||
[DefinedNode(0...14)(
|
[DefinedNode(0...14)(
|
||||||
(8...9),
|
(8...9),
|
||||||
InstanceVariableReadNode(9...13)(),
|
InstanceVariableReadNode(9...13)(:foo),
|
||||||
(13...14),
|
(13...14),
|
||||||
(0...8)
|
(0...8)
|
||||||
),
|
),
|
||||||
|
@ -75,7 +75,7 @@ ProgramNode(0...299)(
|
|||||||
[StringNode(160...161)(nil, (160...161), nil, "a"),
|
[StringNode(160...161)(nil, (160...161), nil, "a"),
|
||||||
EmbeddedVariableNode(161...164)(
|
EmbeddedVariableNode(161...164)(
|
||||||
(161...162),
|
(161...162),
|
||||||
InstanceVariableReadNode(162...164)()
|
InstanceVariableReadNode(162...164)(:a)
|
||||||
)],
|
)],
|
||||||
(164...165)
|
(164...165)
|
||||||
),
|
),
|
||||||
|
@ -153,7 +153,7 @@ ProgramNode(0...916)(
|
|||||||
(206...207),
|
(206...207),
|
||||||
[EmbeddedVariableNode(207...210)(
|
[EmbeddedVariableNode(207...210)(
|
||||||
(207...208),
|
(207...208),
|
||||||
InstanceVariableReadNode(208...210)()
|
InstanceVariableReadNode(208...210)(:a)
|
||||||
),
|
),
|
||||||
StringNode(210...211)(nil, (210...211), nil, " "),
|
StringNode(210...211)(nil, (210...211), nil, " "),
|
||||||
EmbeddedVariableNode(211...215)(
|
EmbeddedVariableNode(211...215)(
|
||||||
@ -267,7 +267,9 @@ ProgramNode(0...916)(
|
|||||||
[StringNode(419...422)(nil, (419...422), nil, "foo"),
|
[StringNode(419...422)(nil, (419...422), nil, "foo"),
|
||||||
EmbeddedStatementsNode(422...429)(
|
EmbeddedStatementsNode(422...429)(
|
||||||
(422...424),
|
(422...424),
|
||||||
StatementsNode(424...428)([InstanceVariableReadNode(424...428)()]),
|
StatementsNode(424...428)(
|
||||||
|
[InstanceVariableReadNode(424...428)(:bar)]
|
||||||
|
),
|
||||||
(428...429)
|
(428...429)
|
||||||
)],
|
)],
|
||||||
(429...430)
|
(429...430)
|
||||||
@ -300,7 +302,9 @@ ProgramNode(0...916)(
|
|||||||
[StringNode(516...519)(nil, (516...519), nil, "foo"),
|
[StringNode(516...519)(nil, (516...519), nil, "foo"),
|
||||||
EmbeddedStatementsNode(519...526)(
|
EmbeddedStatementsNode(519...526)(
|
||||||
(519...521),
|
(519...521),
|
||||||
StatementsNode(521...525)([InstanceVariableReadNode(521...525)()]),
|
StatementsNode(521...525)(
|
||||||
|
[InstanceVariableReadNode(521...525)(:bar)]
|
||||||
|
),
|
||||||
(525...526)
|
(525...526)
|
||||||
)],
|
)],
|
||||||
(526...527),
|
(526...527),
|
||||||
@ -311,7 +315,9 @@ ProgramNode(0...916)(
|
|||||||
[StringNode(529...532)(nil, (529...532), nil, "foo"),
|
[StringNode(529...532)(nil, (529...532), nil, "foo"),
|
||||||
EmbeddedStatementsNode(532...539)(
|
EmbeddedStatementsNode(532...539)(
|
||||||
(532...534),
|
(532...534),
|
||||||
StatementsNode(534...538)([InstanceVariableReadNode(534...538)()]),
|
StatementsNode(534...538)(
|
||||||
|
[InstanceVariableReadNode(534...538)(:bar)]
|
||||||
|
),
|
||||||
(538...539)
|
(538...539)
|
||||||
)],
|
)],
|
||||||
(539...543),
|
(539...543),
|
||||||
@ -501,7 +507,7 @@ ProgramNode(0...916)(
|
|||||||
[IntegerNode(693...694)(),
|
[IntegerNode(693...694)(),
|
||||||
SplatNode(696...701)(
|
SplatNode(696...701)(
|
||||||
(696...697),
|
(696...697),
|
||||||
InstanceVariableReadNode(697...701)()
|
InstanceVariableReadNode(697...701)(:foo)
|
||||||
)],
|
)],
|
||||||
(692...693),
|
(692...693),
|
||||||
(701...702)
|
(701...702)
|
||||||
@ -509,7 +515,7 @@ ProgramNode(0...916)(
|
|||||||
ArrayNode(703...713)(
|
ArrayNode(703...713)(
|
||||||
[SplatNode(704...709)(
|
[SplatNode(704...709)(
|
||||||
(704...705),
|
(704...705),
|
||||||
InstanceVariableReadNode(705...709)()
|
InstanceVariableReadNode(705...709)(:foo)
|
||||||
),
|
),
|
||||||
IntegerNode(711...712)()],
|
IntegerNode(711...712)()],
|
||||||
(703...704),
|
(703...704),
|
||||||
@ -518,11 +524,11 @@ ProgramNode(0...916)(
|
|||||||
ArrayNode(714...728)(
|
ArrayNode(714...728)(
|
||||||
[SplatNode(715...720)(
|
[SplatNode(715...720)(
|
||||||
(715...716),
|
(715...716),
|
||||||
InstanceVariableReadNode(716...720)()
|
InstanceVariableReadNode(716...720)(:foo)
|
||||||
),
|
),
|
||||||
SplatNode(722...727)(
|
SplatNode(722...727)(
|
||||||
(722...723),
|
(722...723),
|
||||||
InstanceVariableReadNode(723...727)()
|
InstanceVariableReadNode(723...727)(:baz)
|
||||||
)],
|
)],
|
||||||
(714...715),
|
(714...715),
|
||||||
(727...728)
|
(727...728)
|
||||||
|
@ -2,7 +2,7 @@ ProgramNode(0...66)(
|
|||||||
[],
|
[],
|
||||||
StatementsNode(0...66)(
|
StatementsNode(0...66)(
|
||||||
[CallNode(0...1)(nil, nil, (0...1), nil, nil, nil, nil, 2, "a"),
|
[CallNode(0...1)(nil, nil, (0...1), nil, nil, nil, nil, 2, "a"),
|
||||||
InstanceVariableReadNode(2...4)(),
|
InstanceVariableReadNode(2...4)(:a),
|
||||||
ClassVariableReadNode(5...8)(),
|
ClassVariableReadNode(5...8)(),
|
||||||
GlobalVariableReadNode(9...11)(),
|
GlobalVariableReadNode(9...11)(),
|
||||||
NumberedReferenceReadNode(12...14)(),
|
NumberedReferenceReadNode(12...14)(),
|
||||||
|
@ -207,7 +207,9 @@ ProgramNode(0...608)(
|
|||||||
[StringNode(563...564)(nil, (563...564), nil, "a"),
|
[StringNode(563...564)(nil, (563...564), nil, "a"),
|
||||||
EmbeddedStatementsNode(564...569)(
|
EmbeddedStatementsNode(564...569)(
|
||||||
(564...566),
|
(564...566),
|
||||||
StatementsNode(566...568)([InstanceVariableReadNode(566...568)()]),
|
StatementsNode(566...568)(
|
||||||
|
[InstanceVariableReadNode(566...568)(:a)]
|
||||||
|
),
|
||||||
(568...569)
|
(568...569)
|
||||||
)],
|
)],
|
||||||
(569...570)
|
(569...570)
|
||||||
@ -220,7 +222,7 @@ ProgramNode(0...608)(
|
|||||||
[StringNode(576...577)(nil, (576...577), nil, "a"),
|
[StringNode(576...577)(nil, (576...577), nil, "a"),
|
||||||
EmbeddedVariableNode(577...580)(
|
EmbeddedVariableNode(577...580)(
|
||||||
(577...578),
|
(577...578),
|
||||||
InstanceVariableReadNode(578...580)()
|
InstanceVariableReadNode(578...580)(:a)
|
||||||
)],
|
)],
|
||||||
(580...581)
|
(580...581)
|
||||||
),
|
),
|
||||||
|
@ -15,7 +15,7 @@ ProgramNode(0...131)(
|
|||||||
(71...74),
|
(71...74),
|
||||||
[EmbeddedStatementsNode(74...81)(
|
[EmbeddedStatementsNode(74...81)(
|
||||||
(74...76),
|
(74...76),
|
||||||
StatementsNode(76...80)([InstanceVariableReadNode(76...80)()]),
|
StatementsNode(76...80)([InstanceVariableReadNode(76...80)(:bar)]),
|
||||||
(80...81)
|
(80...81)
|
||||||
),
|
),
|
||||||
StringNode(81...84)(nil, (81...84), nil, "baz")],
|
StringNode(81...84)(nil, (81...84), nil, "baz")],
|
||||||
|
@ -30,8 +30,9 @@ ProgramNode(0...293)(
|
|||||||
IntegerNode(57...58)()
|
IntegerNode(57...58)()
|
||||||
),
|
),
|
||||||
GlobalVariableReadNode(60...64)(),
|
GlobalVariableReadNode(60...64)(),
|
||||||
InstanceVariableReadNode(66...70)(),
|
InstanceVariableReadNode(66...70)(:abc),
|
||||||
InstanceVariableWriteNode(72...80)(
|
InstanceVariableWriteNode(72...80)(
|
||||||
|
:abc,
|
||||||
(72...76),
|
(72...76),
|
||||||
IntegerNode(79...80)(),
|
IntegerNode(79...80)(),
|
||||||
(77...78)
|
(77...78)
|
||||||
@ -62,14 +63,15 @@ ProgramNode(0...293)(
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
MultiWriteNode(123...137)(
|
MultiWriteNode(123...137)(
|
||||||
[InstanceVariableTargetNode(123...127)(),
|
[InstanceVariableTargetNode(123...127)(:foo),
|
||||||
InstanceVariableTargetNode(129...133)()],
|
InstanceVariableTargetNode(129...133)(:bar)],
|
||||||
(134...135),
|
(134...135),
|
||||||
IntegerNode(136...137)(),
|
IntegerNode(136...137)(),
|
||||||
nil,
|
nil,
|
||||||
nil
|
nil
|
||||||
),
|
),
|
||||||
InstanceVariableWriteNode(139...150)(
|
InstanceVariableWriteNode(139...150)(
|
||||||
|
:foo,
|
||||||
(139...143),
|
(139...143),
|
||||||
ArrayNode(146...150)(
|
ArrayNode(146...150)(
|
||||||
[IntegerNode(146...147)(), IntegerNode(149...150)()],
|
[IntegerNode(146...147)(), IntegerNode(149...150)()],
|
||||||
|
@ -51,7 +51,7 @@ ProgramNode(0...38)(
|
|||||||
StringNode(29...32)(nil, (29...32), nil, "foo"),
|
StringNode(29...32)(nil, (29...32), nil, "foo"),
|
||||||
EmbeddedVariableNode(32...37)(
|
EmbeddedVariableNode(32...37)(
|
||||||
(32...33),
|
(32...33),
|
||||||
InstanceVariableReadNode(33...37)()
|
InstanceVariableReadNode(33...37)(:baz)
|
||||||
)],
|
)],
|
||||||
nil
|
nil
|
||||||
)],
|
)],
|
||||||
|
@ -3,7 +3,7 @@ ProgramNode(0...42)(
|
|||||||
StatementsNode(0...42)(
|
StatementsNode(0...42)(
|
||||||
[DefinedNode(0...13)(
|
[DefinedNode(0...13)(
|
||||||
nil,
|
nil,
|
||||||
InstanceVariableReadNode(9...13)(),
|
InstanceVariableReadNode(9...13)(:foo),
|
||||||
nil,
|
nil,
|
||||||
(0...8)
|
(0...8)
|
||||||
),
|
),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ProgramNode(0...4)(
|
ProgramNode(0...4)(
|
||||||
[],
|
[],
|
||||||
StatementsNode(0...4)([InstanceVariableReadNode(0...4)()])
|
StatementsNode(0...4)([InstanceVariableReadNode(0...4)(:foo)])
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
ProgramNode(0...9)(
|
ProgramNode(0...9)(
|
||||||
[],
|
[],
|
||||||
StatementsNode(0...9)(
|
StatementsNode(0...9)(
|
||||||
[InstanceVariableWriteNode(0...9)((0...4), IntegerNode(7...9)(), (5...6))]
|
[InstanceVariableWriteNode(0...9)(
|
||||||
|
:var,
|
||||||
|
(0...4),
|
||||||
|
IntegerNode(7...9)(),
|
||||||
|
(5...6)
|
||||||
|
)]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -51,7 +51,7 @@ ProgramNode(0...139)(
|
|||||||
nil
|
nil
|
||||||
),
|
),
|
||||||
MultiWriteNode(47...65)(
|
MultiWriteNode(47...65)(
|
||||||
[InstanceVariableTargetNode(47...51)(),
|
[InstanceVariableTargetNode(47...51)(:foo),
|
||||||
ClassVariableTargetNode(53...58)()],
|
ClassVariableTargetNode(53...58)()],
|
||||||
(59...60),
|
(59...60),
|
||||||
ArrayNode(61...65)(
|
ArrayNode(61...65)(
|
||||||
|
@ -6,7 +6,7 @@ ProgramNode(0...15)(
|
|||||||
nil,
|
nil,
|
||||||
(0...1),
|
(0...1),
|
||||||
nil,
|
nil,
|
||||||
ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)()]),
|
ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)(:b)]),
|
||||||
nil,
|
nil,
|
||||||
BlockNode(5...15)(
|
BlockNode(5...15)(
|
||||||
[:c],
|
[:c],
|
||||||
|
@ -10,7 +10,7 @@ ProgramNode(0...73)(
|
|||||||
(13...19),
|
(13...19),
|
||||||
[],
|
[],
|
||||||
(20...22),
|
(20...22),
|
||||||
InstanceVariableTargetNode(23...26)(),
|
InstanceVariableTargetNode(23...26)(:ex),
|
||||||
StatementsNode(28...31)(
|
StatementsNode(28...31)(
|
||||||
[CallNode(28...31)(
|
[CallNode(28...31)(
|
||||||
nil,
|
nil,
|
||||||
|
@ -7,7 +7,7 @@ ProgramNode(0...14)(
|
|||||||
[StringNode(1...4)(nil, (1...4), nil, "foo"),
|
[StringNode(1...4)(nil, (1...4), nil, "foo"),
|
||||||
EmbeddedVariableNode(4...7)(
|
EmbeddedVariableNode(4...7)(
|
||||||
(4...5),
|
(4...5),
|
||||||
InstanceVariableReadNode(5...7)()
|
InstanceVariableReadNode(5...7)(:a)
|
||||||
)],
|
)],
|
||||||
(7...8)
|
(7...8)
|
||||||
),
|
),
|
||||||
|
@ -5,7 +5,7 @@ ProgramNode(0...14)(
|
|||||||
(0...1),
|
(0...1),
|
||||||
[EmbeddedVariableNode(1...4)(
|
[EmbeddedVariableNode(1...4)(
|
||||||
(1...2),
|
(1...2),
|
||||||
InstanceVariableReadNode(2...4)()
|
InstanceVariableReadNode(2...4)(:a)
|
||||||
),
|
),
|
||||||
StringNode(4...5)(nil, (4...5), nil, " "),
|
StringNode(4...5)(nil, (4...5), nil, " "),
|
||||||
EmbeddedVariableNode(5...9)((5...6), ClassVariableReadNode(6...9)()),
|
EmbeddedVariableNode(5...9)((5...6), ClassVariableReadNode(6...9)()),
|
||||||
|
@ -8,6 +8,7 @@ ProgramNode(0...53)(
|
|||||||
:|
|
:|
|
||||||
),
|
),
|
||||||
InstanceVariableOperatorWriteNode(13...20)(
|
InstanceVariableOperatorWriteNode(13...20)(
|
||||||
|
:a,
|
||||||
(13...15),
|
(13...15),
|
||||||
(16...18),
|
(16...18),
|
||||||
IntegerNode(19...20)(),
|
IntegerNode(19...20)(),
|
||||||
|
@ -1298,6 +1298,8 @@ nodes:
|
|||||||
^^^^^^^^^^^
|
^^^^^^^^^^^
|
||||||
- name: InstanceVariableAndWriteNode
|
- name: InstanceVariableAndWriteNode
|
||||||
child_nodes:
|
child_nodes:
|
||||||
|
- name: name
|
||||||
|
type: constant
|
||||||
- name: name_loc
|
- name: name_loc
|
||||||
type: location
|
type: location
|
||||||
- name: operator_loc
|
- name: operator_loc
|
||||||
@ -1311,6 +1313,8 @@ nodes:
|
|||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
- name: InstanceVariableOperatorWriteNode
|
- name: InstanceVariableOperatorWriteNode
|
||||||
child_nodes:
|
child_nodes:
|
||||||
|
- name: name
|
||||||
|
type: constant
|
||||||
- name: name_loc
|
- name: name_loc
|
||||||
type: location
|
type: location
|
||||||
- name: operator_loc
|
- name: operator_loc
|
||||||
@ -1326,6 +1330,8 @@ nodes:
|
|||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
- name: InstanceVariableOrWriteNode
|
- name: InstanceVariableOrWriteNode
|
||||||
child_nodes:
|
child_nodes:
|
||||||
|
- name: name
|
||||||
|
type: constant
|
||||||
- name: name_loc
|
- name: name_loc
|
||||||
type: location
|
type: location
|
||||||
- name: operator_loc
|
- name: operator_loc
|
||||||
@ -1338,12 +1344,18 @@ nodes:
|
|||||||
@target ||= value
|
@target ||= value
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
- name: InstanceVariableReadNode
|
- name: InstanceVariableReadNode
|
||||||
|
child_nodes:
|
||||||
|
- name: name
|
||||||
|
type: constant
|
||||||
comment: |
|
comment: |
|
||||||
Represents referencing an instance variable.
|
Represents referencing an instance variable.
|
||||||
|
|
||||||
@foo
|
@foo
|
||||||
^^^^
|
^^^^
|
||||||
- name: InstanceVariableTargetNode
|
- name: InstanceVariableTargetNode
|
||||||
|
child_nodes:
|
||||||
|
- name: name
|
||||||
|
type: constant
|
||||||
comment: |
|
comment: |
|
||||||
Represents writing to an instance variable in a context that doesn't have an explicit value.
|
Represents writing to an instance variable in a context that doesn't have an explicit value.
|
||||||
|
|
||||||
@ -1351,6 +1363,8 @@ nodes:
|
|||||||
^^^^ ^^^^
|
^^^^ ^^^^
|
||||||
- name: InstanceVariableWriteNode
|
- name: InstanceVariableWriteNode
|
||||||
child_nodes:
|
child_nodes:
|
||||||
|
- name: name
|
||||||
|
type: constant
|
||||||
- name: name_loc
|
- name: name_loc
|
||||||
type: location
|
type: location
|
||||||
- name: value
|
- name: value
|
||||||
|
40
yarp/yarp.c
40
yarp/yarp.c
@ -2621,8 +2621,7 @@ yp_in_node_create(yp_parser_t *parser, yp_node_t *pattern, yp_statements_node_t
|
|||||||
|
|
||||||
// Allocate and initialize a new InstanceVariableAndWriteNode node.
|
// Allocate and initialize a new InstanceVariableAndWriteNode node.
|
||||||
static yp_instance_variable_and_write_node_t *
|
static yp_instance_variable_and_write_node_t *
|
||||||
yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
|
yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
|
||||||
assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
|
|
||||||
assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
|
assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
|
||||||
yp_instance_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_and_write_node_t);
|
yp_instance_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_and_write_node_t);
|
||||||
|
|
||||||
@ -2630,11 +2629,12 @@ yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *targe
|
|||||||
{
|
{
|
||||||
.type = YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE,
|
.type = YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE,
|
||||||
.location = {
|
.location = {
|
||||||
.start = target->location.start,
|
.start = target->base.location.start,
|
||||||
.end = value->location.end
|
.end = value->location.end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.name_loc = target->location,
|
.name = target->name,
|
||||||
|
.name_loc = target->base.location,
|
||||||
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
|
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
|
||||||
.value = value
|
.value = value
|
||||||
};
|
};
|
||||||
@ -2644,18 +2644,19 @@ yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *targe
|
|||||||
|
|
||||||
// Allocate and initialize a new InstanceVariableOperatorWriteNode node.
|
// Allocate and initialize a new InstanceVariableOperatorWriteNode node.
|
||||||
static yp_instance_variable_operator_write_node_t *
|
static yp_instance_variable_operator_write_node_t *
|
||||||
yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
|
yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
|
||||||
yp_instance_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_operator_write_node_t);
|
yp_instance_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_operator_write_node_t);
|
||||||
|
|
||||||
*node = (yp_instance_variable_operator_write_node_t) {
|
*node = (yp_instance_variable_operator_write_node_t) {
|
||||||
{
|
{
|
||||||
.type = YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE,
|
.type = YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE,
|
||||||
.location = {
|
.location = {
|
||||||
.start = target->location.start,
|
.start = target->base.location.start,
|
||||||
.end = value->location.end
|
.end = value->location.end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.name_loc = target->location,
|
.name = target->name,
|
||||||
|
.name_loc = target->base.location,
|
||||||
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
|
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
|
||||||
.value = value,
|
.value = value,
|
||||||
.operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
|
.operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
|
||||||
@ -2666,8 +2667,7 @@ yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *
|
|||||||
|
|
||||||
// Allocate and initialize a new InstanceVariableOrWriteNode node.
|
// Allocate and initialize a new InstanceVariableOrWriteNode node.
|
||||||
static yp_instance_variable_or_write_node_t *
|
static yp_instance_variable_or_write_node_t *
|
||||||
yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
|
yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
|
||||||
assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
|
|
||||||
assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
|
assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
|
||||||
yp_instance_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_or_write_node_t);
|
yp_instance_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_or_write_node_t);
|
||||||
|
|
||||||
@ -2675,11 +2675,12 @@ yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target
|
|||||||
{
|
{
|
||||||
.type = YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE,
|
.type = YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE,
|
||||||
.location = {
|
.location = {
|
||||||
.start = target->location.start,
|
.start = target->base.location.start,
|
||||||
.end = value->location.end
|
.end = value->location.end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.name_loc = target->location,
|
.name = target->name,
|
||||||
|
.name_loc = target->base.location,
|
||||||
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
|
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
|
||||||
.value = value
|
.value = value
|
||||||
};
|
};
|
||||||
@ -2693,9 +2694,13 @@ yp_instance_variable_read_node_create(yp_parser_t *parser, const yp_token_t *tok
|
|||||||
assert(token->type == YP_TOKEN_INSTANCE_VARIABLE);
|
assert(token->type == YP_TOKEN_INSTANCE_VARIABLE);
|
||||||
yp_instance_variable_read_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_read_node_t);
|
yp_instance_variable_read_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_read_node_t);
|
||||||
|
|
||||||
*node = (yp_instance_variable_read_node_t) {{
|
*node = (yp_instance_variable_read_node_t) {
|
||||||
.type = YP_NODE_INSTANCE_VARIABLE_READ_NODE, .location = YP_LOCATION_TOKEN_VALUE(token)
|
{
|
||||||
}};
|
.type = YP_NODE_INSTANCE_VARIABLE_READ_NODE,
|
||||||
|
.location = YP_LOCATION_TOKEN_VALUE(token)
|
||||||
|
},
|
||||||
|
.name = yp_parser_constant_id_location(parser, token->start + 1, token->end)
|
||||||
|
};
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
@ -2712,6 +2717,7 @@ yp_instance_variable_write_node_create(yp_parser_t *parser, yp_instance_variable
|
|||||||
.end = value->location.end
|
.end = value->location.end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
.name = read_node->name,
|
||||||
.name_loc = YP_LOCATION_NODE_BASE_VALUE(read_node),
|
.name_loc = YP_LOCATION_NODE_BASE_VALUE(read_node),
|
||||||
.operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
|
.operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
|
||||||
.value = value
|
.value = value
|
||||||
@ -12821,7 +12827,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
|
|||||||
parser_lex(parser);
|
parser_lex(parser);
|
||||||
|
|
||||||
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
|
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
|
||||||
yp_node_t *result = (yp_node_t *) yp_instance_variable_and_write_node_create(parser, node, &token, value);
|
yp_node_t *result = (yp_node_t *) yp_instance_variable_and_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
|
||||||
|
|
||||||
yp_node_destroy(parser, node);
|
yp_node_destroy(parser, node);
|
||||||
return result;
|
return result;
|
||||||
@ -12922,7 +12928,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
|
|||||||
parser_lex(parser);
|
parser_lex(parser);
|
||||||
|
|
||||||
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
|
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
|
||||||
yp_node_t *result = (yp_node_t *) yp_instance_variable_or_write_node_create(parser, node, &token, value);
|
yp_node_t *result = (yp_node_t *) yp_instance_variable_or_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
|
||||||
|
|
||||||
yp_node_destroy(parser, node);
|
yp_node_destroy(parser, node);
|
||||||
return result;
|
return result;
|
||||||
@ -13033,7 +13039,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
|
|||||||
parser_lex(parser);
|
parser_lex(parser);
|
||||||
|
|
||||||
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
|
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
|
||||||
yp_node_t *result = (yp_node_t *) yp_instance_variable_operator_write_node_create(parser, node, &token, value);
|
yp_node_t *result = (yp_node_t *) yp_instance_variable_operator_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
|
||||||
|
|
||||||
yp_node_destroy(parser, node);
|
yp_node_destroy(parser, node);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user