switched from alphabetical __a __b temporary variables, to numeric _1, _2, which will be shorter in most cases

This commit is contained in:
Jeremy Ashkenas
2010-02-15 21:55:57 -05:00
parent 48c501a7a2
commit 4ea8be8e0b
8 changed files with 257 additions and 266 deletions

View File

@@ -30,16 +30,16 @@
};
// Quickie inheritance convenience wrapper to reduce typing.
inherit = function inherit(parent, props) {
var __a, __b, klass, name, prop;
var _1, _2, klass, name, prop;
klass = del(props, 'constructor');
__a = function(){};
__a.prototype = parent.prototype;
_1 = function(){};
_1.prototype = parent.prototype;
klass.__superClass__ = parent.prototype;
klass.prototype = new __a();
klass.prototype = new _1();
klass.prototype.constructor = klass;
__b = props;
for (name in __b) if (__hasProp.call(__b, name)) {
prop = __b[name];
_2 = props;
for (name in _2) if (__hasProp.call(_2, name)) {
prop = _2[name];
((klass.prototype[name] = prop));
}
return klass;
@@ -86,20 +86,20 @@
};
// Quick short method for the current indentation level, plus tabbing in.
Node.prototype.idt = function idt(tabs) {
var __a, __b, __c, __d, i, idt;
var _1, _2, _3, _4, i, idt;
idt = (this.indent || '');
__c = 0; __d = (tabs || 0);
for (__b=0, i=__c; (__c <= __d ? i < __d : i > __d); (__c <= __d ? i += 1 : i -= 1), __b++) {
_3 = 0; _4 = (tabs || 0);
for (_2=0, i=_3; (_3 <= _4 ? i < _4 : i > _4); (_3 <= _4 ? i += 1 : i -= 1), _2++) {
idt += TAB;
}
return idt;
};
// Does this node, or any of its children, contain a node of a certain kind?
Node.prototype.contains = function contains(block) {
var __a, __b, node;
__a = this.children;
for (__b = 0; __b < __a.length; __b++) {
node = __a[__b];
var _1, _2, node;
_1 = this.children;
for (_2 = 0; _2 < _1.length; _2++) {
node = _1[_2];
if (block(node)) {
return true;
}
@@ -168,14 +168,14 @@
},
// Compile each expression in the Expressions body.
compile_node: function compile_node(o) {
var __a, __b, __c, node;
var _1, _2, _3, node;
return ((function() {
__a = []; __b = this.expressions;
for (__c = 0; __c < __b.length; __c++) {
node = __b[__c];
__a.push(this.compile_expression(node, _.clone(o)));
_1 = []; _2 = this.expressions;
for (_3 = 0; _3 < _2.length; _3++) {
node = _2[_3];
_1.push(this.compile_expression(node, _.clone(o)));
}
return __a;
return _1;
}).call(this)).join("\n");
},
// 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();
},
compile_node: function compile_node(o) {
var __a, __b, baseline, code, only, part, parts, prop, props, soaked, temp;
var _1, _2, baseline, code, only, part, parts, prop, props, soaked, temp;
soaked = false;
only = del(o, 'only_first');
props = only ? this.properties.slice(0, this.properties.length - 1) : this.properties;
@@ -324,9 +324,9 @@
baseline = '(' + baseline + ')';
}
parts = [baseline];
__a = props;
for (__b = 0; __b < __a.length; __b++) {
prop = __a[__b];
_1 = props;
for (_2 = 0; _2 < _1.length; _2++) {
prop = _1[_2];
if (prop instanceof AccessorNode && prop.soak) {
soaked = true;
if (this.base instanceof CallNode && prop === props[0]) {
@@ -383,19 +383,19 @@
},
// Compile a vanilla function call.
compile_node: function compile_node(o) {
var __a, __b, __c, arg, args;
var _1, _2, _3, arg, args;
if (_.any(this.args, function(a) {
return a instanceof SplatNode;
})) {
return this.compile_splat(o);
}
args = ((function() {
__a = []; __b = this.args;
for (__c = 0; __c < __b.length; __c++) {
arg = __b[__c];
__a.push(arg.compile(o));
_1 = []; _2 = this.args;
for (_3 = 0; _3 < _2.length; _3++) {
arg = _2[_3];
_1.push(arg.compile(o));
}
return __a;
return _1;
}).call(this)).join(', ');
if (this.variable === 'super') {
return this.compile_super(args, o);
@@ -412,20 +412,20 @@
},
// Compile a function call being passed variable arguments.
compile_splat: function compile_splat(o) {
var __a, __b, arg, args, code, i, meth, obj;
var _1, _2, arg, args, code, i, meth, obj;
meth = this.variable.compile(o);
obj = this.variable.source || 'this';
args = (function() {
__a = []; __b = this.args;
for (i = 0; i < __b.length; i++) {
arg = __b[i];
__a.push((function() {
_1 = []; _2 = this.args;
for (i = 0; i < _2.length; i++) {
arg = _2[i];
_1.push((function() {
code = arg.compile(o);
code = arg instanceof SplatNode ? code : '[' + code + ']';
return i === 0 ? code : '.concat(' + code + ')';
}).call(this));
}
return __a;
return _1;
}).call(this);
return this.prefix + meth + '.apply(' + obj + ', ' + args.join('') + ')';
},
@@ -563,24 +563,24 @@
// AssignNodes get interleaved correctly, with no trailing commas or
// commas affixed to comments. TODO: Extract this and add it to ArrayNode.
compile_node: function compile_node(o) {
var __a, __b, __c, __d, __e, i, indent, inner, join, last_noncom, non_comments, prop, props;
var _1, _2, _3, _4, _5, i, indent, inner, join, last_noncom, non_comments, prop, props;
o.indent = this.idt(1);
non_comments = (function() {
__a = []; __b = this.properties;
for (__c = 0; __c < __b.length; __c++) {
prop = __b[__c];
_1 = []; _2 = this.properties;
for (_3 = 0; _3 < _2.length; _3++) {
prop = _2[_3];
if (!(prop instanceof CommentNode)) {
__a.push(prop);
_1.push(prop);
}
}
return __a;
return _1;
}).call(this);
last_noncom = non_comments[non_comments.length - 1];
props = (function() {
__d = []; __e = this.properties;
for (i = 0; i < __e.length; i++) {
prop = __e[i];
__d.push((function() {
_4 = []; _5 = this.properties;
for (i = 0; i < _5.length; i++) {
prop = _5[i];
_4.push((function() {
join = ",\n";
if ((prop === last_noncom) || (prop instanceof CommentNode)) {
join = "\n";
@@ -592,7 +592,7 @@
return indent + prop.compile(o) + join;
}).call(this));
}
return __d;
return _4;
}).call(this);
props = props.join('');
inner = props ? '\n' + props + '\n' + this.idt() : '';
@@ -607,13 +607,13 @@
return this;
},
compile_node: function compile_node(o) {
var __a, __b, code, ending, i, obj, objects;
var _1, _2, code, ending, i, obj, objects;
o.indent = this.idt(1);
objects = (function() {
__a = []; __b = this.objects;
for (i = 0; i < __b.length; i++) {
obj = __b[i];
__a.push((function() {
_1 = []; _2 = this.objects;
for (i = 0; i < _2.length; i++) {
obj = _2[i];
_1.push((function() {
code = obj.compile(o);
if (obj instanceof CommentNode) {
return '\n' + code + '\n' + o.indent;
@@ -624,7 +624,7 @@
}
}).call(this));
}
return __a;
return _1;
}).call(this);
objects = objects.join('');
ending = objects.indexOf('\n') >= 0 ? "\n" + this.idt() + ']' : ']';
@@ -717,19 +717,19 @@
// object literals to a value. Peeks at their properties to assign inner names.
// See: http://wiki.ecmascript.org/doku.php?id=harmony:destructuring
compile_pattern_match: function compile_pattern_match(o) {
var __a, __b, access_class, assigns, i, idx, obj, val, val_var;
var _1, _2, access_class, assigns, i, idx, obj, val, val_var;
val_var = o.scope.free_variable();
assigns = [this.idt() + val_var + ' = ' + this.value.compile(o) + ';'];
o.top = true;
o.as_statement = true;
__a = this.variable.base.objects;
for (i = 0; i < __a.length; i++) {
obj = __a[i];
_1 = this.variable.base.objects;
for (i = 0; i < _1.length; i++) {
obj = _1[i];
idx = i;
if (this.variable.is_object()) {
__b = [obj.value, obj.variable.base];
obj = __b[0];
idx = __b[1];
_2 = [obj.value, obj.variable.base];
obj = _2[0];
idx = _2[1];
}
access_class = this.variable.is_array() ? IndexNode : AccessorNode;
if (obj instanceof SplatNode) {
@@ -768,7 +768,7 @@
return this;
},
compile_node: function compile_node(o) {
var __a, __b, __c, __d, __e, code, func, inner, name_part, param, params, shared_scope, splat, top;
var _1, _2, _3, _4, _5, code, func, inner, name_part, param, params, shared_scope, splat, top;
shared_scope = del(o, 'shared_scope');
top = del(o, 'top');
o.scope = shared_scope || new Scope(o.scope, this.body, this);
@@ -783,16 +783,16 @@
this.body.unshift(splat);
}
params = ((function() {
__a = []; __b = this.params;
for (__c = 0; __c < __b.length; __c++) {
param = __b[__c];
__a.push(param.compile(o));
_1 = []; _2 = this.params;
for (_3 = 0; _3 < _2.length; _3++) {
param = _2[_3];
_1.push(param.compile(o));
}
return __a;
return _1;
}).call(this));
__d = params;
for (__e = 0; __e < __d.length; __e++) {
param = __d[__e];
_4 = params;
for (_5 = 0; _5 < _4.length; _5++) {
param = _4[_5];
(o.scope.parameter(param));
}
code = this.body.expressions.length ? '\n' + this.body.compile_with_declarations(o) + '\n' : '';
@@ -922,20 +922,20 @@
// Mimic Python's chained comparisons. See:
// http://docs.python.org/reference/expressions.html#notin
compile_chain: function compile_chain(o) {
var __a, shared;
var _1, shared;
shared = this.first.unwrap().second;
if (shared instanceof CallNode) {
__a = shared.compile_reference(o);
this.first.second = __a[0];
shared = __a[1];
_1 = shared.compile_reference(o);
this.first.second = _1[0];
shared = _1[1];
}
return '(' + this.first.compile(o) + ') && (' + shared.compile(o) + ' ' + this.operator + ' ' + this.second.compile(o) + ')';
},
compile_assignment: function compile_assignment(o) {
var __a, first, second;
__a = [this.first.compile(o), this.second.compile(o)];
first = __a[0];
second = __a[1];
var _1, first, second;
_1 = [this.first.compile(o), this.second.compile(o)];
first = _1[0];
second = _1[1];
if (first.match(IDENTIFIER)) {
o.scope.find(first);
}
@@ -945,10 +945,10 @@
return first + ' = ' + first + ' ' + this.operator.substr(0, 2) + ' ' + second;
},
compile_existence: function compile_existence(o) {
var __a, first, second;
__a = [this.first.compile(o), this.second.compile(o)];
first = __a[0];
second = __a[1];
var _1, first, second;
_1 = [this.first.compile(o), this.second.compile(o)];
first = _1[0];
second = _1[1];
return ExistenceNode.compile_test(o, this.first) + ' ? ' + first + ' : ' + second;
},
compile_unary: function compile_unary(o) {
@@ -1006,14 +1006,14 @@
}
}));
ExistenceNode.compile_test = function compile_test(o, variable) {
var __a, __b, first, second;
__a = [variable, variable];
first = __a[0];
second = __a[1];
var _1, _2, first, second;
_1 = [variable, variable];
first = _1[0];
second = _1[1];
if (variable instanceof CallNode) {
__b = variable.compile_reference(o);
first = __b[0];
second = __b[1];
_2 = variable.compile_reference(o);
first = _2[0];
second = _2[1];
}
return '(typeof ' + first.compile(o) + ' !== "undefined" && ' + second.compile(o) + ' !== null)';
};
@@ -1041,7 +1041,7 @@
ForNode = (exports.ForNode = inherit(Node, {
type: 'For',
constructor: function constructor(body, source, name, index) {
var __a;
var _1;
this.body = body;
this.name = name;
this.index = index || null;
@@ -1050,9 +1050,9 @@
this.step = source.step;
this.object = !!source.object;
if (this.object) {
__a = [this.index, this.name];
this.name = __a[0];
this.index = __a[1];
_1 = [this.index, this.name];
this.name = _1[0];
this.index = _1[1];
}
this.children = _.compact([this.body, this.source, this.filter]);
return this;
@@ -1163,15 +1163,15 @@
},
// Rewrite a chain of IfNodes with their switch condition for equality.
rewrite_condition: function rewrite_condition(expression) {
var __a, __b, __c, cond;
var _1, _2, _3, cond;
this.condition = (function() {
if (this.multiple) {
__a = []; __b = this.condition;
for (__c = 0; __c < __b.length; __c++) {
cond = __b[__c];
__a.push(new OpNode('is', expression, cond));
_1 = []; _2 = this.condition;
for (_3 = 0; _3 < _2.length; _3++) {
cond = _2[_3];
_1.push(new OpNode('is', expression, cond));
}
return __a;
return _1;
} else {
return new OpNode('is', expression, this.condition);
}
@@ -1197,14 +1197,14 @@
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) {
var __a, __b, __c, cond;
var _1, _2, _3, cond;
return ((function() {
__a = []; __b = _.flatten([this.condition]);
for (__c = 0; __c < __b.length; __c++) {
cond = __b[__c];
__a.push(cond.compile(o));
_1 = []; _2 = _.flatten([this.condition]);
for (_3 = 0; _3 < _2.length; _3++) {
cond = _2[_3];
_1.push(cond.compile(o));
}
return __a;
return _1;
}).call(this)).join(' || ');
},
compile_node: function compile_node(o) {