Skip to content

Commit

Permalink
Generate less code inside def/defs to gather block from method
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Aug 2, 2013
1 parent 775d2c6 commit c018aed
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/opal/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1203,13 +1203,12 @@ def js_def(recvr, mid, args, stmts, line, end_line, sexp)

if @scope.uses_block?
@scope.add_temp "$iter = #{scope_name}._p"
@scope.add_temp yielder
blk = fragment(("\n%s%s = %s._p || nil, %s._p = null;\n%s" %
[@indent, yielder, scope_name, scope_name, @indent]), sexp)
@scope.add_temp "#{yielder} = $iter || nil"

code.unshift f("#{scope_name}._p = null;", sexp)
end

code.push(*stmt_code)
code.unshift blk if blk

uses_super = @scope.uses_super

Expand Down

0 comments on commit c018aed

Please sign in to comment.