mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-23 21:57:56 -05:00
nodes: reformatted
This commit is contained in:
63
lib/nodes.js
63
lib/nodes.js
@@ -6,9 +6,6 @@
|
||||
child.prototype = new ctor;
|
||||
if (typeof parent.extended === "function") parent.extended(child);
|
||||
child.__super__ = parent.prototype;
|
||||
}, __indexOf = Array.prototype.indexOf || function(item) {
|
||||
for (var i = 0, l = this.length; i < l; i++) if (this[i] === item) return i;
|
||||
return -1;
|
||||
};
|
||||
Scope = require('./scope').Scope;
|
||||
_ref = require('./helpers'), compact = _ref.compact, flatten = _ref.flatten, extend = _ref.extend, merge = _ref.merge, del = _ref.del, starts = _ref.starts, ends = _ref.ends, last = _ref.last;
|
||||
@@ -347,13 +344,19 @@
|
||||
return !!this.properties.length;
|
||||
};
|
||||
Value.prototype.isArray = function() {
|
||||
return this.base instanceof Arr && !this.properties.length;
|
||||
return !this.properties.length && this.base instanceof Arr;
|
||||
};
|
||||
Value.prototype.isObject = function() {
|
||||
return this.base instanceof Obj && !this.properties.length;
|
||||
return !this.properties.length && this.base instanceof Obj;
|
||||
};
|
||||
Value.prototype.isComplex = function() {
|
||||
return this.base.isComplex() || this.hasProperties();
|
||||
return this.hasProperties() || this.base.isComplex();
|
||||
};
|
||||
Value.prototype.isAssignable = function() {
|
||||
return this.hasProperties() || this.base.isAssignable();
|
||||
};
|
||||
Value.prototype.isSimpleNumber = function() {
|
||||
return this.base instanceof Literal && SIMPLENUM.test(this.base.value);
|
||||
};
|
||||
Value.prototype.isAtomic = function() {
|
||||
var _i, _len, _ref2, node;
|
||||
@@ -366,8 +369,8 @@
|
||||
}
|
||||
return true;
|
||||
};
|
||||
Value.prototype.isAssignable = function() {
|
||||
return this.hasProperties() || this.base.isAssignable();
|
||||
Value.prototype.isStatement = function(o) {
|
||||
return !this.properties.length && this.base.isStatement(o);
|
||||
};
|
||||
Value.prototype.assigns = function(name) {
|
||||
return !this.properties.length && this.base.assigns(name);
|
||||
@@ -378,12 +381,6 @@
|
||||
Value.prototype.unwrap = function() {
|
||||
return this.properties.length ? this : this.base;
|
||||
};
|
||||
Value.prototype.isStatement = function(o) {
|
||||
return !this.properties.length && this.base.isStatement(o);
|
||||
};
|
||||
Value.prototype.isSimpleNumber = function() {
|
||||
return this.base instanceof Literal && SIMPLENUM.test(this.base.value);
|
||||
};
|
||||
Value.prototype.cacheReference = function(o) {
|
||||
var base, bref, name, nref;
|
||||
name = last(this.properties);
|
||||
@@ -479,9 +476,6 @@
|
||||
})();
|
||||
__extends(Call, Base);
|
||||
Call.prototype.children = ['variable', 'args'];
|
||||
Call.prototype.compileSplatArguments = function(o) {
|
||||
return Splat.compileSplattedArray(this.args, o);
|
||||
};
|
||||
Call.prototype.newInstance = function() {
|
||||
this.isNew = true;
|
||||
return this;
|
||||
@@ -575,7 +569,7 @@
|
||||
};
|
||||
Call.prototype.compileSplat = function(o) {
|
||||
var base, fun, idt, name, ref, splatargs;
|
||||
splatargs = this.compileSplatArguments(o);
|
||||
splatargs = Splat.compileSplattedArray(this.args, o);
|
||||
if (this.isSuper) {
|
||||
return "" + (this.superReference(o)) + ".apply(this, " + splatargs + ")";
|
||||
}
|
||||
@@ -753,9 +747,6 @@
|
||||
})();
|
||||
__extends(Arr, Base);
|
||||
Arr.prototype.children = ['objects'];
|
||||
Arr.prototype.compileSplatLiteral = function(o) {
|
||||
return Splat.compileSplattedArray(this.objects, o);
|
||||
};
|
||||
Arr.prototype.compileNode = function(o) {
|
||||
var _i, _len, _len2, _ref2, _ref3, code, i, obj, objects;
|
||||
o.indent = this.idt(1);
|
||||
@@ -763,7 +754,7 @@
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
obj = _ref2[_i];
|
||||
if (obj instanceof Splat) {
|
||||
return this.compileSplatLiteral(o);
|
||||
return Splat.compileSplattedArray(this.objects, o);
|
||||
}
|
||||
}
|
||||
objects = [];
|
||||
@@ -901,7 +892,6 @@
|
||||
})();
|
||||
__extends(Assign, Base);
|
||||
Assign.prototype.METHOD_DEF = /^(?:(\S+)\.prototype\.)?([$A-Za-z_][$\w]*)$/;
|
||||
Assign.prototype.CONDITIONAL = ['||=', '&&=', '?='];
|
||||
Assign.prototype.children = ['variable', 'value'];
|
||||
Assign.prototype.assigns = function(name) {
|
||||
return this[this.context === 'object' ? 'value' : 'variable'].assigns(name);
|
||||
@@ -915,7 +905,7 @@
|
||||
if (this.variable.isArray() || this.variable.isObject()) {
|
||||
return this.compilePatternMatch(o);
|
||||
}
|
||||
if (_ref2 = this.context, __indexOf.call(this.CONDITIONAL, _ref2) >= 0) {
|
||||
if ((_ref2 = this.context) === '||=' || _ref2 === '&&=' || _ref2 === '?=') {
|
||||
return this.compileConditional(o);
|
||||
}
|
||||
}
|
||||
@@ -1011,12 +1001,10 @@
|
||||
})();
|
||||
exports.Code = (function() {
|
||||
Code = (function() {
|
||||
function Code(_arg, _arg2, tag) {
|
||||
this.body = _arg2;
|
||||
this.params = _arg;
|
||||
function Code(params, body, tag) {
|
||||
Code.__super__.constructor.call(this);
|
||||
this.params || (this.params = []);
|
||||
this.body || (this.body = new Expressions);
|
||||
this.params = params || [];
|
||||
this.body = body || new Expressions;
|
||||
this.bound = tag === 'boundfunc';
|
||||
if (this.bound) {
|
||||
this.context = 'this';
|
||||
@@ -1111,12 +1099,11 @@
|
||||
})();
|
||||
exports.Param = (function() {
|
||||
Param = (function() {
|
||||
function Param(_arg, _arg2, _arg3) {
|
||||
this.splat = _arg3;
|
||||
this.attach = _arg2;
|
||||
this.name = _arg;
|
||||
function Param(name, _arg, _arg2) {
|
||||
this.splat = _arg2;
|
||||
this.attach = _arg;
|
||||
Param.__super__.constructor.call(this);
|
||||
this.value = new Literal(this.name);
|
||||
this.value = new Literal(this.name = name);
|
||||
return this;
|
||||
};
|
||||
return Param;
|
||||
@@ -1796,11 +1783,11 @@
|
||||
return If;
|
||||
}).call(this);
|
||||
Push = {
|
||||
wrap: function(name, expressions) {
|
||||
if (expressions.isEmpty() || last(expressions.expressions).containsPureStatement()) {
|
||||
return expressions;
|
||||
wrap: function(name, exps) {
|
||||
if (exps.isEmpty() || last(exps.expressions).containsPureStatement()) {
|
||||
return exps;
|
||||
}
|
||||
return expressions.push(new Call(new Value(new Literal(name), [new Accessor(new Literal('push'))]), [expressions.pop()]));
|
||||
return exps.push(new Call(new Value(new Literal(name), [new Accessor(new Literal('push'))]), [exps.pop()]));
|
||||
}
|
||||
};
|
||||
Closure = {
|
||||
|
||||
Reference in New Issue
Block a user