Skip to content

Commit

Permalink
Replace some Opal references with $opal in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Aug 2, 2013
1 parent c018aed commit d68c2e2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/opal/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ def process_call(sexp, level)
lvar = meth.intern
lvar = "#{lvar}$" if RESERVED.include? lvar
call = s(:call, s(:self), meth.intern, s(:arglist))
[fragment("((#{t} = Opal.irb_vars.#{lvar}) == null ? ", sexp), process(call, :expr), fragment(" : #{t})", sexp)]
[fragment("((#{t} = $opal.irb_vars.#{lvar}) == null ? ", sexp), process(call, :expr), fragment(" : #{t})", sexp)]
}
end

Expand Down Expand Up @@ -999,7 +999,7 @@ def process_class(sexp, level)
base = process(cid[1], :expr)
name = cid[2].to_s
elsif cid[0] == :colon3
base = process(s(:js_tmp, 'Opal.Object'), :expr)
base = process(s(:js_tmp, '$opal.Object'), :expr)
name = cid[1].to_s
else
raise "Bad receiver in class"
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def process_module(sexp, level)
base = process(cid[1], :expr)
name = cid[2].to_s
elsif cid[0] == :colon3
base = fragment('Opal.Object', sexp)
base = fragment('$opal.Object', sexp)
name = cid[1].to_s
else
raise "Bad receiver in class"
Expand Down Expand Up @@ -1220,7 +1220,7 @@ def js_def(recvr, mid, args, stmts, line, end_line, sexp)

if @scope.catch_return
code.unshift f("try {\n", sexp)
code.push f("\n} catch($returner) { if ($returner === Opal.returner) { return $returner.$v; } throw $returner; }", sexp)
code.push f("\n} catch($returner) { if ($returner === $opal.returner) { return $returner.$v; } throw $returner; }", sexp)
end
end
end
Expand Down Expand Up @@ -1570,7 +1570,7 @@ def process_lasgn(sexp, level)
lvar = "#{lvar}$".to_sym if RESERVED.include? lvar.to_s

if @irb_vars and @scope.top?
[fragment("Opal.irb_vars.#{lvar} = ", sexp), process(rhs, :expr)]
[fragment("$opal.irb_vars.#{lvar} = ", sexp), process(rhs, :expr)]
else
@scope.add_local lvar
rhs = process(rhs, :expr)
Expand All @@ -1591,7 +1591,7 @@ def process_lvar(sexp, level)
lvar = "#{lvar}$" if RESERVED.include? lvar

if @irb_vars and @scope.top?
with_temp { |t| fragment("((#{t} = Opal.irb_vars.#{lvar}) == null ? nil : #{t})", sexp) }
with_temp { |t| fragment("((#{t} = $opal.irb_vars.#{lvar}) == null ? nil : #{t})", sexp) }
else
fragment(lvar, sexp)
end
Expand Down Expand Up @@ -2026,7 +2026,7 @@ def process_match3(sexp, level)
# s(:cvar, name)
def process_cvar(exp, level)
with_temp do |tmp|
fragment(("((%s = Opal.cvars[%s]) == null ? nil : %s)" %
fragment(("((%s = $opal.cvars[%s]) == null ? nil : %s)" %
[tmp, exp.shift.to_s.inspect, tmp]), exp)
end
end
Expand All @@ -2035,11 +2035,11 @@ def process_cvar(exp, level)
#
# s(:cvasgn, :@@name, rhs)
def process_cvasgn(exp, level)
"(Opal.cvars[#{exp.shift.to_s.inspect}] = #{process exp.shift, :expr})"
"($opal.cvars[#{exp.shift.to_s.inspect}] = #{process exp.shift, :expr})"
end

def process_cvdecl(exp, level)
[fragment("(Opal.cvars[#{exp.shift.to_s.inspect}] = ", exp), process(exp.shift, :expr), fragment(")", exp)]
[fragment("($opal.cvars[#{exp.shift.to_s.inspect}] = ", exp), process(exp.shift, :expr), fragment(")", exp)]
end

# BASE::NAME
Expand Down

0 comments on commit d68c2e2

Please sign in to comment.