class Opal::Nodes::OpAsgn2Node
s(:op_asgn2, lhs, :b=, :+, rhs)
lhs.b += 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 |tmp| getr = s(:call, s(:js_tmp, tmp), meth, s(:arglist)) asgn = s(:call, s(:js_tmp, tmp), mid, s(:arglist, rhs)) andop = s(:and, getr, asgn) push "(#{tmp} = ", expr(lhs), ", ", expr(andop), ")" end end
def compile_operator
def compile_operator with_temp do |tmp| getr = s(:call, s(:js_tmp, tmp), meth, s(:arglist)) oper = s(:call, getr, op, s(:arglist, rhs)) asgn = s(:call, s(:js_tmp, tmp), mid, s(:arglist, oper)) push "(#{tmp} = ", expr(lhs), ", ", expr(asgn), ")" end end
def compile_or
def compile_or with_temp do |tmp| getr = s(:call, s(:js_tmp, tmp), meth, s(:arglist)) asgn = s(:call, s(:js_tmp, tmp), mid, s(:arglist, rhs)) orop = s(:or, getr, asgn) push "(#{tmp} = ", expr(lhs), ", ", expr(orop), ")" end end
def meth
def meth mid.to_s[0..-2] end