mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Merge branch 'master' of http://github.com/jashkenas/coffee-script into refactorTests
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
(function() {
|
||||
var ALL_SWITCHES, BANNER, CoffeeScript, DEPRECATED_SWITCHES, EventEmitter, SWITCHES, compileOptions, compileScript, compileScripts, compileStdio, exec, fs, helpers, lint, optionParser, optparse, opts, parseOptions, path, printLine, printTokens, printWarn, sources, spawn, usage, version, watch, writeJs, _ref;
|
||||
var ALL_SWITCHES, BANNER, CoffeeScript, DEPRECATED_SWITCHES, EventEmitter, SWITCHES, compileOptions, compileScript, compileScripts, compileStdio, exec, fs, helpers, lint, optionParser, optparse, opts, parseOptions, path, printLine, printTokens, printWarn, sources, spawn, usage, util, version, watch, writeJs, _ref;
|
||||
fs = require('fs');
|
||||
path = require('path');
|
||||
util = require('util');
|
||||
helpers = require('./helpers');
|
||||
optparse = require('./optparse');
|
||||
CoffeeScript = require('./coffee-script');
|
||||
@@ -55,7 +56,7 @@
|
||||
return compileScripts();
|
||||
};
|
||||
compileScripts = function() {
|
||||
var base, compile, _fn, _i, _len, _results;
|
||||
var base, compile, source, _fn, _i, _len, _results;
|
||||
_fn = function(source) {
|
||||
base = path.join(source);
|
||||
compile = function(source, topLevel) {
|
||||
@@ -185,7 +186,7 @@
|
||||
if (err) {
|
||||
return printLine(err.message);
|
||||
} else if (opts.compile && opts.watch) {
|
||||
return printLine("Compiled " + source);
|
||||
return util.log("compiled " + source);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
37
lib/nodes.js
37
lib/nodes.js
@@ -520,7 +520,13 @@
|
||||
__extends(Call, Base);
|
||||
Call.prototype.children = ['variable', 'args'];
|
||||
Call.prototype.newInstance = function() {
|
||||
this.isNew = true;
|
||||
var base;
|
||||
base = this.variable.base || this.variable;
|
||||
if (base instanceof Call) {
|
||||
base.newInstance();
|
||||
} else {
|
||||
this.isNew = true;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
Call.prototype.superReference = function(o) {
|
||||
@@ -1198,9 +1204,12 @@
|
||||
return !!this.ctor;
|
||||
};
|
||||
Code.prototype.compileNode = function(o) {
|
||||
var code, exprs, i, idt, lit, p, param, ref, scope, sharedScope, splats, v, val, vars, wasEmpty, _i, _j, _k, _len, _len2, _len3, _len4, _ref, _ref2, _ref3, _ref4, _results;
|
||||
var code, exprs, i, idt, lit, p, param, ref, sharedScope, splats, v, val, vars, wasEmpty, _i, _j, _k, _len, _len2, _len3, _len4, _ref, _ref2, _ref3, _ref4, _results;
|
||||
sharedScope = del(o, 'sharedScope');
|
||||
o.scope = scope = sharedScope || new Scope(o.scope, this.body, this);
|
||||
o.scope = sharedScope || new Scope(o.scope, this.body, this);
|
||||
if (sharedScope) {
|
||||
o.scope.shared = true;
|
||||
}
|
||||
o.indent += TAB;
|
||||
delete o.bare;
|
||||
delete o.globals;
|
||||
@@ -1253,7 +1262,7 @@
|
||||
if (!splats) {
|
||||
for (i = 0, _len4 = vars.length; i < _len4; i++) {
|
||||
v = vars[i];
|
||||
scope.parameter(vars[i] = v.compile(o));
|
||||
o.scope.parameter(vars[i] = v.compile(o));
|
||||
}
|
||||
}
|
||||
if (!(wasEmpty || this.noReturn)) {
|
||||
@@ -1763,17 +1772,15 @@
|
||||
scope = o.scope;
|
||||
name = this.name && this.name.compile(o, LEVEL_LIST);
|
||||
index = this.index && this.index.compile(o, LEVEL_LIST);
|
||||
if (!hasCode) {
|
||||
if (name && !this.pattern) {
|
||||
scope.find(name, {
|
||||
immediate: true
|
||||
});
|
||||
}
|
||||
if (index) {
|
||||
scope.find(index, {
|
||||
immediate: true
|
||||
});
|
||||
}
|
||||
if (name && !this.pattern) {
|
||||
scope.find(name, {
|
||||
immediate: true
|
||||
});
|
||||
}
|
||||
if (index) {
|
||||
scope.find(index, {
|
||||
immediate: true
|
||||
});
|
||||
}
|
||||
if (this.returns && !hasPure) {
|
||||
rvar = scope.freeVariable('results');
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
(function() {
|
||||
var CoffeeScript, helpers, readline, repl, run, stdio;
|
||||
var CoffeeScript, error, helpers, readline, repl, run, stdio;
|
||||
CoffeeScript = require('./coffee-script');
|
||||
helpers = require('./helpers');
|
||||
readline = require('readline');
|
||||
stdio = process.openStdin();
|
||||
error = function(err) {
|
||||
return stdio.write((err.stack || err.toString()) + '\n\n');
|
||||
};
|
||||
helpers.extend(global, {
|
||||
quit: function() {
|
||||
return process.exit(0);
|
||||
@@ -21,10 +24,11 @@
|
||||
console.log(val);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.stack || err.toString());
|
||||
error(err);
|
||||
}
|
||||
return repl.prompt();
|
||||
};
|
||||
process.on('uncaughtException', error);
|
||||
repl = readline.createInterface(stdio);
|
||||
repl.setPrompt('coffee> ');
|
||||
stdio.on('data', function(buffer) {
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
return false;
|
||||
};
|
||||
Scope.prototype.parameter = function(name) {
|
||||
if (this.shared && this.check(name, true)) {
|
||||
return;
|
||||
}
|
||||
return this.add(name, 'param');
|
||||
};
|
||||
Scope.prototype.check = function(name, immediate) {
|
||||
|
||||
Reference in New Issue
Block a user