mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
Implementing sethaurus' suggestion for better temp variable names -- getting rid of the numbers.
This commit is contained in:
@@ -50,14 +50,14 @@
|
|||||||
};
|
};
|
||||||
// Pretty-print a token stream.
|
// Pretty-print a token stream.
|
||||||
exports.print_tokens = function print_tokens(tokens) {
|
exports.print_tokens = function print_tokens(tokens) {
|
||||||
var _1, _2, _3, strings, token;
|
var _a, _b, _c, strings, token;
|
||||||
strings = (function() {
|
strings = (function() {
|
||||||
_1 = []; _2 = tokens;
|
_a = []; _b = tokens;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
token = _2[_3];
|
token = _b[_c];
|
||||||
_1.push('[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']');
|
_a.push('[' + token[0] + ' ' + token[1].toString().replace(/\n/, '\\n') + ']');
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
return puts(strings.join(' '));
|
return puts(strings.join(' '));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var Parser, _1, _2, _3, _4, _5, _6, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap;
|
var Parser, _a, _b, _c, _d, _e, _f, bnf, grammar, name, non_terminal, o, operators, option, part, tokens, unwrap;
|
||||||
var __hasProp = Object.prototype.hasOwnProperty;
|
var __hasProp = Object.prototype.hasOwnProperty;
|
||||||
Parser = require('jison').Parser;
|
Parser = require('jison').Parser;
|
||||||
// DSL ===================================================================
|
// DSL ===================================================================
|
||||||
@@ -523,24 +523,24 @@
|
|||||||
// Make the Jison parser.
|
// Make the Jison parser.
|
||||||
bnf = {};
|
bnf = {};
|
||||||
tokens = [];
|
tokens = [];
|
||||||
_1 = grammar;
|
_a = grammar;
|
||||||
for (name in _1) if (__hasProp.call(_1, name)) {
|
for (name in _a) if (__hasProp.call(_a, name)) {
|
||||||
non_terminal = _1[name];
|
non_terminal = _a[name];
|
||||||
bnf[name] = (function() {
|
bnf[name] = (function() {
|
||||||
_2 = []; _3 = non_terminal;
|
_b = []; _c = non_terminal;
|
||||||
for (_4 = 0; _4 < _3.length; _4++) {
|
for (_d = 0; _d < _c.length; _d++) {
|
||||||
option = _3[_4];
|
option = _c[_d];
|
||||||
_2.push((function() {
|
_b.push((function() {
|
||||||
_5 = option[0].split(" ");
|
_e = option[0].split(" ");
|
||||||
for (_6 = 0; _6 < _5.length; _6++) {
|
for (_f = 0; _f < _e.length; _f++) {
|
||||||
part = _5[_6];
|
part = _e[_f];
|
||||||
!grammar[part] ? tokens.push(part) : null;
|
!grammar[part] ? tokens.push(part) : null;
|
||||||
}
|
}
|
||||||
name === "Root" ? (option[1] = "return " + option[1]) : null;
|
name === "Root" ? (option[1] = "return " + option[1]) : null;
|
||||||
return option;
|
return option;
|
||||||
}).call(this));
|
}).call(this));
|
||||||
}
|
}
|
||||||
return _2;
|
return _b;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
}
|
}
|
||||||
tokens = tokens.join(" ");
|
tokens = tokens.join(" ");
|
||||||
|
|||||||
@@ -30,16 +30,16 @@
|
|||||||
};
|
};
|
||||||
// Quickie inheritance convenience wrapper to reduce typing.
|
// Quickie inheritance convenience wrapper to reduce typing.
|
||||||
inherit = function inherit(parent, props) {
|
inherit = function inherit(parent, props) {
|
||||||
var _1, _2, klass, name, prop;
|
var _a, _b, klass, name, prop;
|
||||||
klass = del(props, 'constructor');
|
klass = del(props, 'constructor');
|
||||||
_1 = function(){};
|
_a = function(){};
|
||||||
_1.prototype = parent.prototype;
|
_a.prototype = parent.prototype;
|
||||||
klass.__superClass__ = parent.prototype;
|
klass.__superClass__ = parent.prototype;
|
||||||
klass.prototype = new _1();
|
klass.prototype = new _a();
|
||||||
klass.prototype.constructor = klass;
|
klass.prototype.constructor = klass;
|
||||||
_2 = props;
|
_b = props;
|
||||||
for (name in _2) if (__hasProp.call(_2, name)) {
|
for (name in _b) if (__hasProp.call(_b, name)) {
|
||||||
prop = _2[name];
|
prop = _b[name];
|
||||||
((klass.prototype[name] = prop));
|
((klass.prototype[name] = prop));
|
||||||
}
|
}
|
||||||
return klass;
|
return klass;
|
||||||
@@ -86,20 +86,20 @@
|
|||||||
};
|
};
|
||||||
// Quick short method for the current indentation level, plus tabbing in.
|
// Quick short method for the current indentation level, plus tabbing in.
|
||||||
Node.prototype.idt = function idt(tabs) {
|
Node.prototype.idt = function idt(tabs) {
|
||||||
var _1, _2, _3, _4, i, idt;
|
var _a, _b, _c, _d, i, idt;
|
||||||
idt = (this.indent || '');
|
idt = (this.indent || '');
|
||||||
_3 = 0; _4 = (tabs || 0);
|
_c = 0; _d = (tabs || 0);
|
||||||
for (_2=0, i=_3; (_3 <= _4 ? i < _4 : i > _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
|
for (_b=0, i=_c; (_c <= _d ? i < _d : i > _d); (_c <= _d ? i += 1 : i -= 1), _b++) {
|
||||||
idt += TAB;
|
idt += TAB;
|
||||||
}
|
}
|
||||||
return idt;
|
return idt;
|
||||||
};
|
};
|
||||||
// Does this node, or any of its children, contain a node of a certain kind?
|
// Does this node, or any of its children, contain a node of a certain kind?
|
||||||
Node.prototype.contains = function contains(block) {
|
Node.prototype.contains = function contains(block) {
|
||||||
var _1, _2, node;
|
var _a, _b, node;
|
||||||
_1 = this.children;
|
_a = this.children;
|
||||||
for (_2 = 0; _2 < _1.length; _2++) {
|
for (_b = 0; _b < _a.length; _b++) {
|
||||||
node = _1[_2];
|
node = _a[_b];
|
||||||
if (block(node)) {
|
if (block(node)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -168,14 +168,14 @@
|
|||||||
},
|
},
|
||||||
// Compile each expression in the Expressions body.
|
// Compile each expression in the Expressions body.
|
||||||
compile_node: function compile_node(o) {
|
compile_node: function compile_node(o) {
|
||||||
var _1, _2, _3, node;
|
var _a, _b, _c, node;
|
||||||
return ((function() {
|
return ((function() {
|
||||||
_1 = []; _2 = this.expressions;
|
_a = []; _b = this.expressions;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
node = _2[_3];
|
node = _b[_c];
|
||||||
_1.push(this.compile_expression(node, _.clone(o)));
|
_a.push(this.compile_expression(node, _.clone(o)));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this)).join("\n");
|
}).call(this)).join("\n");
|
||||||
},
|
},
|
||||||
// If this is the top-level Expressions, wrap everything in a safety closure.
|
// If this is the top-level Expressions, wrap everything in a safety closure.
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
return this.base.is_statement && this.base.is_statement() && !this.has_properties();
|
return this.base.is_statement && this.base.is_statement() && !this.has_properties();
|
||||||
},
|
},
|
||||||
compile_node: function compile_node(o) {
|
compile_node: function compile_node(o) {
|
||||||
var _1, _2, baseline, code, only, part, parts, prop, props, soaked, temp;
|
var _a, _b, baseline, code, only, part, parts, prop, props, soaked, temp;
|
||||||
soaked = false;
|
soaked = false;
|
||||||
only = del(o, 'only_first');
|
only = del(o, 'only_first');
|
||||||
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
|
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
|
||||||
@@ -324,9 +324,9 @@
|
|||||||
baseline = '(' + baseline + ')';
|
baseline = '(' + baseline + ')';
|
||||||
}
|
}
|
||||||
parts = [baseline];
|
parts = [baseline];
|
||||||
_1 = props;
|
_a = props;
|
||||||
for (_2 = 0; _2 < _1.length; _2++) {
|
for (_b = 0; _b < _a.length; _b++) {
|
||||||
prop = _1[_2];
|
prop = _a[_b];
|
||||||
if (prop instanceof AccessorNode && prop.soak) {
|
if (prop instanceof AccessorNode && prop.soak) {
|
||||||
soaked = true;
|
soaked = true;
|
||||||
if (this.base instanceof CallNode && prop === props[0]) {
|
if (this.base instanceof CallNode && prop === props[0]) {
|
||||||
@@ -383,19 +383,19 @@
|
|||||||
},
|
},
|
||||||
// Compile a vanilla function call.
|
// Compile a vanilla function call.
|
||||||
compile_node: function compile_node(o) {
|
compile_node: function compile_node(o) {
|
||||||
var _1, _2, _3, arg, args;
|
var _a, _b, _c, arg, args;
|
||||||
if (_.any(this.args, function(a) {
|
if (_.any(this.args, function(a) {
|
||||||
return a instanceof SplatNode;
|
return a instanceof SplatNode;
|
||||||
})) {
|
})) {
|
||||||
return this.compile_splat(o);
|
return this.compile_splat(o);
|
||||||
}
|
}
|
||||||
args = ((function() {
|
args = ((function() {
|
||||||
_1 = []; _2 = this.args;
|
_a = []; _b = this.args;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
arg = _2[_3];
|
arg = _b[_c];
|
||||||
_1.push(arg.compile(o));
|
_a.push(arg.compile(o));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this)).join(', ');
|
}).call(this)).join(', ');
|
||||||
if (this.variable === 'super') {
|
if (this.variable === 'super') {
|
||||||
return this.compile_super(args, o);
|
return this.compile_super(args, o);
|
||||||
@@ -412,20 +412,20 @@
|
|||||||
},
|
},
|
||||||
// Compile a function call being passed variable arguments.
|
// Compile a function call being passed variable arguments.
|
||||||
compile_splat: function compile_splat(o) {
|
compile_splat: function compile_splat(o) {
|
||||||
var _1, _2, arg, args, code, i, meth, obj;
|
var _a, _b, arg, args, code, i, meth, obj;
|
||||||
meth = this.variable.compile(o);
|
meth = this.variable.compile(o);
|
||||||
obj = this.variable.source || 'this';
|
obj = this.variable.source || 'this';
|
||||||
args = (function() {
|
args = (function() {
|
||||||
_1 = []; _2 = this.args;
|
_a = []; _b = this.args;
|
||||||
for (i = 0; i < _2.length; i++) {
|
for (i = 0; i < _b.length; i++) {
|
||||||
arg = _2[i];
|
arg = _b[i];
|
||||||
_1.push((function() {
|
_a.push((function() {
|
||||||
code = arg.compile(o);
|
code = arg.compile(o);
|
||||||
code = arg instanceof SplatNode ? code : '[' + code + ']';
|
code = arg instanceof SplatNode ? code : '[' + code + ']';
|
||||||
return i === 0 ? code : '.concat(' + code + ')';
|
return i === 0 ? code : '.concat(' + code + ')';
|
||||||
}).call(this));
|
}).call(this));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
return this.prefix + meth + '.apply(' + obj + ', ' + args.join('') + ')';
|
return this.prefix + meth + '.apply(' + obj + ', ' + args.join('') + ')';
|
||||||
},
|
},
|
||||||
@@ -564,24 +564,24 @@
|
|||||||
// AssignNodes get interleaved correctly, with no trailing commas or
|
// AssignNodes get interleaved correctly, with no trailing commas or
|
||||||
// commas affixed to comments. TODO: Extract this and add it to ArrayNode.
|
// commas affixed to comments. TODO: Extract this and add it to ArrayNode.
|
||||||
compile_node: function compile_node(o) {
|
compile_node: function compile_node(o) {
|
||||||
var _1, _2, _3, _4, _5, i, indent, inner, join, last_noncom, non_comments, prop, props;
|
var _a, _b, _c, _d, _e, i, indent, inner, join, last_noncom, non_comments, prop, props;
|
||||||
o.indent = this.idt(1);
|
o.indent = this.idt(1);
|
||||||
non_comments = (function() {
|
non_comments = (function() {
|
||||||
_1 = []; _2 = this.properties;
|
_a = []; _b = this.properties;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
prop = _2[_3];
|
prop = _b[_c];
|
||||||
if (!(prop instanceof CommentNode)) {
|
if (!(prop instanceof CommentNode)) {
|
||||||
_1.push(prop);
|
_a.push(prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
last_noncom = non_comments[non_comments.length - 1];
|
last_noncom = non_comments[non_comments.length - 1];
|
||||||
props = (function() {
|
props = (function() {
|
||||||
_4 = []; _5 = this.properties;
|
_d = []; _e = this.properties;
|
||||||
for (i = 0; i < _5.length; i++) {
|
for (i = 0; i < _e.length; i++) {
|
||||||
prop = _5[i];
|
prop = _e[i];
|
||||||
_4.push((function() {
|
_d.push((function() {
|
||||||
join = ",\n";
|
join = ",\n";
|
||||||
if ((prop === last_noncom) || (prop instanceof CommentNode)) {
|
if ((prop === last_noncom) || (prop instanceof CommentNode)) {
|
||||||
join = "\n";
|
join = "\n";
|
||||||
@@ -593,7 +593,7 @@
|
|||||||
return indent + prop.compile(o) + join;
|
return indent + prop.compile(o) + join;
|
||||||
}).call(this));
|
}).call(this));
|
||||||
}
|
}
|
||||||
return _4;
|
return _d;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
props = props.join('');
|
props = props.join('');
|
||||||
inner = props ? '\n' + props + '\n' + this.idt() : '';
|
inner = props ? '\n' + props + '\n' + this.idt() : '';
|
||||||
@@ -608,13 +608,13 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
compile_node: function compile_node(o) {
|
compile_node: function compile_node(o) {
|
||||||
var _1, _2, code, ending, i, obj, objects;
|
var _a, _b, code, ending, i, obj, objects;
|
||||||
o.indent = this.idt(1);
|
o.indent = this.idt(1);
|
||||||
objects = (function() {
|
objects = (function() {
|
||||||
_1 = []; _2 = this.objects;
|
_a = []; _b = this.objects;
|
||||||
for (i = 0; i < _2.length; i++) {
|
for (i = 0; i < _b.length; i++) {
|
||||||
obj = _2[i];
|
obj = _b[i];
|
||||||
_1.push((function() {
|
_a.push((function() {
|
||||||
code = obj.compile(o);
|
code = obj.compile(o);
|
||||||
if (obj instanceof CommentNode) {
|
if (obj instanceof CommentNode) {
|
||||||
return '\n' + code + '\n' + o.indent;
|
return '\n' + code + '\n' + o.indent;
|
||||||
@@ -625,7 +625,7 @@
|
|||||||
}
|
}
|
||||||
}).call(this));
|
}).call(this));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
objects = objects.join('');
|
objects = objects.join('');
|
||||||
ending = objects.indexOf('\n') >= 0 ? "\n" + this.idt() + ']' : ']';
|
ending = objects.indexOf('\n') >= 0 ? "\n" + this.idt() + ']' : ']';
|
||||||
@@ -718,19 +718,19 @@
|
|||||||
// object literals to a value. Peeks at their properties to assign inner names.
|
// object literals to a value. Peeks at their properties to assign inner names.
|
||||||
// See: http://wiki.ecmascript.org/doku.php?id=harmony:destructuring
|
// See: http://wiki.ecmascript.org/doku.php?id=harmony:destructuring
|
||||||
compile_pattern_match: function compile_pattern_match(o) {
|
compile_pattern_match: function compile_pattern_match(o) {
|
||||||
var _1, _2, access_class, assigns, i, idx, obj, val, val_var;
|
var _a, _b, access_class, assigns, i, idx, obj, val, val_var;
|
||||||
val_var = o.scope.free_variable();
|
val_var = o.scope.free_variable();
|
||||||
assigns = [this.idt() + val_var + ' = ' + this.value.compile(o) + ';'];
|
assigns = [this.idt() + val_var + ' = ' + this.value.compile(o) + ';'];
|
||||||
o.top = true;
|
o.top = true;
|
||||||
o.as_statement = true;
|
o.as_statement = true;
|
||||||
_1 = this.variable.base.objects;
|
_a = this.variable.base.objects;
|
||||||
for (i = 0; i < _1.length; i++) {
|
for (i = 0; i < _a.length; i++) {
|
||||||
obj = _1[i];
|
obj = _a[i];
|
||||||
idx = i;
|
idx = i;
|
||||||
if (this.variable.is_object()) {
|
if (this.variable.is_object()) {
|
||||||
_2 = [obj.value, obj.variable.base];
|
_b = [obj.value, obj.variable.base];
|
||||||
obj = _2[0];
|
obj = _b[0];
|
||||||
idx = _2[1];
|
idx = _b[1];
|
||||||
}
|
}
|
||||||
access_class = this.variable.is_array() ? IndexNode : AccessorNode;
|
access_class = this.variable.is_array() ? IndexNode : AccessorNode;
|
||||||
if (obj instanceof SplatNode) {
|
if (obj instanceof SplatNode) {
|
||||||
@@ -769,7 +769,7 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
compile_node: function compile_node(o) {
|
compile_node: function compile_node(o) {
|
||||||
var _1, _2, _3, _4, _5, code, func, inner, name_part, param, params, shared_scope, splat, top;
|
var _a, _b, _c, _d, _e, code, func, inner, name_part, param, params, shared_scope, splat, top;
|
||||||
shared_scope = del(o, 'shared_scope');
|
shared_scope = del(o, 'shared_scope');
|
||||||
top = del(o, 'top');
|
top = del(o, 'top');
|
||||||
o.scope = shared_scope || new Scope(o.scope, this.body, this);
|
o.scope = shared_scope || new Scope(o.scope, this.body, this);
|
||||||
@@ -784,16 +784,16 @@
|
|||||||
this.body.unshift(splat);
|
this.body.unshift(splat);
|
||||||
}
|
}
|
||||||
params = ((function() {
|
params = ((function() {
|
||||||
_1 = []; _2 = this.params;
|
_a = []; _b = this.params;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
param = _2[_3];
|
param = _b[_c];
|
||||||
_1.push(param.compile(o));
|
_a.push(param.compile(o));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this));
|
}).call(this));
|
||||||
_4 = params;
|
_d = params;
|
||||||
for (_5 = 0; _5 < _4.length; _5++) {
|
for (_e = 0; _e < _d.length; _e++) {
|
||||||
param = _4[_5];
|
param = _d[_e];
|
||||||
(o.scope.parameter(param));
|
(o.scope.parameter(param));
|
||||||
}
|
}
|
||||||
code = this.body.expressions.length ? '\n' + this.body.compile_with_declarations(o) + '\n' : '';
|
code = this.body.expressions.length ? '\n' + this.body.compile_with_declarations(o) + '\n' : '';
|
||||||
@@ -923,20 +923,20 @@
|
|||||||
// Mimic Python's chained comparisons. See:
|
// Mimic Python's chained comparisons. See:
|
||||||
// http://docs.python.org/reference/expressions.html#notin
|
// http://docs.python.org/reference/expressions.html#notin
|
||||||
compile_chain: function compile_chain(o) {
|
compile_chain: function compile_chain(o) {
|
||||||
var _1, shared;
|
var _a, shared;
|
||||||
shared = this.first.unwrap().second;
|
shared = this.first.unwrap().second;
|
||||||
if (shared instanceof CallNode) {
|
if (shared instanceof CallNode) {
|
||||||
_1 = shared.compile_reference(o);
|
_a = shared.compile_reference(o);
|
||||||
this.first.second = _1[0];
|
this.first.second = _a[0];
|
||||||
shared = _1[1];
|
shared = _a[1];
|
||||||
}
|
}
|
||||||
return '(' + this.first.compile(o) + ') && (' + shared.compile(o) + ' ' + this.operator + ' ' + this.second.compile(o) + ')';
|
return '(' + this.first.compile(o) + ') && (' + shared.compile(o) + ' ' + this.operator + ' ' + this.second.compile(o) + ')';
|
||||||
},
|
},
|
||||||
compile_assignment: function compile_assignment(o) {
|
compile_assignment: function compile_assignment(o) {
|
||||||
var _1, first, second;
|
var _a, first, second;
|
||||||
_1 = [this.first.compile(o), this.second.compile(o)];
|
_a = [this.first.compile(o), this.second.compile(o)];
|
||||||
first = _1[0];
|
first = _a[0];
|
||||||
second = _1[1];
|
second = _a[1];
|
||||||
if (first.match(IDENTIFIER)) {
|
if (first.match(IDENTIFIER)) {
|
||||||
o.scope.find(first);
|
o.scope.find(first);
|
||||||
}
|
}
|
||||||
@@ -946,10 +946,10 @@
|
|||||||
return first + ' = ' + first + ' ' + this.operator.substr(0, 2) + ' ' + second;
|
return first + ' = ' + first + ' ' + this.operator.substr(0, 2) + ' ' + second;
|
||||||
},
|
},
|
||||||
compile_existence: function compile_existence(o) {
|
compile_existence: function compile_existence(o) {
|
||||||
var _1, first, second;
|
var _a, first, second;
|
||||||
_1 = [this.first.compile(o), this.second.compile(o)];
|
_a = [this.first.compile(o), this.second.compile(o)];
|
||||||
first = _1[0];
|
first = _a[0];
|
||||||
second = _1[1];
|
second = _a[1];
|
||||||
return ExistenceNode.compile_test(o, this.first) + ' ? ' + first + ' : ' + second;
|
return ExistenceNode.compile_test(o, this.first) + ' ? ' + first + ' : ' + second;
|
||||||
},
|
},
|
||||||
compile_unary: function compile_unary(o) {
|
compile_unary: function compile_unary(o) {
|
||||||
@@ -1007,14 +1007,14 @@
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
ExistenceNode.compile_test = function compile_test(o, variable) {
|
ExistenceNode.compile_test = function compile_test(o, variable) {
|
||||||
var _1, _2, first, second;
|
var _a, _b, first, second;
|
||||||
_1 = [variable, variable];
|
_a = [variable, variable];
|
||||||
first = _1[0];
|
first = _a[0];
|
||||||
second = _1[1];
|
second = _a[1];
|
||||||
if (variable instanceof CallNode) {
|
if (variable instanceof CallNode) {
|
||||||
_2 = variable.compile_reference(o);
|
_b = variable.compile_reference(o);
|
||||||
first = _2[0];
|
first = _b[0];
|
||||||
second = _2[1];
|
second = _b[1];
|
||||||
}
|
}
|
||||||
return '(typeof ' + first.compile(o) + ' !== "undefined" && ' + second.compile(o) + ' !== null)';
|
return '(typeof ' + first.compile(o) + ' !== "undefined" && ' + second.compile(o) + ' !== null)';
|
||||||
};
|
};
|
||||||
@@ -1042,7 +1042,7 @@
|
|||||||
ForNode = (exports.ForNode = inherit(Node, {
|
ForNode = (exports.ForNode = inherit(Node, {
|
||||||
type: 'For',
|
type: 'For',
|
||||||
constructor: function constructor(body, source, name, index) {
|
constructor: function constructor(body, source, name, index) {
|
||||||
var _1;
|
var _a;
|
||||||
this.body = body;
|
this.body = body;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.index = index || null;
|
this.index = index || null;
|
||||||
@@ -1051,9 +1051,9 @@
|
|||||||
this.step = source.step;
|
this.step = source.step;
|
||||||
this.object = !!source.object;
|
this.object = !!source.object;
|
||||||
if (this.object) {
|
if (this.object) {
|
||||||
_1 = [this.index, this.name];
|
_a = [this.index, this.name];
|
||||||
this.name = _1[0];
|
this.name = _a[0];
|
||||||
this.index = _1[1];
|
this.index = _a[1];
|
||||||
}
|
}
|
||||||
this.children = _.compact([this.body, this.source, this.filter]);
|
this.children = _.compact([this.body, this.source, this.filter]);
|
||||||
return this;
|
return this;
|
||||||
@@ -1164,15 +1164,15 @@
|
|||||||
},
|
},
|
||||||
// Rewrite a chain of IfNodes with their switch condition for equality.
|
// Rewrite a chain of IfNodes with their switch condition for equality.
|
||||||
rewrite_condition: function rewrite_condition(expression) {
|
rewrite_condition: function rewrite_condition(expression) {
|
||||||
var _1, _2, _3, cond;
|
var _a, _b, _c, cond;
|
||||||
this.condition = (function() {
|
this.condition = (function() {
|
||||||
if (this.multiple) {
|
if (this.multiple) {
|
||||||
_1 = []; _2 = this.condition;
|
_a = []; _b = this.condition;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
cond = _2[_3];
|
cond = _b[_c];
|
||||||
_1.push(new OpNode('is', expression, cond));
|
_a.push(new OpNode('is', expression, cond));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
} else {
|
} else {
|
||||||
return new OpNode('is', expression, this.condition);
|
return new OpNode('is', expression, this.condition);
|
||||||
}
|
}
|
||||||
@@ -1198,14 +1198,14 @@
|
|||||||
return this.statement = this.statement || !!(this.comment || this.tags.statement || this.body.is_statement() || (this.else_body && this.else_body.is_statement()));
|
return this.statement = this.statement || !!(this.comment || this.tags.statement || this.body.is_statement() || (this.else_body && this.else_body.is_statement()));
|
||||||
},
|
},
|
||||||
compile_condition: function compile_condition(o) {
|
compile_condition: function compile_condition(o) {
|
||||||
var _1, _2, _3, cond;
|
var _a, _b, _c, cond;
|
||||||
return ((function() {
|
return ((function() {
|
||||||
_1 = []; _2 = _.flatten([this.condition]);
|
_a = []; _b = _.flatten([this.condition]);
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
cond = _2[_3];
|
cond = _b[_c];
|
||||||
_1.push(cond.compile(o));
|
_a.push(cond.compile(o));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this)).join(' || ');
|
}).call(this)).join(' || ');
|
||||||
},
|
},
|
||||||
compile_node: function compile_node(o) {
|
compile_node: function compile_node(o) {
|
||||||
|
|||||||
@@ -14,14 +14,14 @@
|
|||||||
};
|
};
|
||||||
// Parse the argument array, calling defined callbacks, returning the remaining non-option arguments.
|
// Parse the argument array, calling defined callbacks, returning the remaining non-option arguments.
|
||||||
op.prototype.parse = function parse(args) {
|
op.prototype.parse = function parse(args) {
|
||||||
var _1, _2, arg, callback, is_option, results, rule, value;
|
var _a, _b, arg, callback, is_option, results, rule, value;
|
||||||
results = [];
|
results = [];
|
||||||
args = args.concat([]);
|
args = args.concat([]);
|
||||||
while (((arg = args.shift()))) {
|
while (((arg = args.shift()))) {
|
||||||
is_option = false;
|
is_option = false;
|
||||||
_1 = this.rules;
|
_a = this.rules;
|
||||||
for (_2 = 0; _2 < _1.length; _2++) {
|
for (_b = 0; _b < _a.length; _b++) {
|
||||||
rule = _1[_2];
|
rule = _a[_b];
|
||||||
if (rule.letter === arg || rule.flag === arg) {
|
if (rule.letter === arg || rule.flag === arg) {
|
||||||
callback = this.actions[rule.name];
|
callback = this.actions[rule.name];
|
||||||
value = rule.argument && args.shift();
|
value = rule.argument && args.shift();
|
||||||
@@ -40,13 +40,13 @@
|
|||||||
};
|
};
|
||||||
// Return the help text for this OptionParser, for --help and such.
|
// Return the help text for this OptionParser, for --help and such.
|
||||||
op.prototype.help = function help() {
|
op.prototype.help = function help() {
|
||||||
var _1, _2, _3, _4, has_shorts, lines, longest, rule, text;
|
var _a, _b, _c, _d, has_shorts, lines, longest, rule, text;
|
||||||
longest = 0;
|
longest = 0;
|
||||||
has_shorts = false;
|
has_shorts = false;
|
||||||
lines = [this.banner, '', this.options_title];
|
lines = [this.banner, '', this.options_title];
|
||||||
_1 = this.rules;
|
_a = this.rules;
|
||||||
for (_2 = 0; _2 < _1.length; _2++) {
|
for (_b = 0; _b < _a.length; _b++) {
|
||||||
rule = _1[_2];
|
rule = _a[_b];
|
||||||
if (rule.letter) {
|
if (rule.letter) {
|
||||||
has_shorts = true;
|
has_shorts = true;
|
||||||
}
|
}
|
||||||
@@ -54,9 +54,9 @@
|
|||||||
longest = rule.flag.length;
|
longest = rule.flag.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_3 = this.rules;
|
_c = this.rules;
|
||||||
for (_4 = 0; _4 < _3.length; _4++) {
|
for (_d = 0; _d < _c.length; _d++) {
|
||||||
rule = _3[_4];
|
rule = _c[_d];
|
||||||
has_shorts ? (text = rule.letter ? spaces(2) + rule.letter + ', ' : spaces(6)) : null;
|
has_shorts ? (text = rule.letter ? spaces(2) + rule.letter + ', ' : spaces(6)) : null;
|
||||||
text += spaces(longest, rule.flag) + spaces(3);
|
text += spaces(longest, rule.flag) + spaces(3);
|
||||||
text += rule.description;
|
text += rule.description;
|
||||||
@@ -72,18 +72,18 @@
|
|||||||
// Build rules from a list of valid switch tuples in the form:
|
// Build rules from a list of valid switch tuples in the form:
|
||||||
// [letter-flag, long-flag, help], or [long-flag, help].
|
// [letter-flag, long-flag, help], or [long-flag, help].
|
||||||
build_rules = function build_rules(rules) {
|
build_rules = function build_rules(rules) {
|
||||||
var _1, _2, _3, tuple;
|
var _a, _b, _c, tuple;
|
||||||
_1 = []; _2 = rules;
|
_a = []; _b = rules;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
tuple = _2[_3];
|
tuple = _b[_c];
|
||||||
_1.push((function() {
|
_a.push((function() {
|
||||||
if (tuple.length < 3) {
|
if (tuple.length < 3) {
|
||||||
tuple.unshift(null);
|
tuple.unshift(null);
|
||||||
}
|
}
|
||||||
return build_rule.apply(this, tuple);
|
return build_rule.apply(this, tuple);
|
||||||
}).call(this));
|
}).call(this));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
};
|
};
|
||||||
// Build a rule from a short-letter-flag, long-form-flag, and help text.
|
// Build a rule from a short-letter-flag, long-form-flag, and help text.
|
||||||
build_rule = function build_rule(letter, flag, description) {
|
build_rule = function build_rule(letter, flag, description) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _1, _2, _3, _4, _5, _6, _7, _8, pair, re;
|
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_START, EXPRESSION_TAIL, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, INVERSES, SINGLE_CLOSERS, SINGLE_LINERS, _a, _b, _c, _d, _e, _f, _g, _h, pair, re;
|
||||||
var __hasProp = Object.prototype.hasOwnProperty;
|
var __hasProp = Object.prototype.hasOwnProperty;
|
||||||
if (!((typeof process !== "undefined" && process !== null))) {
|
if (!((typeof process !== "undefined" && process !== null))) {
|
||||||
this.exports = this;
|
this.exports = this;
|
||||||
@@ -12,21 +12,21 @@
|
|||||||
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['PARAM_START', 'PARAM_END'], ['CALL_START', 'CALL_END'], ['INDEX_START', 'INDEX_END']];
|
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['PARAM_START', 'PARAM_END'], ['CALL_START', 'CALL_END'], ['INDEX_START', 'INDEX_END']];
|
||||||
// Tokens that signal the start of a balanced pair.
|
// Tokens that signal the start of a balanced pair.
|
||||||
EXPRESSION_START = (function() {
|
EXPRESSION_START = (function() {
|
||||||
_1 = []; _2 = BALANCED_PAIRS;
|
_a = []; _b = BALANCED_PAIRS;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
pair = _2[_3];
|
pair = _b[_c];
|
||||||
_1.push(pair[0]);
|
_a.push(pair[0]);
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
// Tokens that signal the end of a balanced pair.
|
// Tokens that signal the end of a balanced pair.
|
||||||
EXPRESSION_TAIL = (function() {
|
EXPRESSION_TAIL = (function() {
|
||||||
_4 = []; _5 = BALANCED_PAIRS;
|
_d = []; _e = BALANCED_PAIRS;
|
||||||
for (_6 = 0; _6 < _5.length; _6++) {
|
for (_f = 0; _f < _e.length; _f++) {
|
||||||
pair = _5[_6];
|
pair = _e[_f];
|
||||||
_4.push(pair[1]);
|
_d.push(pair[1]);
|
||||||
}
|
}
|
||||||
return _4;
|
return _d;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
// Tokens that indicate the close of a clause of an expression.
|
// Tokens that indicate the close of a clause of an expression.
|
||||||
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_TAIL);
|
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_TAIL);
|
||||||
@@ -37,9 +37,9 @@
|
|||||||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'TRY', 'DELETE', 'TYPEOF', 'SWITCH', 'TRUE', 'FALSE', 'YES', 'NO', 'ON', 'OFF', '!', '!!', 'NOT', '@', '->', '=>', '[', '(', '{'];
|
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'TRY', 'DELETE', 'TYPEOF', 'SWITCH', 'TRUE', 'FALSE', 'YES', 'NO', 'ON', 'OFF', '!', '!!', 'NOT', '@', '->', '=>', '[', '(', '{'];
|
||||||
// The inverse mappings of token pairs we're trying to fix up.
|
// The inverse mappings of token pairs we're trying to fix up.
|
||||||
INVERSES = {};
|
INVERSES = {};
|
||||||
_7 = BALANCED_PAIRS;
|
_g = BALANCED_PAIRS;
|
||||||
for (_8 = 0; _8 < _7.length; _8++) {
|
for (_h = 0; _h < _g.length; _h++) {
|
||||||
pair = _7[_8];
|
pair = _g[_h];
|
||||||
INVERSES[pair[0]] = pair[1];
|
INVERSES[pair[0]] = pair[1];
|
||||||
INVERSES[pair[1]] = pair[0];
|
INVERSES[pair[1]] = pair[0];
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@
|
|||||||
stack = [0];
|
stack = [0];
|
||||||
return this.scan_tokens((function(__this) {
|
return this.scan_tokens((function(__this) {
|
||||||
var __func = function(prev, token, post, i) {
|
var __func = function(prev, token, post, i) {
|
||||||
var _10, _11, _12, _9, idx, last, size, stack_pointer, tag, tmp;
|
var _i, _j, _k, _l, idx, last, size, stack_pointer, tag, tmp;
|
||||||
tag = token[0];
|
tag = token[0];
|
||||||
if (tag === 'INDENT') {
|
if (tag === 'INDENT') {
|
||||||
stack.push(0);
|
stack.push(0);
|
||||||
@@ -210,8 +210,8 @@
|
|||||||
if (stack[stack.length - 1] > 0 || tag === 'INDENT') {
|
if (stack[stack.length - 1] > 0 || tag === 'INDENT') {
|
||||||
idx = tag === 'OUTDENT' ? i + 1 : i;
|
idx = tag === 'OUTDENT' ? i + 1 : i;
|
||||||
stack_pointer = tag === 'INDENT' ? 2 : 1;
|
stack_pointer = tag === 'INDENT' ? 2 : 1;
|
||||||
_11 = 0; _12 = stack[stack.length - stack_pointer];
|
_k = 0; _l = stack[stack.length - stack_pointer];
|
||||||
for (_10=0, tmp=_11; (_11 <= _12 ? tmp < _12 : tmp > _12); (_11 <= _12 ? tmp += 1 : tmp -= 1), _10++) {
|
for (_j=0, tmp=_k; (_k <= _l ? tmp < _l : tmp > _l); (_k <= _l ? tmp += 1 : tmp -= 1), _j++) {
|
||||||
this.tokens.splice(idx, 0, ['CALL_END', ')', token[2]]);
|
this.tokens.splice(idx, 0, ['CALL_END', ')', token[2]]);
|
||||||
}
|
}
|
||||||
size = stack[stack.length - stack_pointer] + 1;
|
size = stack[stack.length - stack_pointer] + 1;
|
||||||
@@ -275,17 +275,17 @@
|
|||||||
// Ensure that all listed pairs of tokens are correctly balanced throughout
|
// Ensure that all listed pairs of tokens are correctly balanced throughout
|
||||||
// the course of the token stream.
|
// the course of the token stream.
|
||||||
re.prototype.ensure_balance = function ensure_balance(pairs) {
|
re.prototype.ensure_balance = function ensure_balance(pairs) {
|
||||||
var _10, _9, key, levels, unclosed, value;
|
var _i, _j, key, levels, unclosed, value;
|
||||||
levels = {};
|
levels = {};
|
||||||
this.scan_tokens((function(__this) {
|
this.scan_tokens((function(__this) {
|
||||||
var __func = function(prev, token, post, i) {
|
var __func = function(prev, token, post, i) {
|
||||||
var _10, _11, _9, close, open;
|
var _i, _j, _k, close, open;
|
||||||
_9 = pairs;
|
_i = pairs;
|
||||||
for (_10 = 0; _10 < _9.length; _10++) {
|
for (_j = 0; _j < _i.length; _j++) {
|
||||||
pair = _9[_10];
|
pair = _i[_j];
|
||||||
_11 = pair;
|
_k = pair;
|
||||||
open = _11[0];
|
open = _k[0];
|
||||||
close = _11[1];
|
close = _k[1];
|
||||||
levels[open] = levels[open] || 0;
|
levels[open] = levels[open] || 0;
|
||||||
if (token[0] === open) {
|
if (token[0] === open) {
|
||||||
levels[open] += 1;
|
levels[open] += 1;
|
||||||
@@ -304,14 +304,14 @@
|
|||||||
});
|
});
|
||||||
})(this));
|
})(this));
|
||||||
unclosed = (function() {
|
unclosed = (function() {
|
||||||
_9 = []; _10 = levels;
|
_i = []; _j = levels;
|
||||||
for (key in _10) if (__hasProp.call(_10, key)) {
|
for (key in _j) if (__hasProp.call(_j, key)) {
|
||||||
value = _10[key];
|
value = _j[key];
|
||||||
if (value > 0) {
|
if (value > 0) {
|
||||||
_9.push(key);
|
_i.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _9;
|
return _i;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
if (unclosed.length) {
|
if (unclosed.length) {
|
||||||
throw new Error("unclosed " + unclosed[0]);
|
throw new Error("unclosed " + unclosed[0]);
|
||||||
@@ -331,12 +331,12 @@
|
|||||||
// up balanced in the end.
|
// up balanced in the end.
|
||||||
//
|
//
|
||||||
re.prototype.rewrite_closing_parens = function rewrite_closing_parens() {
|
re.prototype.rewrite_closing_parens = function rewrite_closing_parens() {
|
||||||
var _9, debt, key, stack, val;
|
var _i, debt, key, stack, val;
|
||||||
stack = [];
|
stack = [];
|
||||||
debt = {};
|
debt = {};
|
||||||
_9 = INVERSES;
|
_i = INVERSES;
|
||||||
for (key in _9) if (__hasProp.call(_9, key)) {
|
for (key in _i) if (__hasProp.call(_i, key)) {
|
||||||
val = _9[key];
|
val = _i[key];
|
||||||
((debt[key] = 0));
|
((debt[key] = 0));
|
||||||
}
|
}
|
||||||
return this.scan_tokens((function(__this) {
|
return this.scan_tokens((function(__this) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
this.expressions = expressions;
|
this.expressions = expressions;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.variables = {};
|
this.variables = {};
|
||||||
this.temp_variable = this.parent ? this.parent.temp_variable : 1;
|
this.temp_var = this.parent ? this.parent.temp_var : '_a';
|
||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
// Look up a variable in lexical scope, or declare it if not found.
|
// Look up a variable in lexical scope, or declare it if not found.
|
||||||
@@ -47,13 +47,13 @@
|
|||||||
};
|
};
|
||||||
// Find an available, short, name for a compiler-generated variable.
|
// Find an available, short, name for a compiler-generated variable.
|
||||||
Scope.prototype.free_variable = function free_variable() {
|
Scope.prototype.free_variable = function free_variable() {
|
||||||
var id;
|
var ordinal;
|
||||||
id = '_' + this.temp_variable;
|
while (this.check(this.temp_var)) {
|
||||||
while (this.check(id)) {
|
ordinal = 1 + parseInt(this.temp_var.substr(1), 36);
|
||||||
id = '_' + (this.temp_variable += 1);
|
this.temp_var = '_' + ordinal.toString(36).replace(/\d/g, 'a');
|
||||||
}
|
}
|
||||||
this.variables[id] = 'var';
|
this.variables[this.temp_var] = 'var';
|
||||||
return id;
|
return this.temp_var;
|
||||||
};
|
};
|
||||||
// Ensure that an assignment is made at the top of scope (or top-level
|
// Ensure that an assignment is made at the top of scope (or top-level
|
||||||
// scope, if requested).
|
// scope, if requested).
|
||||||
@@ -78,45 +78,45 @@
|
|||||||
};
|
};
|
||||||
// Return the list of variables first declared in current scope.
|
// Return the list of variables first declared in current scope.
|
||||||
Scope.prototype.declared_variables = function declared_variables() {
|
Scope.prototype.declared_variables = function declared_variables() {
|
||||||
var _1, _2, key, val;
|
var _a, _b, key, val;
|
||||||
return ((function() {
|
return ((function() {
|
||||||
_1 = []; _2 = this.variables;
|
_a = []; _b = this.variables;
|
||||||
for (key in _2) if (__hasProp.call(_2, key)) {
|
for (key in _b) if (__hasProp.call(_b, key)) {
|
||||||
val = _2[key];
|
val = _b[key];
|
||||||
if (val === 'var') {
|
if (val === 'var') {
|
||||||
_1.push(key);
|
_a.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this)).sort();
|
}).call(this)).sort();
|
||||||
};
|
};
|
||||||
// Return the list of variables that are supposed to be assigned at the top
|
// Return the list of variables that are supposed to be assigned at the top
|
||||||
// of scope.
|
// of scope.
|
||||||
Scope.prototype.assigned_variables = function assigned_variables() {
|
Scope.prototype.assigned_variables = function assigned_variables() {
|
||||||
var _1, _2, key, val;
|
var _a, _b, key, val;
|
||||||
return ((function() {
|
return ((function() {
|
||||||
_1 = []; _2 = this.variables;
|
_a = []; _b = this.variables;
|
||||||
for (key in _2) if (__hasProp.call(_2, key)) {
|
for (key in _b) if (__hasProp.call(_b, key)) {
|
||||||
val = _2[key];
|
val = _b[key];
|
||||||
if (val.assigned) {
|
if (val.assigned) {
|
||||||
_1.push([key, val.value]);
|
_a.push([key, val.value]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this)).sort();
|
}).call(this)).sort();
|
||||||
};
|
};
|
||||||
Scope.prototype.compiled_declarations = function compiled_declarations() {
|
Scope.prototype.compiled_declarations = function compiled_declarations() {
|
||||||
return this.declared_variables().join(', ');
|
return this.declared_variables().join(', ');
|
||||||
};
|
};
|
||||||
Scope.prototype.compiled_assignments = function compiled_assignments() {
|
Scope.prototype.compiled_assignments = function compiled_assignments() {
|
||||||
var _1, _2, _3, t;
|
var _a, _b, _c, t;
|
||||||
return ((function() {
|
return ((function() {
|
||||||
_1 = []; _2 = this.assigned_variables();
|
_a = []; _b = this.assigned_variables();
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
t = _2[_3];
|
t = _b[_c];
|
||||||
_1.push(t[0] + ' = ' + t[1]);
|
_a.push(t[0] + ' = ' + t[1]);
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}).call(this)).join(', ');
|
}).call(this)).join(', ');
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
@@ -40,22 +40,22 @@
|
|||||||
// The cornerstone, an each implementation.
|
// The cornerstone, an each implementation.
|
||||||
// Handles objects implementing forEach, arrays, and raw objects.
|
// Handles objects implementing forEach, arrays, and raw objects.
|
||||||
_.each = function each(obj, iterator, context) {
|
_.each = function each(obj, iterator, context) {
|
||||||
var _1, _2, _3, _4, _5, _6, i, index, key, val;
|
var _a, _b, _c, _d, _e, _f, i, index, key, val;
|
||||||
index = 0;
|
index = 0;
|
||||||
try {
|
try {
|
||||||
if (obj.forEach) {
|
if (obj.forEach) {
|
||||||
return obj.forEach(iterator, context);
|
return obj.forEach(iterator, context);
|
||||||
}
|
}
|
||||||
if (_.isNumber(obj.length)) {
|
if (_.isNumber(obj.length)) {
|
||||||
_1 = []; _4 = 0; _5 = obj.length;
|
_a = []; _d = 0; _e = obj.length;
|
||||||
for (_3=0, i=_4; (_4 <= _5 ? i < _5 : i > _5); (_4 <= _5 ? i += 1 : i -= 1), _3++) {
|
for (_c=0, i=_d; (_d <= _e ? i < _e : i > _e); (_d <= _e ? i += 1 : i -= 1), _c++) {
|
||||||
_1.push(iterator.call(context, obj[i], i, obj));
|
_a.push(iterator.call(context, obj[i], i, obj));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
}
|
}
|
||||||
_6 = obj;
|
_f = obj;
|
||||||
for (key in _6) if (__hasProp.call(_6, key)) {
|
for (key in _f) if (__hasProp.call(_f, key)) {
|
||||||
val = _6[key];
|
val = _f[key];
|
||||||
iterator.call(context, val, key, obj);
|
iterator.call(context, val, key, obj);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -173,13 +173,13 @@
|
|||||||
// Determine if a given value is included in the array or object,
|
// Determine if a given value is included in the array or object,
|
||||||
// based on '==='.
|
// based on '==='.
|
||||||
_.include = function include(obj, target) {
|
_.include = function include(obj, target) {
|
||||||
var _1, key, val;
|
var _a, key, val;
|
||||||
if (obj && _.isFunction(obj.indexOf)) {
|
if (obj && _.isFunction(obj.indexOf)) {
|
||||||
return _.indexOf(obj, target) !== -1;
|
return _.indexOf(obj, target) !== -1;
|
||||||
}
|
}
|
||||||
_1 = obj;
|
_a = obj;
|
||||||
for (key in _1) if (__hasProp.call(_1, key)) {
|
for (key in _a) if (__hasProp.call(_a, key)) {
|
||||||
val = _1[key];
|
val = _a[key];
|
||||||
if (val === target) {
|
if (val === target) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -188,15 +188,15 @@
|
|||||||
};
|
};
|
||||||
// Invoke a method with arguments on every item in a collection.
|
// Invoke a method with arguments on every item in a collection.
|
||||||
_.invoke = function invoke(obj, method) {
|
_.invoke = function invoke(obj, method) {
|
||||||
var _1, _2, _3, args, val;
|
var _a, _b, _c, args, val;
|
||||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||||
args = _.rest(arguments, 2);
|
args = _.rest(arguments, 2);
|
||||||
_1 = []; _2 = obj;
|
_a = []; _b = obj;
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
val = _2[_3];
|
val = _b[_c];
|
||||||
_1.push((method ? val[method] : val).apply(val, args));
|
_a.push((method ? val[method] : val).apply(val, args));
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
};
|
};
|
||||||
// Convenience version of a common use case of map: fetching a property.
|
// Convenience version of a common use case of map: fetching a property.
|
||||||
_.pluck = function pluck(obj, key) {
|
_.pluck = function pluck(obj, key) {
|
||||||
@@ -315,14 +315,14 @@
|
|||||||
};
|
};
|
||||||
// Trim out all falsy values from an array.
|
// Trim out all falsy values from an array.
|
||||||
_.compact = function compact(array) {
|
_.compact = function compact(array) {
|
||||||
var _1, _2, _3, _4, _5, i;
|
var _a, _b, _c, _d, _e, i;
|
||||||
_1 = []; _4 = 0; _5 = array.length;
|
_a = []; _d = 0; _e = array.length;
|
||||||
for (_3=0, i=_4; (_4 <= _5 ? i < _5 : i > _5); (_4 <= _5 ? i += 1 : i -= 1), _3++) {
|
for (_c=0, i=_d; (_d <= _e ? i < _e : i > _e); (_d <= _e ? i += 1 : i -= 1), _c++) {
|
||||||
if (array[i]) {
|
if (array[i]) {
|
||||||
_1.push(array[i]);
|
_a.push(array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
};
|
};
|
||||||
// Return a completely flattened version of an array.
|
// Return a completely flattened version of an array.
|
||||||
_.flatten = function flatten(array) {
|
_.flatten = function flatten(array) {
|
||||||
@@ -336,26 +336,26 @@
|
|||||||
};
|
};
|
||||||
// Return a version of the array that does not contain the specified value(s).
|
// Return a version of the array that does not contain the specified value(s).
|
||||||
_.without = function without(array) {
|
_.without = function without(array) {
|
||||||
var _1, _2, _3, val, values;
|
var _a, _b, _c, val, values;
|
||||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||||
values = _.rest(arguments);
|
values = _.rest(arguments);
|
||||||
_1 = []; _2 = _.toArray(array);
|
_a = []; _b = _.toArray(array);
|
||||||
for (_3 = 0; _3 < _2.length; _3++) {
|
for (_c = 0; _c < _b.length; _c++) {
|
||||||
val = _2[_3];
|
val = _b[_c];
|
||||||
if (!_.include(values, val)) {
|
if (!_.include(values, val)) {
|
||||||
_1.push(val);
|
_a.push(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
};
|
};
|
||||||
// Produce a duplicate-free version of the array. If the array has already
|
// Produce a duplicate-free version of the array. If the array has already
|
||||||
// been sorted, you have the option of using a faster algorithm.
|
// been sorted, you have the option of using a faster algorithm.
|
||||||
_.uniq = function uniq(array, isSorted) {
|
_.uniq = function uniq(array, isSorted) {
|
||||||
var _1, el, i, memo;
|
var _a, el, i, memo;
|
||||||
memo = [];
|
memo = [];
|
||||||
_1 = _.toArray(array);
|
_a = _.toArray(array);
|
||||||
for (i = 0; i < _1.length; i++) {
|
for (i = 0; i < _a.length; i++) {
|
||||||
el = _1[i];
|
el = _a[i];
|
||||||
if (i === 0 || (isSorted === true ? _.last(memo) !== el : !_.include(memo, el))) {
|
if (i === 0 || (isSorted === true ? _.last(memo) !== el : !_.include(memo, el))) {
|
||||||
memo.push(el);
|
memo.push(el);
|
||||||
}
|
}
|
||||||
@@ -377,12 +377,12 @@
|
|||||||
// Zip together multiple lists into a single array -- elements that share
|
// Zip together multiple lists into a single array -- elements that share
|
||||||
// an index go together.
|
// an index go together.
|
||||||
_.zip = function zip() {
|
_.zip = function zip() {
|
||||||
var _1, _2, _3, _4, i, length, results;
|
var _a, _b, _c, _d, i, length, results;
|
||||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||||
length = _.max(_.pluck(arguments, 'length'));
|
length = _.max(_.pluck(arguments, 'length'));
|
||||||
results = new Array(length);
|
results = new Array(length);
|
||||||
_3 = 0; _4 = length;
|
_c = 0; _d = length;
|
||||||
for (_2=0, i=_3; (_3 <= _4 ? i < _4 : i > _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
|
for (_b=0, i=_c; (_c <= _d ? i < _d : i > _d); (_c <= _d ? i += 1 : i -= 1), _b++) {
|
||||||
results[i] = _.pluck(arguments, String(i));
|
results[i] = _.pluck(arguments, String(i));
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
@@ -427,7 +427,7 @@
|
|||||||
// the native Python range() function. See:
|
// the native Python range() function. See:
|
||||||
// http://docs.python.org/library/functions.html#range
|
// http://docs.python.org/library/functions.html#range
|
||||||
_.range = function range(start, stop, step) {
|
_.range = function range(start, stop, step) {
|
||||||
var _1, a, i, idx, len, range, solo;
|
var _a, a, i, idx, len, range, solo;
|
||||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||||
a = arguments;
|
a = arguments;
|
||||||
solo = a.length <= 1;
|
solo = a.length <= 1;
|
||||||
@@ -440,7 +440,7 @@
|
|||||||
}
|
}
|
||||||
range = new Array(len);
|
range = new Array(len);
|
||||||
idx = 0;
|
idx = 0;
|
||||||
_1 = [];
|
_a = [];
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((step > 0 ? i - stop : stop - i) >= 0) {
|
if ((step > 0 ? i - stop : stop - i) >= 0) {
|
||||||
return range;
|
return range;
|
||||||
@@ -449,7 +449,7 @@
|
|||||||
idx++;
|
idx++;
|
||||||
i += step;
|
i += step;
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
};
|
};
|
||||||
// ----------------------- Function Functions: -----------------------------
|
// ----------------------- Function Functions: -----------------------------
|
||||||
// Create a function bound to a given object (assigning 'this', and arguments,
|
// Create a function bound to a given object (assigning 'this', and arguments,
|
||||||
@@ -506,11 +506,11 @@
|
|||||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||||
funcs = arguments;
|
funcs = arguments;
|
||||||
return (function() {
|
return (function() {
|
||||||
var _1, _2, _3, _4, args, i;
|
var _a, _b, _c, _d, args, i;
|
||||||
var arguments = Array.prototype.slice.call(arguments, 0);
|
var arguments = Array.prototype.slice.call(arguments, 0);
|
||||||
args = arguments;
|
args = arguments;
|
||||||
_3 = (funcs.length - 1); _4 = 0;
|
_c = (funcs.length - 1); _d = 0;
|
||||||
for (_2=0, i=_3; (_3 <= _4 ? i <= _4 : i >= _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
|
for (_b=0, i=_c; (_c <= _d ? i <= _d : i >= _d); (_c <= _d ? i += 1 : i -= 1), _b++) {
|
||||||
args = [funcs[i].apply(this, args)];
|
args = [funcs[i].apply(this, args)];
|
||||||
}
|
}
|
||||||
return args[0];
|
return args[0];
|
||||||
@@ -519,16 +519,16 @@
|
|||||||
// ------------------------- Object Functions: ----------------------------
|
// ------------------------- Object Functions: ----------------------------
|
||||||
// Retrieve the names of an object's properties.
|
// Retrieve the names of an object's properties.
|
||||||
_.keys = function keys(obj) {
|
_.keys = function keys(obj) {
|
||||||
var _1, _2, key, val;
|
var _a, _b, key, val;
|
||||||
if (_.isArray(obj)) {
|
if (_.isArray(obj)) {
|
||||||
return _.range(0, obj.length);
|
return _.range(0, obj.length);
|
||||||
}
|
}
|
||||||
_1 = []; _2 = obj;
|
_a = []; _b = obj;
|
||||||
for (key in _2) if (__hasProp.call(_2, key)) {
|
for (key in _b) if (__hasProp.call(_b, key)) {
|
||||||
val = _2[key];
|
val = _b[key];
|
||||||
_1.push(key);
|
_a.push(key);
|
||||||
}
|
}
|
||||||
return _1;
|
return _a;
|
||||||
};
|
};
|
||||||
// Retrieve the values of an object's properties.
|
// Retrieve the values of an object's properties.
|
||||||
_.values = function values(obj) {
|
_.values = function values(obj) {
|
||||||
@@ -542,10 +542,10 @@
|
|||||||
};
|
};
|
||||||
// Extend a given object with all of the properties in a source object.
|
// Extend a given object with all of the properties in a source object.
|
||||||
_.extend = function extend(destination, source) {
|
_.extend = function extend(destination, source) {
|
||||||
var _1, key, val;
|
var _a, key, val;
|
||||||
_1 = source;
|
_a = source;
|
||||||
for (key in _1) if (__hasProp.call(_1, key)) {
|
for (key in _a) if (__hasProp.call(_a, key)) {
|
||||||
val = _1[key];
|
val = _a[key];
|
||||||
destination[key] = val;
|
destination[key] = val;
|
||||||
}
|
}
|
||||||
return destination;
|
return destination;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Scope: exports.Scope: (parent, expressions, method) ->
|
|||||||
@expressions: expressions
|
@expressions: expressions
|
||||||
@method: method
|
@method: method
|
||||||
@variables: {}
|
@variables: {}
|
||||||
@temp_variable: if @parent then @parent.temp_variable else 1
|
@temp_var: if @parent then @parent.temp_var else '_a'
|
||||||
this
|
this
|
||||||
|
|
||||||
# Look up a variable in lexical scope, or declare it if not found.
|
# Look up a variable in lexical scope, or declare it if not found.
|
||||||
@@ -38,11 +38,11 @@ Scope::reset: (name) ->
|
|||||||
|
|
||||||
# Find an available, short, name for a compiler-generated variable.
|
# Find an available, short, name for a compiler-generated variable.
|
||||||
Scope::free_variable: ->
|
Scope::free_variable: ->
|
||||||
id: '_' + @temp_variable
|
while @check @temp_var
|
||||||
while @check(id)
|
ordinal: 1 + parseInt @temp_var.substr(1), 36
|
||||||
id: '_' + (@temp_variable += 1)
|
@temp_var: '_' + ordinal.toString(36).replace(/\d/g, 'a')
|
||||||
@variables[id]: 'var'
|
@variables[@temp_var]: 'var'
|
||||||
id
|
@temp_var
|
||||||
|
|
||||||
# Ensure that an assignment is made at the top of scope (or top-level
|
# Ensure that an assignment is made at the top of scope (or top-level
|
||||||
# scope, if requested).
|
# scope, if requested).
|
||||||
|
|||||||
Reference in New Issue
Block a user