class Opal::Rewriters::LogicalOperatorAssignment
def self.new_temp
def self.new_temp @@counter ||= 0 @@counter += 1 :"$logical_op_recvr_tmp_#{@@counter}" end
def self.reset_tmp_counter!
def self.reset_tmp_counter! @@counter = 0 end
def on_and_asgn(node)
def on_and_asgn(node) lhs, rhs = *node result = HANDLERS .fetch(lhs.type) { error "cannot handle LHS type: #{lhs.type}" } .call(lhs, rhs, :and) process(result) end
def on_defined?(node)
`defined?(a &&= 1)`
and
`defined?(a ||= 1)`
Rewrites any or_asgn and and_asgn node like
def on_defined?(node) inner, _ = *node if %i[or_asgn and_asgn].include?(inner.type) ASSIGNMENT_STRING_NODE else super(node) end end
def on_or_asgn(node)
def on_or_asgn(node) lhs, rhs = *node result = HANDLERS .fetch(lhs.type) { error "cannot handle LHS type: #{lhs.type}" } .call(lhs, rhs, :or) process(result) end