aboutsummaryrefslogtreecommitdiffstats
path: root/lib/yarp
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-08-30 15:28:10 -0400
committergit <svn-admin@ruby-lang.org>2023-08-30 19:59:28 +0000
commit00dbee94ac71527cffbfa959a99f17457eb440fc (patch)
treebc05023d97aa0abe6a50b0e2a08a3db066a5fbd4 /lib/yarp
parent151e94fee5a54f07fa031942de72009c7f7b1d1d (diff)
downloadruby-00dbee94ac71527cffbfa959a99f17457eb440fc.tar.gz
[ruby/yarp] Add class variables to the constant pool
https://github.com/ruby/yarp/commit/be5cb60c83
Diffstat (limited to 'lib/yarp')
-rw-r--r--lib/yarp/desugar_visitor.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/yarp/desugar_visitor.rb b/lib/yarp/desugar_visitor.rb
index 8fe488368e..d0c0494e0c 100644
--- a/lib/yarp/desugar_visitor.rb
+++ b/lib/yarp/desugar_visitor.rb
@@ -8,7 +8,7 @@ module YARP
#
# @@foo && @@foo = bar
def visit_class_variable_and_write_node(node)
- desugar_and_write_node(node, ClassVariableReadNode, ClassVariableWriteNode)
+ desugar_and_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, arguments: [node.name])
end
# @@foo ||= bar
@@ -17,7 +17,7 @@ module YARP
#
# defined?(@@foo) ? @@foo : @@foo = bar
def visit_class_variable_or_write_node(node)
- desugar_or_write_defined_node(node, ClassVariableReadNode, ClassVariableWriteNode)
+ desugar_or_write_defined_node(node, ClassVariableReadNode, ClassVariableWriteNode, arguments: [node.name])
end
# @@foo += bar
@@ -26,7 +26,7 @@ module YARP
#
# @@foo = @@foo + bar
def visit_class_variable_operator_write_node(node)
- desugar_operator_write_node(node, ClassVariableReadNode, ClassVariableWriteNode)
+ desugar_operator_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, arguments: [node.name])
end
# Foo &&= bar
@@ -245,15 +245,15 @@ module YARP
end
# Don't desugar `x ||= y` to `defined?(x) ? x : x = y`
- def desugar_or_write_defined_node(node, read_class, write_class)
+ def desugar_or_write_defined_node(node, read_class, write_class, arguments: [])
IfNode.new(
node.operator_loc,
- DefinedNode.new(nil, read_class.new(node.name_loc), nil, node.operator_loc, node.name_loc),
- StatementsNode.new([read_class.new(node.name_loc)], node.location),
+ DefinedNode.new(nil, read_class.new(*arguments, node.name_loc), nil, node.operator_loc, node.name_loc),
+ StatementsNode.new([read_class.new(*arguments, node.name_loc)], node.location),
ElseNode.new(
node.operator_loc,
StatementsNode.new(
- [write_class.new(node.name_loc, node.value, node.operator_loc, node.location)],
+ [write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location)],
node.location
),
node.operator_loc,