mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fixes issue #477, missing global helpers in REPL.
This commit is contained in:
parent
4fc4edc7a0
commit
64b5ccc524
3 changed files with 10 additions and 4 deletions
|
@ -217,7 +217,7 @@
|
|||
var code;
|
||||
o.indent = (this.tab = o.noWrap ? '' : TAB);
|
||||
o.scope = new Scope(null, this, null);
|
||||
code = o.globals ? this.compileNode(o) : this.compileWithDeclarations(o);
|
||||
code = this.compileWithDeclarations(o);
|
||||
code = code.replace(TRAILING_WHITESPACE, '');
|
||||
code = code.replace(DOUBLE_PARENS, '($1)');
|
||||
return o.noWrap ? code : ("(function(){\n" + code + "\n})();\n");
|
||||
|
@ -228,7 +228,7 @@
|
|||
if (o.scope.hasAssignments(this)) {
|
||||
code = ("" + (this.tab) + "var " + (o.scope.compiledAssignments()) + ";\n" + code);
|
||||
}
|
||||
if (o.scope.hasDeclarations(this)) {
|
||||
if (!o.globals && o.scope.hasDeclarations(this)) {
|
||||
code = ("" + (this.tab) + "var " + (o.scope.compiledDeclarations()) + ";\n" + code);
|
||||
}
|
||||
return code;
|
||||
|
|
|
@ -199,7 +199,7 @@ exports.Expressions: class Expressions extends BaseNode
|
|||
compileRoot: (o) ->
|
||||
o.indent: @tab: if o.noWrap then '' else TAB
|
||||
o.scope: new Scope(null, this, null)
|
||||
code: if o.globals then @compileNode(o) else @compileWithDeclarations(o)
|
||||
code: @compileWithDeclarations(o)
|
||||
code: code.replace(TRAILING_WHITESPACE, '')
|
||||
code: code.replace(DOUBLE_PARENS, '($1)')
|
||||
if o.noWrap then code else "(function(){\n$code\n})();\n"
|
||||
|
@ -209,7 +209,7 @@ exports.Expressions: class Expressions extends BaseNode
|
|||
compileWithDeclarations: (o) ->
|
||||
code: @compileNode(o)
|
||||
code: "${@tab}var ${o.scope.compiledAssignments()};\n$code" if o.scope.hasAssignments(this)
|
||||
code: "${@tab}var ${o.scope.compiledDeclarations()};\n$code" if o.scope.hasDeclarations(this)
|
||||
code: "${@tab}var ${o.scope.compiledDeclarations()};\n$code" if not o.globals and o.scope.hasDeclarations(this)
|
||||
code
|
||||
|
||||
# Compiles a single expression within the expressions body. If we need to
|
||||
|
|
|
@ -6,3 +6,9 @@ js: CoffeeScript.compile("one\r\ntwo", {noWrap: on})
|
|||
|
||||
ok js is "one;\ntwo;"
|
||||
|
||||
|
||||
global.resultArray: []
|
||||
CoffeeScript.run("resultArray.push i for i of global", {noWrap: on, globals: on, source: 'tests'})
|
||||
|
||||
ok 'setInterval' in global.resultArray
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue