Module: Duby::AST::CallOpAssignment

Included in:
JRubyAst::OpAsgnNode, JRubyAst::OpElementAsgnNode
Defined in:
lib/duby/transform.rb

Instance Method Summary collapse

Instance Method Details

#call_op_assignment(transformer, parent, name, args) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/duby/transform.rb', line 186

def call_op_assignment(transformer, parent, name, args)
  set_args = JRubyAst::ListNode.new(position)
  set_args.add_all(args)
  set_args.add(value_node)

  first = JRubyAst::CallNode.new(position, receiver_node, name, args)
  second = JRubyAst::AttrAssignNode.new(position, receiver_node,
                                        "#{name}=", set_args)

  if operator_name == '||'
    klass = JRubyAst::OrNode
  elsif operator_name == '&&'
    klass = JRubyAst::AndNode
  else
    raise "Unknown OpAsgn operator #{operator_name}"
  end
  transformer.transform(klass.new(position, first, second), parent)
end