1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

removed "globals" option of CoffeeScript.compile and enhanced fix from

previous commits
This commit is contained in:
Michael Ficarra 2011-04-29 15:53:30 -04:00
parent 63ce244359
commit 7efea4bb23
7 changed files with 8 additions and 12 deletions

View file

@ -79,7 +79,7 @@
global: {}
};
for (g in global) {
sandbox[g] = global[g];
sandbox.global[g] = global[g];
}
sandbox.global.global = sandbox.global;
sandbox.global.root = sandbox.global;

View file

@ -301,7 +301,7 @@
post = this.compileNode(o);
scope = o.scope;
if (scope.expressions === this) {
if (!o.globals && o.scope.hasDeclarations()) {
if (o.scope.hasDeclarations()) {
code += "" + this.tab + "var " + (scope.declaredVariables().join(', ')) + ";\n";
}
if (scope.hasAssignments) {
@ -1304,7 +1304,6 @@
o.scope.shared = del(o, 'sharedScope');
o.indent += TAB;
delete o.bare;
delete o.globals;
vars = [];
exprs = [];
_ref2 = this.params;

View file

@ -25,7 +25,7 @@
global: {}
};
for (g in global) {
sandbox[g] = global[g];
sandbox.global[g] = global[g];
}
sandbox.global.global = sandbox.global;
sandbox.global.root = sandbox.global;
@ -41,7 +41,6 @@
val = CoffeeScript.eval(code, {
sandbox: sandbox,
bare: true,
globals: true,
filename: 'repl'
});
if (val !== void 0) {

View file

@ -85,7 +85,7 @@ exports.eval = (code, options = {}) ->
require: require
module : { exports: {} }
global : {}
sandbox[g] = global[g] for g of global
sandbox.global[g] = global[g] for g of global
sandbox.global.global = sandbox.global
sandbox.global.root = sandbox.global
sandbox.global.GLOBAL = sandbox.global

View file

@ -250,7 +250,7 @@ exports.Block = class Block extends Base
post = @compileNode o
{scope} = o
if scope.expressions is this
if not o.globals and o.scope.hasDeclarations()
if o.scope.hasDeclarations()
code += "#{@tab}var #{ scope.declaredVariables().join(', ') };\n"
if scope.hasAssignments
code += "#{@tab}var #{ multident scope.assignedVariables().join(', '), @tab };\n"
@ -1048,7 +1048,6 @@ exports.Code = class Code extends Base
o.scope.shared = del o, 'sharedScope'
o.indent += TAB
delete o.bare
delete o.globals
vars = []
exprs = []
for param in @params when param.splat

View file

@ -36,7 +36,7 @@ run = do ->
require: require
module : { exports: {} }
global : {}
sandbox[g] = global[g] for g of global
sandbox.global[g] = global[g] for g of global
sandbox.global.global = sandbox.global
sandbox.global.root = sandbox.global
sandbox.global.GLOBAL = sandbox.global
@ -49,7 +49,6 @@ run = do ->
val = CoffeeScript.eval code, {
sandbox,
bare: on,
globals: on,
filename: 'repl'
}
unless val is undefined

View file

@ -9,8 +9,8 @@ cantCompile = (code) ->
test "ensure that carriage returns don't break compilation on Windows", ->
doesNotThrow -> CoffeeScript.compile 'one\r\ntwo', bare: on
test "--bare and globals:on", ->
eq -1, CoffeeScript.compile('x = y', bare: on, globals: on).indexOf 'var'
test "--bare", ->
eq -1, CoffeeScript.compile('x = y', bare: on).indexOf 'function'
ok 'passed' is CoffeeScript.eval '"passed"', bare: on, filename: 'test'
test "multiple generated references", ->