removed helpers.{indexOf,include} in favor of in operator

This commit is contained in:
satyr
2010-10-20 11:04:38 +09:00
parent c1d24944dc
commit 2c84f3ed1f
11 changed files with 516 additions and 550 deletions

View File

@@ -1,14 +1,17 @@
(function() {
var Accessor, ArrayLiteral, Assign, Base, Call, Class, Closure, Code, Comment, Existence, Expressions, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, Literal, NO, NUMBER, ObjectLiteral, Op, Param, Parens, Push, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, TRAILING_WHITESPACE, Throw, Try, UTILITIES, Value, While, YES, _ref, compact, del, ends, flatten, include, last, merge, starts, utility;
var Accessor, ArrayLiteral, Assign, Base, Call, Class, Closure, Code, Comment, Existence, Expressions, Extends, For, IDENTIFIER, IS_STRING, If, In, Index, Literal, NO, NUMBER, ObjectLiteral, Op, Param, Parens, Push, Range, Return, SIMPLENUM, Scope, Slice, Splat, Switch, TAB, THIS, TRAILING_WHITESPACE, Throw, Try, UTILITIES, Value, While, YES, _ref, compact, del, ends, flatten, last, merge, starts, utility;
var __extends = function(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
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, merge = _ref.merge, del = _ref.del, include = _ref.include, starts = _ref.starts, ends = _ref.ends, last = _ref.last;
_ref = require('./helpers'), compact = _ref.compact, flatten = _ref.flatten, merge = _ref.merge, del = _ref.del, starts = _ref.starts, ends = _ref.ends, last = _ref.last;
YES = function() {
return true;
};
@@ -983,7 +986,7 @@
Assign.prototype.children = ['variable', 'value'];
Assign.prototype.topSensitive = YES;
Assign.prototype.compileNode = function(o) {
var ifn, isValue, match, name, stmt, top, val;
var _ref2, ifn, isValue, match, name, stmt, top, val;
if (isValue = this.variable instanceof Value) {
if (this.variable.isArray() || this.variable.isObject()) {
return this.compilePatternMatch(o);
@@ -995,7 +998,7 @@
delete o.top;
return ifn.compile(o);
}
if (include(this.CONDITIONAL, this.context)) {
if ((_ref2 = this.context, __indexOf.call(this.CONDITIONAL, _ref2) >= 0)) {
return this.compileConditional(o);
}
}
@@ -1391,7 +1394,8 @@
return this.operator !== '!' || this.first.isComplex();
};
Op.prototype.isChainable = function() {
return include(this.CHAINABLE, this.operator);
var _ref2;
return (_ref2 = this.operator, __indexOf.call(this.CHAINABLE, _ref2) >= 0);
};
Op.prototype.invert = function() {
var _ref2;
@@ -1404,21 +1408,21 @@
return Op.__super__.toString.call(this, idt, this.constructor.name + ' ' + this.operator);
};
Op.prototype.compileNode = function(o) {
var ifn;
if (this.isChainable() && this.first.unwrap().isChainable()) {
return this.compileChain(o);
}
var _ref2, ifn;
if (this.isUnary()) {
if (include(this.MUTATORS, this.operator) && (ifn = If.unfoldSoak(o, this, 'first'))) {
if ((_ref2 = this.operator, __indexOf.call(this.MUTATORS, _ref2) >= 0) && (ifn = If.unfoldSoak(o, this, 'first'))) {
return ifn.compile(o);
}
return this.compileUnary(o);
}
if (this.isChainable() && this.first.unwrap().isChainable()) {
return this.compileChain(o);
}
if (this.operator === '?') {
return this.compileExistence(o);
}
this.first.tags.front = this.tags.front;
return [this.first.compile(o), this.operator, this.second.compile(o)].join(' ');
return "" + (this.first.compile(o)) + " " + (this.operator) + " " + (this.second.compile(o));
};
Op.prototype.compileChain = function(o) {
var _ref2, _ref3, first, second, shared;
@@ -1439,8 +1443,8 @@
return new Existence(fst).compile(o) + (" ? " + ref + " : " + (this.second.compile(o)));
};
Op.prototype.compileUnary = function(o) {
var parts, space;
space = include(this.PREFIX_OPERATORS, this.operator) ? ' ' : '';
var _ref2, parts, space;
space = (_ref2 = this.operator, __indexOf.call(this.PREFIX_OPERATORS, _ref2) >= 0) ? ' ' : '';
parts = [this.operator, space, this.first.compile(o)];
return (this.flip ? parts.reverse() : parts).join('');
};