Coco ce2d08a: removed _argN temporaries for readability/consistency

This commit is contained in:
Jeremy Ashkenas 2010-11-20 20:39:35 -05:00
parent 835244f92d
commit 0e4d589d80
6 changed files with 85 additions and 72 deletions

View File

@ -67,8 +67,8 @@
_ref = this.tokens[this.pos++] || [''], tag = _ref[0], this.yytext = _ref[1], this.yylineno = _ref[2];
return tag;
},
setInput: function(_arg) {
this.tokens = _arg;
setInput: function(tokens) {
this.tokens = tokens;
return this.pos = 0;
},
upcomingInput: function() {

View File

@ -292,8 +292,8 @@
return Expressions;
}();
exports.Literal = Literal = function() {
function Literal(_arg) {
this.value = _arg;
function Literal(value) {
this.value = value;
}
__extends(Literal, Base);
Literal.prototype.makeReturn = function() {
@ -327,8 +327,8 @@
return Literal;
}();
exports.Return = Return = function() {
function Return(_arg) {
this.expression = _arg;
function Return(expression) {
this.expression = expression;
}
__extends(Return, Base);
Return.prototype.children = ['expression'];
@ -486,8 +486,8 @@
return Value;
}();
exports.Comment = Comment = function() {
function Comment(_arg) {
this.comment = _arg;
function Comment(comment) {
this.comment = comment;
}
__extends(Comment, Base);
Comment.prototype.isPureStatement = YES;
@ -504,9 +504,9 @@
return Comment;
}();
exports.Call = Call = function() {
function Call(variable, _arg, _arg2) {
this.args = _arg != null ? _arg : [];
this.soak = _arg2;
function Call(variable, args, soak) {
this.args = args != null ? args : [];
this.soak = soak;
this.isNew = false;
this.isSuper = variable === 'super';
this.variable = this.isSuper ? null : variable;
@ -632,9 +632,9 @@
return Call;
}();
exports.Extends = Extends = function() {
function Extends(_arg, _arg2) {
this.child = _arg;
this.parent = _arg2;
function Extends(child, parent) {
this.child = child;
this.parent = parent;
}
__extends(Extends, Base);
Extends.prototype.children = ['child', 'parent'];
@ -645,8 +645,8 @@
return Extends;
}();
exports.Access = Access = function() {
function Access(_arg, tag) {
this.name = _arg;
function Access(name, tag) {
this.name = name;
this.proto = tag === 'proto' ? '.prototype' : '';
this.soak = tag === 'soak';
}
@ -661,8 +661,8 @@
return Access;
}();
exports.Index = Index = function() {
function Index(_arg) {
this.index = _arg;
function Index(index) {
this.index = index;
}
__extends(Index, Base);
Index.prototype.children = ['index'];
@ -675,9 +675,9 @@
return Index;
}();
exports.Range = Range = function() {
function Range(_arg, _arg2, tag) {
this.from = _arg;
this.to = _arg2;
function Range(from, to, tag) {
this.from = from;
this.to = to;
this.exclusive = tag === 'exclusive';
this.equals = this.exclusive ? '' : '=';
}
@ -760,8 +760,8 @@
return Range;
}();
exports.Slice = Slice = function() {
function Slice(_arg) {
this.range = _arg;
function Slice(range) {
this.range = range;
Slice.__super__.constructor.call(this);
}
__extends(Slice, Base);
@ -779,8 +779,8 @@
return Slice;
}();
exports.Obj = Obj = function() {
function Obj(props, _arg) {
this.generated = _arg != null ? _arg : false;
function Obj(props, generated) {
this.generated = generated != null ? generated : false;
this.objects = this.properties = props || [];
}
__extends(Obj, Base);
@ -928,10 +928,10 @@
return Arr;
}();
exports.Class = Class = function() {
function Class(_arg, _arg2, _arg3) {
this.variable = _arg;
this.parent = _arg2;
this.body = _arg3 != null ? _arg3 : new Expressions;
function Class(variable, parent, body) {
this.variable = variable;
this.parent = parent;
this.body = body != null ? body : new Expressions;
this.boundFuncs = [];
}
__extends(Class, Base);
@ -1057,10 +1057,10 @@
return Class;
}();
exports.Assign = Assign = function() {
function Assign(_arg, _arg2, _arg3) {
this.variable = _arg;
this.value = _arg2;
this.context = _arg3;
function Assign(variable, value, context) {
this.variable = variable;
this.value = value;
this.context = context;
}
__extends(Assign, Base);
Assign.prototype.METHOD_DEF = /^(?:(\S+)\.prototype\.|\S+?)?\b([$A-Za-z_][$\w]*)$/;
@ -1313,10 +1313,10 @@
return Code;
}();
exports.Param = Param = function() {
function Param(_arg, _arg2, _arg3) {
this.name = _arg;
this.value = _arg2;
this.splat = _arg3;
function Param(name, value, splat) {
this.name = name;
this.value = value;
this.splat = splat;
}
__extends(Param, Base);
Param.prototype.children = ['name', 'value'];
@ -1328,7 +1328,15 @@
if (this.reference) {
return this.reference;
}
node = this.isComplex() ? new Literal(o.scope.freeVariable('arg')) : this.name;
node = this.name;
if (node["this"]) {
node = node.properties[0].name;
if (node.value.reserved) {
node = new Literal('_' + node.value);
}
} else if (node.isComplex()) {
node = new Literal(o.scope.freeVariable('arg'));
}
node = new Value(node);
if (this.splat) {
node = new Splat(node);
@ -1407,8 +1415,8 @@
this.returns = true;
return this;
};
While.prototype.addBody = function(_arg) {
this.body = _arg;
While.prototype.addBody = function(body) {
this.body = body;
return this;
};
While.prototype.containsPureStatement = function() {
@ -1578,9 +1586,9 @@
return Op;
}();
exports.In = In = function() {
function In(_arg, _arg2) {
this.object = _arg;
this.array = _arg2;
function In(object, array) {
this.object = object;
this.array = array;
}
__extends(In, Base);
In.prototype.children = ['object', 'array'];
@ -1632,11 +1640,11 @@
return In;
}();
exports.Try = Try = function() {
function Try(_arg, _arg2, _arg3, _arg4) {
this.attempt = _arg;
this.error = _arg2;
this.recovery = _arg3;
this.ensure = _arg4;
function Try(attempt, error, recovery, ensure) {
this.attempt = attempt;
this.error = error;
this.recovery = recovery;
this.ensure = ensure;
}
__extends(Try, Base);
Try.prototype.children = ['attempt', 'recovery', 'ensure'];
@ -1660,8 +1668,8 @@
return Try;
}();
exports.Throw = Throw = function() {
function Throw(_arg) {
this.expression = _arg;
function Throw(expression) {
this.expression = expression;
}
__extends(Throw, Base);
Throw.prototype.children = ['expression'];
@ -1673,8 +1681,8 @@
return Throw;
}();
exports.Existence = Existence = function() {
function Existence(_arg) {
this.expression = _arg;
function Existence(expression) {
this.expression = expression;
}
__extends(Existence, Base);
Existence.prototype.children = ['expression'];
@ -1692,8 +1700,8 @@
return Existence;
}();
exports.Parens = Parens = function() {
function Parens(_arg) {
this.body = _arg;
function Parens(body) {
this.body = body;
}
__extends(Parens, Base);
Parens.prototype.children = ['body'];
@ -1724,10 +1732,10 @@
return Parens;
}();
exports.For = For = function() {
function For(body, source, _arg, _arg2) {
function For(body, source, name, index) {
var _ref;
this.name = _arg;
this.index = _arg2;
this.name = name;
this.index = index;
this.source = source.source, this.guard = source.guard, this.step = source.step;
this.body = Expressions.wrap([body]);
this.raw = !!source.raw;
@ -1872,10 +1880,10 @@
return For;
}();
exports.Switch = Switch = function() {
function Switch(_arg, _arg2, _arg3) {
this.subject = _arg;
this.cases = _arg2;
this.otherwise = _arg3;
function Switch(subject, cases, otherwise) {
this.subject = subject;
this.cases = cases;
this.otherwise = otherwise;
}
__extends(Switch, Base);
Switch.prototype.children = ['subject', 'cases', 'otherwise'];
@ -1933,8 +1941,8 @@
return Switch;
}();
exports.If = If = function() {
function If(condition, _arg, options) {
this.body = _arg;
function If(condition, body, options) {
this.body = body;
options == null && (options = {});
this.condition = options.invert ? condition.invert() : condition;
this.elseBody = null;

View File

@ -1,8 +1,8 @@
(function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments;
exports.OptionParser = OptionParser = function() {
function OptionParser(rules, _arg) {
this.banner = _arg;
function OptionParser(rules, banner) {
this.banner = banner;
this.rules = buildRules(rules);
}
OptionParser.prototype.parse = function(args) {

View File

@ -8,8 +8,8 @@
}, __slice = Array.prototype.slice;
exports.Rewriter = Rewriter = function() {
function Rewriter() {}
Rewriter.prototype.rewrite = function(_arg) {
this.tokens = _arg;
Rewriter.prototype.rewrite = function(tokens) {
this.tokens = tokens;
this.removeLeadingNewlines();
this.removeMidExpressionNewlines();
this.closeOpenCalls();

View File

@ -2,10 +2,10 @@
var Scope, extend, last, _ref;
_ref = require('./helpers'), extend = _ref.extend, last = _ref.last;
exports.Scope = Scope = function() {
function Scope(_arg, _arg2, _arg3) {
this.parent = _arg;
this.expressions = _arg2;
this.method = _arg3;
function Scope(parent, expressions, method) {
this.parent = parent;
this.expressions = expressions;
this.method = method;
this.variables = [
{
name: 'arguments',

View File

@ -1056,7 +1056,12 @@ exports.Param = class Param extends Base
asReference: (o) ->
return @reference if @reference
node = if @isComplex() then new Literal o.scope.freeVariable 'arg' else @name
node = @name
if node.this
node = node.properties[0].name
node = new Literal '_' + node.value if node.value.reserved
else if node.isComplex()
node = new Literal o.scope.freeVariable 'arg'
node = new Value node
node = new Splat node if @splat
@reference = node