Merge branch 'master' into issue2849

Conflicts:
	lib/coffee-script/coffee-script.js
	src/coffee-script.coffee
This commit is contained in:
Demian Ferreiro
2013-06-09 02:40:53 -03:00
111 changed files with 2799 additions and 1673 deletions

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var CoffeeScript, compile, runScripts,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
@@ -10,11 +10,10 @@
compile = CoffeeScript.compile;
CoffeeScript["eval"] = function(code, options) {
var _ref;
if (options == null) {
options = {};
}
if ((_ref = options.bare) == null) {
if (options.bare == null) {
options.bare = true;
}
return eval(compile(code, options));
@@ -25,6 +24,7 @@
options = {};
}
options.bare = true;
options.shiftLine = true;
return Function(compile(code, options))();
};
@@ -32,7 +32,7 @@
return;
}
if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null)) {
if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null) && (typeof unescape !== "undefined" && unescape !== null) && (typeof encodeURIComponent !== "undefined" && encodeURIComponent !== null)) {
compile = function(code, options) {
var js, v3SourceMap, _ref;
if (options == null) {
@@ -41,7 +41,7 @@
options.sourceMap = true;
options.inline = true;
_ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap;
return "" + js + "\n//@ sourceMappingURL=data:application/json;base64," + (btoa(v3SourceMap)) + "\n//@ sourceURL=coffeescript";
return "" + js + "\n//@ sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//@ sourceURL=coffeescript";
};
}

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var CoffeeScript, cakefileDirectory, existsSync, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;

View File

@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var Lexer, SourceMap, child_process, compile, ext, fork, formatSourcePosition, fs, helpers, lexer, loadFile, parser, patchStackTrace, patched, path, vm, _i, _len, _ref,
var Lexer, Module, SourceMap, child_process, compile, ext, findExtension, fork, formatSourcePosition, fs, helpers, lexer, loadFile, parser, patchStackTrace, patched, path, sourceMaps, vm, _i, _len, _ref,
__hasProp = {}.hasOwnProperty;
fs = require('fs');
@@ -19,7 +19,7 @@
SourceMap = require('./sourcemap');
exports.VERSION = '1.6.2';
exports.VERSION = '1.6.3';
exports.helpers = helpers;
@@ -28,12 +28,12 @@
if (options == null) {
options = {};
}
merge = exports.helpers.merge;
merge = helpers.merge;
if (options.sourceMap) {
map = new SourceMap;
}
try {
fragments = (parser.parse(lexer.tokenize(code, options))).compileToFragments(options);
fragments = parser.parse(lexer.tokenize(code, options)).compileToFragments(options);
} catch (_error) {
err = _error;
err.filename = options.filename;
@@ -41,7 +41,10 @@
throw err;
}
currentLine = 0;
if (options.header || options.inline) {
if (options.header) {
currentLine += 1;
}
if (options.shiftLine) {
currentLine += 1;
}
currentColumn = 0;
@@ -89,12 +92,12 @@
};
exports.run = function(code, options) {
var answer, mainModule, _ref;
var answer, mainModule;
if (options == null) {
options = {};
}
mainModule = require.main;
if ((_ref = options.sourceMap) == null) {
if (options.sourceMap == null) {
options.sourceMap = true;
}
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
@@ -103,7 +106,7 @@
if (!helpers.isCoffee(mainModule.filename) || require.extensions) {
answer = compile(code, options);
patchStackTrace();
mainModule._sourceMaps[mainModule.filename] = answer.sourceMap;
sourceMaps[mainModule.filename] = answer.sourceMap;
return mainModule._compile(answer.js, mainModule.filename);
} else {
return mainModule._compile(code, mainModule.filename);
@@ -174,13 +177,16 @@
};
loadFile = function(module, filename) {
var raw, stripped;
var answer, raw, stripped;
raw = fs.readFileSync(filename, 'utf8');
stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
return module._compile(compile(stripped, {
answer = compile(stripped, {
filename: filename,
sourceMap: true,
literate: helpers.isLiterate(filename)
}), filename);
});
sourceMaps[filename] = answer.sourceMap;
return module._compile(answer.js, filename);
};
if (require.extensions) {
@@ -189,6 +195,29 @@
ext = _ref[_i];
require.extensions[ext] = loadFile;
}
Module = require('module');
findExtension = function(filename) {
var curExtension, extensions;
extensions = path.basename(filename).split('.');
if (extensions[0] === '') {
extensions.shift();
}
while (extensions.shift()) {
curExtension = '.' + extensions.join('.');
if (Module._extensions[curExtension]) {
return curExtension;
}
}
return '.js';
};
Module.prototype.load = function(filename) {
var extension;
this.filename = filename;
this.paths = Module._nodeModulePaths(path.dirname(filename));
extension = findExtension(filename);
Module._extensions[extension](this, filename);
return this.loaded = true;
};
}
if (child_process) {
@@ -245,6 +274,8 @@
patched = false;
sourceMaps = {};
patchStackTrace = function() {
var mainModule;
if (patched) {
@@ -252,13 +283,12 @@
}
patched = true;
mainModule = require.main;
mainModule._sourceMaps = {};
return Error.prepareStackTrace = function(err, stack) {
var frame, frames, getSourceMapping, sourceFiles, _ref1;
sourceFiles = {};
getSourceMapping = function(filename, line, column) {
var answer, sourceMap;
sourceMap = mainModule._sourceMaps[filename];
sourceMap = sourceMaps[filename];
if (sourceMap) {
answer = sourceMap.sourceLocation([line - 1, column - 1]);
}

View File

@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, useWinPathSep, version, wait, watch, watchDir, watchers, writeJs, _ref;
fs = require('fs');
@@ -18,6 +18,8 @@
exists = fs.exists || path.exists;
useWinPathSep = path.sep === '\\';
helpers.extend(CoffeeScript, new EventEmitter);
printLine = function(line) {
@@ -34,7 +36,7 @@
BANNER = 'Usage: coffee [options] path/to/script.coffee -- [args]\n\nIf called without options, `coffee` will run your script.';
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-l', '--lint', 'pipe the compiled JavaScript through JavaScript Lint'], ['-m', '--map', 'generate source map and save as .map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
opts = {};
@@ -185,8 +187,6 @@
return printLine(t.output.trim());
} else if (o.compile || o.map) {
return writeJs(base, t.file, t.output, options.jsPath, t.sourceMap);
} else if (o.lint) {
return lint(t.file, t.output);
}
}
} catch (_error) {
@@ -387,9 +387,9 @@
if (extension == null) {
extension = ".js";
}
basename = helpers.baseFileName(source, true, path.sep);
basename = helpers.baseFileName(source, true, useWinPathSep);
srcDir = path.dirname(source);
baseDir = base === '.' ? srcDir : srcDir.substring(base.length);
baseDir = base === '.' || base === './' ? srcDir : srcDir.substring(base.length);
dir = opts.output ? path.join(opts.output, baseDir) : srcDir;
return path.join(dir, basename + extension);
};
@@ -407,7 +407,7 @@
js = ' ';
}
if (generatedSourceMap) {
js = "" + js + "\n/*\n//@ sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, path.sep)) + "\n*/\n";
js = "" + js + "\n/*\n//@ sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n*/\n";
}
fs.writeFile(jsPath, js, function(err) {
if (err) {
@@ -442,19 +442,6 @@
return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message);
};
lint = function(file, js) {
var conf, jsl, printIt;
printIt = function(buffer) {
return printLine(file + ':\t' + buffer.toString().trim());
};
conf = __dirname + '/../../extras/jsl.conf';
jsl = spawn('jsl', ['-nologo', '-stdin', '-conf', conf]);
jsl.stdout.on('data', printIt);
jsl.stderr.on('data', printIt);
jsl.stdin.write(js);
return jsl.stdin.end();
};
printTokens = function(tokens) {
var strings, tag, token, value;
strings = (function() {
@@ -476,7 +463,7 @@
optionParser = new optparse.OptionParser(SWITCHES, BANNER);
o = opts = optionParser.parse(process.argv.slice(2));
o.compile || (o.compile = !!o.output);
o.run = !(o.compile || o.print || o.lint || o.map);
o.run = !(o.compile || o.print || o.map);
o.print = !!(o.print || (o["eval"] || o.stdio && o.compile));
sources = o["arguments"];
for (i = _i = 0, _len = sources.length; _i < _len; i = ++_i) {
@@ -489,7 +476,7 @@
var answer, cwd, jsDir, jsPath;
answer = {
filename: filename,
literate: helpers.isLiterate(filename),
literate: opts.literate || helpers.isLiterate(filename),
bare: opts.bare,
header: opts.compile,
sourceMap: opts.map
@@ -503,13 +490,13 @@
jsPath: jsPath,
sourceRoot: path.relative(jsDir, cwd),
sourceFiles: [path.relative(cwd, filename)],
generatedFile: helpers.baseFileName(jsPath, false, path.sep)
generatedFile: helpers.baseFileName(jsPath, false, useWinPathSep)
});
} else {
answer = helpers.merge(answer, {
sourceRoot: "",
sourceFiles: [helpers.baseFileName(filename, false, path.sep)],
generatedFile: helpers.baseFileName(filename, true, path.sep) + ".js"
sourceFiles: [helpers.baseFileName(filename, false, useWinPathSep)],
generatedFile: helpers.baseFileName(filename, true, useWinPathSep) + ".js"
});
}
}

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
@@ -350,6 +350,8 @@
return [$2, $3];
}), o('CATCH Object Block', function() {
return [LOC(2)(new Value($2)), $3];
}), o('CATCH Block', function() {
return [null, $2];
})
],
Throw: [

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var buildLocationData, extend, flatten, last, repeat, _ref;
@@ -156,14 +156,15 @@
}
};
exports.baseFileName = function(file, stripExt, pathSep) {
var parts;
exports.baseFileName = function(file, stripExt, useWinPathSep) {
var parts, pathSep;
if (stripExt == null) {
stripExt = false;
}
if (pathSep == null) {
pathSep = '/';
if (useWinPathSep == null) {
useWinPathSep = false;
}
pathSep = useWinPathSep ? /\\|\// : /\//;
parts = file.split(pathSep);
file = parts[parts.length - 1];
if (!stripExt) {
@@ -186,11 +187,11 @@
};
exports.throwSyntaxError = function(message, location) {
var error, _ref1, _ref2;
if ((_ref1 = location.last_line) == null) {
var error;
if (location.last_line == null) {
location.last_line = location.first_line;
}
if ((_ref2 = location.last_column) == null) {
if (location.last_column == null) {
location.last_column = location.first_column;
}
error = new SyntaxError(message);

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var key, val, _ref;

View File

@@ -1,11 +1,11 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, starts, throwSyntaxError, _ref, _ref1,
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
_ref = require('./rewriter'), Rewriter = _ref.Rewriter, INVERSES = _ref.INVERSES;
_ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError;
_ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, repeat = _ref1.repeat, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError;
exports.Lexer = Lexer = (function() {
function Lexer() {}
@@ -155,10 +155,10 @@
}
lexedLength = number.length;
if (octalLiteral = /^0o([0-7]+)/.exec(number)) {
number = '0x' + (parseInt(octalLiteral[1], 8)).toString(16);
number = '0x' + parseInt(octalLiteral[1], 8).toString(16);
}
if (binaryLiteral = /^0b([01]+)/.exec(number)) {
number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16);
number = '0x' + parseInt(binaryLiteral[1], 2).toString(16);
}
this.token('NUMBER', number, 0, lexedLength);
return lexedLength;
@@ -228,7 +228,7 @@
if (here) {
this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
herecomment: true,
indent: Array(this.indent + 1).join(' ')
indent: repeat(' ', this.indent)
}), 0, comment.length);
}
return comment.length;
@@ -710,7 +710,7 @@
column = this.chunkColumn;
if (lineCount > 0) {
lines = string.split('\n');
column = (last(lines)).length;
column = last(lines).length;
} else {
column += string.length;
}
@@ -876,9 +876,9 @@
BOOL = ['TRUE', 'FALSE'];
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--', ']'];
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--'];
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING');
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING', ']');
CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, _ref2, _ref3,
__hasProp = {}.hasOwnProperty,
@@ -44,7 +44,7 @@
}
CodeFragment.prototype.toString = function() {
return "" + this.code + [this.locationData ? ": " + locationDataToString(this.locationData) : void 0];
return "" + this.code + (this.locationData ? ": " + locationDataToString(this.locationData) : '');
};
return CodeFragment;
@@ -189,10 +189,11 @@
Base.prototype.traverseChildren = function(crossScope, func) {
return this.eachChild(function(child) {
if (func(child) === false) {
return false;
var recur;
recur = func(child);
if (recur !== false) {
return child.traverseChildren(crossScope, func);
}
return child.traverseChildren(crossScope, func);
});
};
@@ -475,6 +476,8 @@
fragments.push(this.makeCode(scope.assignedVariables().join(",\n" + (this.tab + TAB))));
}
fragments.push(this.makeCode(";\n" + (this.spaced ? '\n' : '')));
} else if (fragments.length && post.length) {
fragments.push(this.makeCode("\n"));
}
}
return fragments.concat(post);
@@ -634,7 +637,7 @@
Return.prototype.compileNode = function(o) {
var answer;
answer = [];
answer.push(this.makeCode(this.tab + ("return" + [this.expression ? " " : void 0])));
answer.push(this.makeCode(this.tab + ("return" + (this.expression ? " " : ""))));
if (this.expression) {
answer = answer.concat(this.expression.compileToFragments(o, LEVEL_PAREN));
}
@@ -773,17 +776,16 @@
};
Value.prototype.unfoldSoak = function(o) {
var _ref4,
_this = this;
return (_ref4 = this.unfoldedSoak) != null ? _ref4 : this.unfoldedSoak = (function() {
var fst, i, ifn, prop, ref, snd, _i, _len, _ref5, _ref6;
var _this = this;
return this.unfoldedSoak != null ? this.unfoldedSoak : this.unfoldedSoak = (function() {
var fst, i, ifn, prop, ref, snd, _i, _len, _ref4, _ref5;
if (ifn = _this.base.unfoldSoak(o)) {
(_ref5 = ifn.body.properties).push.apply(_ref5, _this.properties);
(_ref4 = ifn.body.properties).push.apply(_ref4, _this.properties);
return ifn;
}
_ref6 = _this.properties;
for (i = _i = 0, _len = _ref6.length; _i < _len; i = ++_i) {
prop = _ref6[i];
_ref5 = _this.properties;
for (i = _i = 0, _len = _ref5.length; _i < _len; i = ++_i) {
prop = _ref5[i];
if (!prop.soak) {
continue;
}
@@ -820,7 +822,7 @@
Comment.prototype.compileNode = function(o, level) {
var code;
code = '/*' + multident(this.comment, this.tab) + ("\n" + this.tab + "*/\n");
code = "/*" + (multident(this.comment, this.tab)) + (__indexOf.call(this.comment, '\n') >= 0 ? "\n" + this.tab : '') + "*/\n";
if ((level || o.level) === LEVEL_TOP) {
code = o.indent + code;
}
@@ -1227,7 +1229,7 @@
join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n';
indent = prop instanceof Comment ? '' : idt;
if (prop instanceof Assign && prop.variable instanceof Value && prop.variable.hasProperties()) {
throw new SyntaxError('Invalid object key');
prop.variable.error('Invalid object key');
}
if (prop instanceof Value && prop["this"]) {
prop = new Assign(prop.properties[0].name, prop, 'object');
@@ -1308,7 +1310,7 @@
}
answer.push.apply(answer, fragments);
}
if ((fragmentsToText(answer)).indexOf('\n') >= 0) {
if (fragmentsToText(answer).indexOf('\n') >= 0) {
answer.unshift(this.makeCode("[\n" + o.indent));
answer.push(this.makeCode("\n" + this.tab + "]"));
} else {
@@ -2125,7 +2127,7 @@
set = '';
body = this.body;
if (body.isEmpty()) {
body = '';
body = this.makeCode('');
} else {
if (this.returns) {
body.makeReturn(rvar = o.scope.freeVariable('results'));
@@ -2306,7 +2308,7 @@
Op.prototype.compileExistence = function(o) {
var fst, ref;
if (this.first.isComplex()) {
if (!o.isExistentialEquals && this.first.isComplex()) {
ref = new Literal(o.scope.freeVariable('ref'));
fst = new Parens(new Assign(ref, this.first));
} else {
@@ -2410,7 +2412,7 @@
var fragments, ref, sub, _ref4;
_ref4 = this.object.cache(o, LEVEL_LIST), sub = _ref4[0], ref = _ref4[1];
fragments = [].concat(this.makeCode(utility('indexOf') + ".call("), this.array.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), ref, this.makeCode(") " + (this.negated ? '< 0' : '>= 0')));
if ((fragmentsToText(sub)) === (fragmentsToText(ref))) {
if (fragmentsToText(sub) === fragmentsToText(ref)) {
return fragments;
}
fragments = sub.concat(this.makeCode(', '), fragments);
@@ -2459,10 +2461,10 @@
};
Try.prototype.compileNode = function(o) {
var catchPart, ensurePart, placeholder, tryPart, _ref4;
var catchPart, ensurePart, placeholder, tryPart;
o.indent += TAB;
tryPart = this.attempt.compileToFragments(o, LEVEL_TOP);
catchPart = this.recovery ? (placeholder = new Literal('_error'), this.recovery.unshift(new Assign(this.errorVariable, placeholder)), this.errorVariable = placeholder, (_ref4 = this.errorVariable.value, __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0) ? this.errorVariable.error("catch variable may not be \"" + this.errorVariable.value + "\"") : void 0, [].concat(this.makeCode(" catch ("), this.errorVariable.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"))) : !(this.ensure || this.recovery) ? [this.makeCode(' catch (_error) {}')] : [];
catchPart = this.recovery ? (placeholder = new Literal('_error'), this.errorVariable ? this.recovery.unshift(new Assign(this.errorVariable, placeholder)) : void 0, [].concat(this.makeCode(" catch ("), placeholder.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"))) : !(this.ensure || this.recovery) ? [this.makeCode(' catch (_error) {}')] : [];
ensurePart = this.ensure ? [].concat(this.makeCode(" finally {\n"), this.ensure.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}")) : [];
return [].concat(this.makeCode("" + this.tab + "try {\n"), tryPart, this.makeCode("\n" + this.tab + "}"), catchPart, ensurePart);
};
@@ -2582,6 +2584,9 @@
if (this.range && this.pattern) {
this.name.error('cannot pattern match over range loops');
}
if (this.own && !this.object) {
this.index.error('cannot use own with for-in');
}
this.returns = false;
}

View File

@@ -1,6 +1,8 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments;
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
repeat = require('./helpers').repeat;
exports.OptionParser = OptionParser = (function() {
function OptionParser(rules, banner) {
@@ -66,7 +68,7 @@
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
rule = _ref[_i];
spaces = 15 - rule.longFlag.length;
spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
spaces = spaces > 0 ? repeat(' ', spaces) : '';
letPart = rule.shortFlag ? rule.shortFlag + ', ' : ' ';
lines.push(' ' + letPart + rule.longFlag + spaces + rule.description);
}

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,10 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var CoffeeScript, addMultilineHandler, merge, nodeREPL, prettyErrorMessage, replDefaults, vm, _ref;
var CoffeeScript, addHistory, addMultilineHandler, fs, merge, nodeREPL, path, prettyErrorMessage, replDefaults, vm, _ref;
fs = require('fs');
path = require('path');
vm = require('vm');
@@ -12,6 +16,8 @@
replDefaults = {
prompt: 'coffee> ',
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
historyMaxInputSize: 10240,
"eval": function(input, context, filename, cb) {
var Assign, Block, Literal, Value, ast, err, js, _ref1;
input = input.replace(/\uFF00/g, '\n');
@@ -86,6 +92,44 @@
});
};
addHistory = function(repl, filename, maxSize) {
var buffer, fd, lastLine, readFd, size, stat;
lastLine = null;
try {
stat = fs.statSync(filename);
size = Math.min(maxSize, stat.size);
readFd = fs.openSync(filename, 'r');
buffer = new Buffer(size);
fs.readSync(readFd, buffer, 0, size, stat.size - size);
repl.rli.history = buffer.toString().split('\n').reverse();
if (stat.size > maxSize) {
repl.rli.history.pop();
}
if (repl.rli.history[0] === '') {
repl.rli.history.shift();
}
repl.rli.historyIndex = -1;
lastLine = repl.rli.history[0];
} catch (_error) {}
fd = fs.openSync(filename, 'a');
repl.rli.addListener('line', function(code) {
if (code && code.length && code !== '.history' && lastLine !== code) {
fs.write(fd, "" + code + "\n");
return lastLine = code;
}
});
repl.rli.on('exit', function() {
return fs.close(fd);
});
return repl.commands['.history'] = {
help: 'Show command history',
action: function() {
repl.outputStream.write("" + (repl.rli.history.slice(0).reverse().join('\n')) + "\n");
return repl.displayPrompt();
}
};
};
module.exports = {
start: function(opts) {
var build, major, minor, repl, _ref1;
@@ -105,6 +149,9 @@
return repl.outputStream.write('\n');
});
addMultilineHandler(repl);
if (opts.historyFile) {
addHistory(repl, opts.historyFile, opts.historyMaxInputSize);
}
return repl;
}
};

View File

@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__slice = [].slice;
@@ -273,7 +273,7 @@
startImplicitCall(i + 1);
return forward(2);
}
if (this.matchTags(i, IMPLICIT_FUNC, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) {
if (__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.matchTags(i + 1, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) {
startImplicitCall(i + 1);
stack.push(['INDENT', i + 2]);
return forward(3);
@@ -358,14 +358,14 @@
var action, condition, indent, outdent, starter;
starter = indent = outdent = null;
condition = function(token, i) {
var _ref;
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
var _ref, _ref1;
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref1 = token[0]) === 'CATCH' || _ref1 === 'FINALLY') && (starter === '->' || starter === '=>'));
};
action = function(token, i) {
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
};
return this.scanTokens(function(token, i, tokens) {
var tag, _ref, _ref1;
var j, tag, _i, _ref, _ref1;
tag = token[0];
if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') {
tokens.splice(i, 1);
@@ -375,9 +375,14 @@
tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation())));
return 2;
}
if (tag === 'CATCH' && ((_ref = this.tag(i + 2)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) {
tokens.splice.apply(tokens, [i + 2, 0].concat(__slice.call(this.indentation())));
return 4;
if (tag === 'CATCH') {
for (j = _i = 1; _i <= 2; j = ++_i) {
if (!((_ref = this.tag(i + j)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) {
continue;
}
tokens.splice.apply(tokens, [i + j, 0].concat(__slice.call(this.indentation())));
return 2 + j;
}
}
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
starter = tag;
@@ -469,8 +474,6 @@
IMPLICIT_UNSPACED_CALL = ['+', '-'];
IMPLICIT_BLOCK = ['->', '=>', '{', '[', ','];
IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR'];
SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN'];

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var Scope, extend, last, _ref;

View File

@@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
(function() {
var LineMap, SourceMap;