Merge branch 'master' of git://github.com/StanAngeloff/coffee-script

This commit is contained in:
Jeremy Ashkenas
2010-09-21 08:06:12 -04:00
6 changed files with 20 additions and 17 deletions

View File

@@ -69,10 +69,10 @@
return fs.stat(source, function(err, stats) {
if (stats.isDirectory()) {
return fs.readdir(source, function(err, files) {
var _i2, _len2, _ref3, _result2, file;
var _j, _len2, _ref3, _result2, file;
_result2 = []; _ref3 = files;
for (_i2 = 0, _len2 = _ref3.length; _i2 < _len2; _i2++) {
file = _ref3[_i2];
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
file = _ref3[_j];
_result2.push(compile(path.join(source, file)));
}
return _result2;

View File

@@ -1,5 +1,5 @@
(function() {
var Parser, _i, _i2, _len, _len2, _ref, _ref2, _ref3, _result, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
var Parser, _i, _j, _len, _len2, _ref, _ref2, _ref3, _result, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
var __hasProp = Object.prototype.hasOwnProperty;
Parser = require('jison').Parser;
unwrap = /function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
@@ -623,8 +623,8 @@
alt = _ref2[_i];
_result.push((function() {
_ref3 = alt[0].split(' ');
for (_i2 = 0, _len2 = _ref3.length; _i2 < _len2; _i2++) {
token = _ref3[_i2];
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
token = _ref3[_j];
if (!(grammar[token])) {
tokens.push(token);
}

View File

@@ -116,7 +116,7 @@
return '\n' + idt + (override || this["class"]) + children;
};
BaseNode.prototype.eachChild = function(func) {
var _i, _i2, _len, _len2, _ref2, _ref3, _result, attr, child;
var _i, _j, _len, _len2, _ref2, _ref3, _result, attr, child;
if (!(this.children)) {
return null;
}
@@ -125,8 +125,8 @@
attr = _ref2[_i];
if (this[attr]) {
_ref3 = flatten([this[attr]]);
for (_i2 = 0, _len2 = _ref3.length; _i2 < _len2; _i2++) {
child = _ref3[_i2];
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
child = _ref3[_j];
if (func(child) === false) {
return null;
}
@@ -1768,7 +1768,7 @@
return this;
};
SwitchNode.prototype.compileNode = function(o) {
var _i, _i2, _len, _len2, _ref2, _ref3, block, code, condition, conditions, exprs, idt, pair;
var _i, _j, _len, _len2, _ref2, _ref3, block, code, condition, conditions, exprs, idt, pair;
idt = (o.indent = this.idt(1));
o.top = true;
code = ("" + (this.tab) + "switch (" + (this.subject.compile(o)) + ") {");
@@ -1780,8 +1780,8 @@
block = _ref3[1];
exprs = block.expressions;
_ref3 = flatten([conditions]);
for (_i2 = 0, _len2 = _ref3.length; _i2 < _len2; _i2++) {
condition = _ref3[_i2];
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
condition = _ref3[_j];
if (this.tags.subjectless) {
condition = new OpNode('!!', new ParentheticalNode(condition));
}

View File

@@ -94,7 +94,7 @@
};
};
normalizeArguments = function(args) {
var _i, _i2, _len, _len2, _ref, _ref2, arg, l, match, result;
var _i, _j, _len, _len2, _ref, _ref2, arg, l, match, result;
args = args.slice(0);
result = [];
_ref = args;
@@ -102,8 +102,8 @@
arg = _ref[_i];
if (match = arg.match(MULTI_FLAG)) {
_ref2 = match[1].split('');
for (_i2 = 0, _len2 = _ref2.length; _i2 < _len2; _i2++) {
l = _ref2[_i2];
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
l = _ref2[_j];
result.push('-' + l);
}
} else {

View File

@@ -65,7 +65,7 @@
return !!(this.parent && this.parent.check(name));
};
Scope.prototype.temporary = function(type, index) {
return '_' + type + (index > 1 ? index : '');
return type.length > 1 ? '_' + type + (index > 1 ? index : '') : '_' + (index + parseInt(type, 36)).toString(36).replace(/\d/g, 'a');
};
Scope.prototype.freeVariable = function(type) {
var index, temp;

View File

@@ -62,7 +62,10 @@ exports.Scope = class Scope
# Generate a temporary variable name at the given index.
temporary: (type, index) ->
'_' + type + if index > 1 then index else ''
if type.length > 1
'_' + type + if index > 1 then index else ''
else
'_' + (index + parseInt type, 36).toString(36).replace /\d/g, 'a'
# If we need to store an intermediate result, find an available name for a
# compiler-generated variable. `_var`, `_var2`, and so on...