class Opal::Nodes::OpAsgn1Node
s(:op_asgn1, lhs, args, :||, rhs)<br>lhs ||= rhs
def compile
def compile case op.to_s when '||' then compile_or when '&&' then compile_and else compile_operator end end
def compile_and
def compile_and with_temp do |a| # args with_temp do |r| # recv aref = s(:call, s(:js_tmp, r), :[], s(:arglist, s(:js_tmp, a))) aset = s(:call, s(:js_tmp, r), :[]=, s(:arglist, s(:js_tmp, a), rhs)) andop = s(:and, aref, aset) push "(#{a} = ", expr(first_arg), ", #{r} = ", expr(lhs) push ", ", expr(andop), ")" end end end
def compile_operator
def compile_operator with_temp do |a| # args with_temp do |r| # recv cur = s(:call, s(:js_tmp, r), :[], s(:arglist, s(:js_tmp, a))) rhs = s(:call, cur, op.to_sym, s(:arglist, self.rhs)) call = s(:call, s(:js_tmp, r), :[]=, s(:arglist, s(:js_tmp, a), rhs)) push "(#{a} = ", expr(first_arg), ", #{r} = ", expr(lhs) push ", ", expr(call), ")" end end end
def compile_or
def compile_or with_temp do |a| # args with_temp do |r| # recv aref = s(:call, s(:js_tmp, r), :[], s(:arglist, s(:js_tmp, a))) aset = s(:call, s(:js_tmp, r), :[]=, s(:arglist, s(:js_tmp, a), rhs)) orop = s(:or, aref, aset) push "(#{a} = ", expr(first_arg), ", #{r} = ", expr(lhs) push ", ", expr(orop), ")" end end end
def first_arg
def first_arg args[1] end