123456789_123456789_123456789_123456789_123456789_

Class: Prism::DesugarAndWriteNode

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, DSL
Inherits: Object
Defined in: lib/prism/desugar_compiler.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

DSL - Included

#alias_global_variable_node

Create a new AliasGlobalVariableNode node.

#alias_method_node

Create a new AliasMethodNode node.

#alternation_pattern_node

Create a new AlternationPatternNode node.

#and_node

Create a new AndNode node.

#arguments_node

Create a new ArgumentsNode node.

#arguments_node_flag

Retrieve the value of one of the ArgumentsNodeFlags flags.

#array_node

Create a new ArrayNode node.

#array_node_flag

Retrieve the value of one of the ArrayNodeFlags flags.

#array_pattern_node

Create a new ArrayPatternNode node.

#assoc_node

Create a new AssocNode node.

#assoc_splat_node

Create a new AssocSplatNode node.

#back_reference_read_node

Create a new BackReferenceReadNode node.

#begin_node

Create a new BeginNode node.

#block_argument_node

Create a new BlockArgumentNode node.

#block_local_variable_node

Create a new BlockLocalVariableNode node.

#block_node

Create a new BlockNode node.

#block_parameter_node

Create a new BlockParameterNode node.

#block_parameters_node

Create a new BlockParametersNode node.

#break_node

Create a new BreakNode node.

#call_and_write_node

Create a new CallAndWriteNode node.

#call_node

Create a new CallNode node.

#call_node_flag

Retrieve the value of one of the CallNodeFlags flags.

#call_operator_write_node

Create a new CallOperatorWriteNode node.

#call_or_write_node

Create a new CallOrWriteNode node.

#call_target_node

Create a new CallTargetNode node.

#capture_pattern_node

Create a new CapturePatternNode node.

#case_match_node

Create a new CaseMatchNode node.

#case_node

Create a new CaseNode node.

#class_node

Create a new ClassNode node.

#class_variable_and_write_node

Create a new ClassVariableAndWriteNode node.

#class_variable_operator_write_node
#class_variable_or_write_node

Create a new ClassVariableOrWriteNode node.

#class_variable_read_node

Create a new ClassVariableReadNode node.

#class_variable_target_node

Create a new ClassVariableTargetNode node.

#class_variable_write_node

Create a new ClassVariableWriteNode node.

#constant_and_write_node

Create a new ConstantAndWriteNode node.

#constant_operator_write_node

Create a new ConstantOperatorWriteNode node.

#constant_or_write_node

Create a new ConstantOrWriteNode node.

#constant_path_and_write_node

Create a new ConstantPathAndWriteNode node.

#constant_path_node

Create a new ConstantPathNode node.

#constant_path_operator_write_node
#constant_path_or_write_node

Create a new ConstantPathOrWriteNode node.

#constant_path_target_node

Create a new ConstantPathTargetNode node.

#constant_path_write_node

Create a new ConstantPathWriteNode node.

#constant_read_node

Create a new ConstantReadNode node.

#constant_target_node

Create a new ConstantTargetNode node.

#constant_write_node

Create a new ConstantWriteNode node.

#def_node

Create a new DefNode node.

#defined_node

Create a new DefinedNode node.

#else_node

Create a new ElseNode node.

#embedded_statements_node

Create a new EmbeddedStatementsNode node.

#embedded_variable_node

Create a new EmbeddedVariableNode node.

#encoding_flag

Retrieve the value of one of the EncodingFlags flags.

#ensure_node

Create a new EnsureNode node.

#false_node

Create a new FalseNode node.

#find_pattern_node

Create a new FindPatternNode node.

#flip_flop_node

Create a new FlipFlopNode node.

#float_node

Create a new FloatNode node.

#for_node

Create a new ForNode node.

#forwarding_arguments_node

Create a new ForwardingArgumentsNode node.

#forwarding_parameter_node

Create a new ForwardingParameterNode node.

#forwarding_super_node

Create a new ForwardingSuperNode node.

#global_variable_and_write_node

Create a new GlobalVariableAndWriteNode node.

#global_variable_operator_write_node
#global_variable_or_write_node

Create a new GlobalVariableOrWriteNode node.

#global_variable_read_node

Create a new GlobalVariableReadNode node.

#global_variable_target_node

Create a new GlobalVariableTargetNode node.

#global_variable_write_node

Create a new GlobalVariableWriteNode node.

#hash_node

Create a new HashNode node.

#hash_pattern_node

Create a new HashPatternNode node.

#if_node

Create a new IfNode node.

#imaginary_node

Create a new ImaginaryNode node.

#implicit_node

Create a new ImplicitNode node.

#implicit_rest_node

Create a new ImplicitRestNode node.

#in_node

Create a new InNode node.

#index_and_write_node

Create a new IndexAndWriteNode node.

#index_operator_write_node

Create a new IndexOperatorWriteNode node.

#index_or_write_node

Create a new IndexOrWriteNode node.

#index_target_node

Create a new IndexTargetNode node.

#instance_variable_and_write_node

Create a new InstanceVariableAndWriteNode node.

#instance_variable_operator_write_node
#instance_variable_or_write_node

Create a new InstanceVariableOrWriteNode node.

#instance_variable_read_node

Create a new InstanceVariableReadNode node.

#instance_variable_target_node

Create a new InstanceVariableTargetNode node.

#instance_variable_write_node

Create a new InstanceVariableWriteNode node.

#integer_base_flag

Retrieve the value of one of the IntegerBaseFlags flags.

#integer_node

Create a new IntegerNode node.

#interpolated_match_last_line_node
#interpolated_regular_expression_node
#interpolated_string_node

Create a new InterpolatedStringNode node.

#interpolated_string_node_flag

