Skip to content

Commit

Permalink
Added support for more #defined? args
Browse files Browse the repository at this point in the history
  • Loading branch information
elia committed Oct 12, 2013
1 parent 0c93869 commit 09f7778
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/opal/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,16 @@ def process_defined(sexp, level)
f("($hasOwn.call($gvars, #{gvar_name.inspect}) ? 'global-variable', : nil)", sexp)
when :yield
f("(#{js_block_given(sexp, level)} ? 'yield' : nil)", sexp)
when :lasgn, :iasgn, :gasgn, :cvdecl, :masgn,
:op_asgn_or, :op_asgn_and
f("'assignment'", sexp)
when :paren, :not
process_defined([part[1]], level)
when :and, :or, :str, :dstr, :dregx, :int, :float, :dot2, :regexp, :array, :hash, :sym
f("'expression'", sexp)
when :nth_ref
gvar_name = "$#{part[1].to_s[1..-1]}"
f("($hasOwn.call($gvars, #{gvar_name.inspect}) ? 'global-variable', : nil)", sexp)
else
raise "bad defined? part: #{part[0]} (full sexp: #{part.inspect})"
end
Expand Down

0 comments on commit 09f7778

Please sign in to comment.