Skip to content

Commit c723073

Browse files
committedOct 24, 2013
Initial commit of foo[bar] += baz, support
1 parent 45f2c92 commit c723073

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
 

‎lib/opal/cli.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def prepare_eval_code
213213
# SOURCE
214214

215215
def sexp
216-
Opal::Grammar.new.parse(source)
216+
Opal::Parser.new.parse(source)
217217
end
218218
end
219219
end

‎lib/opal/nodes/call_special.rb

+21
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,27 @@ def first_arg
6666
end
6767

6868
def compile
69+
case op.to_s
70+
when '||' then compile_or
71+
when '&&' then compile_and
72+
else compile_operator
73+
end
74+
end
75+
76+
def compile_operator
77+
with_temp do |a| # args
78+
with_temp do |r| # recv
79+
cur = s(:call, s(:js_tmp, r), :[], s(:arglist, s(:js_tmp, a)))
80+
rhs = s(:call, cur, :+, s(:arglist, self.rhs))
81+
call = s(:call, s(:js_tmp, r), :[]=, s(:arglist, s(:js_tmp, a), rhs))
82+
83+
push "(#{a} = ", expr(first_arg), ", #{r} = ", expr(lhs)
84+
push ", ", expr(call), ")"
85+
end
86+
end
87+
end
88+
89+
def compile_or
6990
with_temp do |a| # args
7091
with_temp do |r| # recv
7192
aref = s(:call, s(:js_tmp, r), :[], s(:arglist, s(:js_tmp, a)))

0 commit comments

Comments
 (0)
Please sign in to comment.