Retrieve the value of one of the InterpolatedStringNodeFlags flags.

#interpolated_symbol_node

Create a new InterpolatedSymbolNode node.

#interpolated_x_string_node

Create a new InterpolatedXStringNode node.

#it_local_variable_read_node

Create a new ItLocalVariableReadNode node.

#it_parameters_node

Create a new ItParametersNode node.

#keyword_hash_node

Create a new KeywordHashNode node.

#keyword_hash_node_flag

Retrieve the value of one of the KeywordHashNodeFlags flags.

#keyword_rest_parameter_node

Create a new KeywordRestParameterNode node.

#lambda_node

Create a new LambdaNode node.

#local_variable_and_write_node

Create a new LocalVariableAndWriteNode node.

#local_variable_operator_write_node
#local_variable_or_write_node

Create a new LocalVariableOrWriteNode node.

#local_variable_read_node

Create a new LocalVariableReadNode node.

#local_variable_target_node

Create a new LocalVariableTargetNode node.

#local_variable_write_node

Create a new LocalVariableWriteNode node.

#location

Create a new Location object.

#loop_flag

Retrieve the value of one of the LoopFlags flags.

#match_last_line_node

Create a new MatchLastLineNode node.

#match_predicate_node

Create a new MatchPredicateNode node.

#match_required_node

Create a new MatchRequiredNode node.

#match_write_node

Create a new MatchWriteNode node.

#missing_node

Create a new MissingNode node.

#module_node

Create a new ModuleNode node.

#multi_target_node

Create a new MultiTargetNode node.

#multi_write_node

Create a new MultiWriteNode node.

#next_node

Create a new NextNode node.

#nil_node

Create a new NilNode node.

#no_keywords_parameter_node

Create a new NoKeywordsParameterNode node.

#numbered_parameters_node

Create a new NumberedParametersNode node.

#numbered_reference_read_node

Create a new NumberedReferenceReadNode node.

#optional_keyword_parameter_node

Create a new OptionalKeywordParameterNode node.

#optional_parameter_node

Create a new OptionalParameterNode node.

#or_node

Create a new OrNode node.

#parameter_flag

Retrieve the value of one of the ParameterFlags flags.

#parameters_node

Create a new ParametersNode node.

#parentheses_node

Create a new ParenthesesNode node.

#pinned_expression_node

Create a new PinnedExpressionNode node.

#pinned_variable_node

Create a new PinnedVariableNode node.

#post_execution_node

Create a new PostExecutionNode node.

#pre_execution_node

Create a new PreExecutionNode node.

#program_node

Create a new ProgramNode node.

#range_flag

Retrieve the value of one of the RangeFlags flags.

#range_node

Create a new RangeNode node.

#rational_node

Create a new RationalNode node.

#redo_node

Create a new RedoNode node.

#regular_expression_flag

Retrieve the value of one of the RegularExpressionFlags flags.

#regular_expression_node

Create a new RegularExpressionNode node.

#required_keyword_parameter_node

Create a new RequiredKeywordParameterNode node.

#required_parameter_node

Create a new RequiredParameterNode node.

#rescue_modifier_node

Create a new RescueModifierNode node.

#rescue_node

Create a new RescueNode node.

#rest_parameter_node

Create a new RestParameterNode node.

#retry_node

Create a new RetryNode node.

#return_node

Create a new ReturnNode node.

#self_node

Create a new SelfNode node.

#shareable_constant_node

Create a new ShareableConstantNode node.

#shareable_constant_node_flag

Retrieve the value of one of the ShareableConstantNodeFlags flags.

#singleton_class_node

Create a new SingletonClassNode node.

#source

Create a new Source object.

#source_encoding_node

Create a new SourceEncodingNode node.

#source_file_node

Create a new SourceFileNode node.

#source_line_node

Create a new SourceLineNode node.

#splat_node

Create a new SplatNode node.

#statements_node

Create a new StatementsNode node.

#string_flag

Retrieve the value of one of the StringFlags flags.

#string_node

Create a new StringNode node.

#super_node

Create a new SuperNode node.

#symbol_flag

Retrieve the value of one of the SymbolFlags flags.

#symbol_node

Create a new SymbolNode node.

#true_node

Create a new TrueNode node.

#undef_node

Create a new UndefNode node.

#unless_node

Create a new UnlessNode node.

#until_node

Create a new UntilNode node.

#when_node

Create a new WhenNode node.

#while_node

Create a new WhileNode node.

#x_string_node

Create a new XStringNode node.

#yield_node

Create a new YieldNode node.

#default_location

The default location object that gets attached to nodes if no location is specified, which uses the given source.

#default_node

The default node that gets attached to nodes if no node is specified for a required node field.

#default_source

The default source object that gets attached to nodes and locations if no source is specified.

Constructor Details

.new(node, default_source, read_class, write_class, **arguments) ⇒ DesugarAndWriteNode

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 10

def initialize(node, default_source, read_class, write_class, **arguments)
  @node = node
  @default_source = default_source
  @read_class = read_class
  @write_class = write_class
  @arguments = arguments
end

Instance Attribute Details

#arguments (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 8

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#default_source (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 8

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#node (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 8

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#read_class (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 8

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#write_class (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 8

attr_reader :node, :default_source, :read_class, :write_class, :arguments

Instance Method Details

#compile

Desugar x &&= y to x && x = y

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 19

def compile
  and_node(
    location: node.location,
    left: public_send(read_class, location: node.name_loc, **arguments),
    right: public_send(
      write_class,
      location: node.location,
      **arguments,
      name_loc: node.name_loc,
      value: node.value,
      operator_loc: node.operator_loc
    ),
    operator_loc: node.operator_loc
  )
end