mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
nodes: @soakNode -> @soak
This commit is contained in:
parent
2aa093b65c
commit
27cdafb2d0
5 changed files with 22 additions and 22 deletions
|
@ -178,7 +178,7 @@
|
|||
return new Index($2);
|
||||
}), o('INDEX_SOAK Index', function() {
|
||||
return extend($2, {
|
||||
soakNode: true
|
||||
soak: true
|
||||
});
|
||||
}), o('INDEX_PROTO Index', function() {
|
||||
return extend($2, {
|
||||
|
|
18
lib/nodes.js
18
lib/nodes.js
|
@ -106,7 +106,7 @@
|
|||
}
|
||||
return _result;
|
||||
}).call(this)).join('');
|
||||
klass = override || this.constructor.name + (this.soakNode ? '?' : '');
|
||||
klass = override || this.constructor.name + (this.soak ? '?' : '');
|
||||
return '\n' + idt + klass + children;
|
||||
};
|
||||
Base.prototype.eachChild = function(func) {
|
||||
|
@ -363,7 +363,7 @@
|
|||
_ref2 = this.properties.concat(this.base);
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
node = _ref2[_i];
|
||||
if (node.soakNode || node instanceof Call) {
|
||||
if (node.soak || node instanceof Call) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -425,8 +425,8 @@
|
|||
_ref2 = this.properties;
|
||||
for (i = 0, _len = _ref2.length; i < _len; i++) {
|
||||
prop = _ref2[i];
|
||||
if (prop.soakNode) {
|
||||
prop.soakNode = false;
|
||||
if (prop.soak) {
|
||||
prop.soak = false;
|
||||
fst = new Value(this.base, this.properties.slice(0, i));
|
||||
snd = new Value(this.base, this.properties.slice(i));
|
||||
if (fst.isComplex()) {
|
||||
|
@ -464,7 +464,7 @@
|
|||
exports.Call = (function() {
|
||||
Call = (function() {
|
||||
function Call(variable, _arg, _arg2) {
|
||||
this.soakNode = _arg2;
|
||||
this.soak = _arg2;
|
||||
this.args = _arg;
|
||||
Call.__super__.constructor.call(this);
|
||||
this.isNew = false;
|
||||
|
@ -495,7 +495,7 @@
|
|||
};
|
||||
Call.prototype.unfoldSoak = function(o) {
|
||||
var _i, _len, _ref2, _ref3, call, ifn, left, list, rite;
|
||||
if (this.soakNode) {
|
||||
if (this.soak) {
|
||||
if (this.variable) {
|
||||
if (ifn = If.unfoldSoak(o, this, 'variable')) {
|
||||
return ifn;
|
||||
|
@ -615,7 +615,7 @@
|
|||
this.name = _arg;
|
||||
Accessor.__super__.constructor.call(this);
|
||||
this.proto = tag === 'prototype' ? '.prototype' : '';
|
||||
this.soakNode = tag === 'soak';
|
||||
this.soak = tag === 'soak';
|
||||
return this;
|
||||
}
|
||||
return Accessor;
|
||||
|
@ -1695,7 +1695,7 @@
|
|||
this.body = _arg;
|
||||
this.tags = tags || (tags = {});
|
||||
this.condition = tags.invert ? condition.invert() : condition;
|
||||
this.soakNode = tags.soak;
|
||||
this.soak = tags.soak;
|
||||
this.elseBody = null;
|
||||
this.isChain = false;
|
||||
return this;
|
||||
|
@ -1767,7 +1767,7 @@
|
|||
return o.level >= LEVEL_COND ? "(" + code + ")" : code;
|
||||
};
|
||||
If.prototype.unfoldSoak = function() {
|
||||
return this.soakNode && this;
|
||||
return this.soak && this;
|
||||
};
|
||||
If.unfoldSoak = function(o, parent, name) {
|
||||
var ifn;
|
||||
|
|
|
@ -172,7 +172,7 @@ break;
|
|||
case 81:this.$ = new yy.Index($$[$0-3+2-1]);
|
||||
break;
|
||||
case 82:this.$ = yy.extend($$[$0-2+2-1], {
|
||||
soakNode: true
|
||||
soak: true
|
||||
});
|
||||
break;
|
||||
case 83:this.$ = yy.extend($$[$0-2+2-1], {
|
||||
|
|
|
@ -247,7 +247,7 @@ grammar =
|
|||
# Indexing into an object or array using bracket notation.
|
||||
Index: [
|
||||
o 'INDEX_START Expression INDEX_END', -> new Index $2
|
||||
o 'INDEX_SOAK Index', -> extend $2, soakNode: yes
|
||||
o 'INDEX_SOAK Index', -> extend $2, soak : yes
|
||||
o 'INDEX_PROTO Index', -> extend $2, proto: yes
|
||||
]
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ exports.Base = class Base
|
|||
toString: (idt, override) ->
|
||||
idt or= ''
|
||||
children = (child.toString idt + TAB for child in @collectChildren()).join('')
|
||||
klass = override or @constructor.name + if @soakNode then '?' else ''
|
||||
klass = override or @constructor.name + if @soak then '?' else ''
|
||||
'\n' + idt + klass + children
|
||||
|
||||
# Passes each child to a function, breaking when the function returns `false`.
|
||||
|
@ -325,7 +325,7 @@ exports.Value = class Value extends Base
|
|||
isSimpleNumber : -> @base instanceof Literal and SIMPLENUM.test @base.value
|
||||
isAtomic : ->
|
||||
for node in @properties.concat @base
|
||||
return no if node.soakNode or node instanceof Call
|
||||
return no if node.soak or node instanceof Call
|
||||
yes
|
||||
|
||||
isStatement : (o) -> not @properties.length and @base.isStatement o
|
||||
|
@ -372,8 +372,8 @@ exports.Value = class Value extends Base
|
|||
if ifn = @base.unfoldSoak o
|
||||
Array::push.apply ifn.body.properties, @properties
|
||||
return ifn
|
||||
for prop, i in @properties when prop.soakNode
|
||||
prop.soakNode = off
|
||||
for prop, i in @properties when prop.soak
|
||||
prop.soak = off
|
||||
fst = new Value @base, @properties.slice 0, i
|
||||
snd = new Value @base, @properties.slice i
|
||||
if fst.isComplex()
|
||||
|
@ -406,7 +406,7 @@ exports.Call = class Call extends Base
|
|||
|
||||
children: ['variable', 'args']
|
||||
|
||||
constructor: (variable, @args, @soakNode) ->
|
||||
constructor: (variable, @args, @soak) ->
|
||||
super()
|
||||
@isNew = false
|
||||
@isSuper = variable is 'super'
|
||||
|
@ -431,7 +431,7 @@ exports.Call = class Call extends Base
|
|||
|
||||
# Soaked chained invocations unfold into if/else ternary structures.
|
||||
unfoldSoak: (o) ->
|
||||
if @soakNode
|
||||
if @soak
|
||||
if @variable
|
||||
return ifn if ifn = If.unfoldSoak o, this, 'variable'
|
||||
[left, rite] = new Value(@variable).cacheReference o
|
||||
|
@ -527,8 +527,8 @@ exports.Accessor = class Accessor extends Base
|
|||
|
||||
constructor: (@name, tag) ->
|
||||
super()
|
||||
@proto = if tag is 'prototype' then '.prototype' else ''
|
||||
@soakNode = tag is 'soak'
|
||||
@proto = if tag is 'prototype' then '.prototype' else ''
|
||||
@soak = tag is 'soak'
|
||||
|
||||
compile: (o) ->
|
||||
name = @name.compile o
|
||||
|
@ -1389,7 +1389,7 @@ exports.If = class If extends Base
|
|||
constructor: (condition, @body, tags) ->
|
||||
@tags = tags or= {}
|
||||
@condition = if tags.invert then condition.invert() else condition
|
||||
@soakNode = tags.soak
|
||||
@soak = tags.soak
|
||||
@elseBody = null
|
||||
@isChain = false
|
||||
|
||||
|
@ -1448,7 +1448,7 @@ exports.If = class If extends Base
|
|||
@elseBodyNode()?.compile o, LEVEL_LIST
|
||||
if o.level >= LEVEL_COND then "(#{code})" else code
|
||||
|
||||
unfoldSoak: -> @soakNode and this
|
||||
unfoldSoak: -> @soak and this
|
||||
|
||||
# Unfold a node's child if soak, then tuck the node under created `If`
|
||||
@unfoldSoak: (o, parent, name) ->
|
||||
|
|
Loading…
Add table
Reference in a new issue