class Opal::Rewriters::LogicalOperatorAssignment::ConditionalSendHandler
using SendHandler to ‘recvr.nil? ? nil : (recvr.meth || recvr.meth = rhs)`
NOTE: Later output of this handler gets post-processed by this rewriter again
Produces `recvr.nil? ? nil : recvr.meth ||= rhs`
Takes `recvr&.meth ||= rhs`
def self.call(lhs, rhs, root_type)
def self.call(lhs, rhs, root_type) root_type = :"#{root_type}_asgn" recvr, meth, *args = *lhs recvr_tmp = new_temp cache_recvr = s(:lvasgn, recvr_tmp, recvr) # $tmp = recvr recvr = s(:js_tmp, recvr_tmp) recvr_is_nil = s(:send, recvr, :nil?) # recvr.nil? plain_send = lhs.updated(:send, [recvr, meth, *args]) # recvr.meth plain_or_asgn = s(root_type, plain_send, rhs) # recvr.meth ||= rhs s(:begin, cache_recvr, s(:if, recvr_is_nil, # if recvr.nil? s(:nil), # nil # else plain_or_asgn # recvr.meth ||= rhs ), ) # end end