mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
reverting the closure wrapper removal again.
This commit is contained in:
@@ -303,7 +303,7 @@
|
||||
};
|
||||
|
||||
Block.prototype.compileRoot = function(o) {
|
||||
var code, e, exp, i, prelude, preludeExps, rest;
|
||||
var code, exp, i, prelude, preludeExps, rest;
|
||||
o.indent = o.bare ? '' : TAB;
|
||||
o.scope = new Scope(null, this, null);
|
||||
o.level = LEVEL_TOP;
|
||||
@@ -316,19 +316,22 @@
|
||||
_results = [];
|
||||
for (i = 0, _len = _ref2.length; i < _len; i++) {
|
||||
exp = _ref2[i];
|
||||
e = exp.unwrap();
|
||||
if (!(e instanceof Comment || e instanceof Literal)) break;
|
||||
if (!(exp.unwrap() instanceof Comment)) break;
|
||||
_results.push(exp);
|
||||
}
|
||||
return _results;
|
||||
}).call(this);
|
||||
rest = this.expressions.slice(preludeExps.length);
|
||||
this.expressions = preludeExps;
|
||||
if (preludeExps.length) prelude = "" + (this.compileNode(o)) + "\n";
|
||||
if (preludeExps.length) {
|
||||
prelude = "" + (this.compileNode(merge(o, {
|
||||
indent: ''
|
||||
}))) + "\n";
|
||||
}
|
||||
this.expressions = rest;
|
||||
}
|
||||
code = this.compileWithDeclarations(o);
|
||||
if (o.bare) return prelude + code;
|
||||
if (o.bare) return code;
|
||||
return "" + prelude + "(function() {\n" + code + "\n}).call(this);\n";
|
||||
};
|
||||
|
||||
|
||||
@@ -250,15 +250,14 @@ exports.Block = class Block extends Base
|
||||
prelude = ""
|
||||
unless o.bare
|
||||
preludeExps = for exp, i in @expressions
|
||||
e = exp.unwrap()
|
||||
break unless e instanceof Comment or e instanceof Literal
|
||||
break unless exp.unwrap() instanceof Comment
|
||||
exp
|
||||
rest = @expressions[preludeExps.length...]
|
||||
@expressions = preludeExps
|
||||
prelude = "#{@compileNode o}\n" if preludeExps.length
|
||||
prelude = "#{@compileNode merge(o, indent: '')}\n" if preludeExps.length
|
||||
@expressions = rest
|
||||
code = @compileWithDeclarations o
|
||||
return prelude + code if o.bare
|
||||
return code if o.bare
|
||||
"#{prelude}(function() {\n#{code}\n}).call(this);\n"
|
||||
|
||||
# Compile the expressions body for the contents of a function, with
|
||||
|
||||
Reference in New Issue
Block a user