tweaking compileWithDeclarations

This commit is contained in:
Jeremy Ashkenas
2010-10-11 12:27:57 -04:00
parent acc06d772a
commit d7052d09ff

View File

@@ -209,14 +209,10 @@ exports.Expressions = class Expressions extends Base
# declarations of all inner variables pushed up to the top.
compileWithDeclarations: (o) ->
code = @compileNode(o)
code = """
#{@tab}var #{ o.scope.compiledAssignments().replace /\n/g, '$&' + @tab };
#{code}
""" if o.scope.hasAssignments this
code = """
#{@tab}var #{o.scope.compiledDeclarations()};
#{code}
""" if not o.globals and o.scope.hasDeclarations this
if o.scope.hasAssignments this
code = "#{@tab}var #{ o.scope.compiledAssignments().replace /\n/g, '$&' + @tab };\n#{code}"
if not o.globals and o.scope.hasDeclarations this
code = "#{@tab}var #{o.scope.compiledDeclarations()};\n#{code}"
code
# Compiles a single expression within the expressions body. If we need to