mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
moving nodes.coffee over to use Tesco's new auto-setter style.
This commit is contained in:
141
lib/nodes.js
141
lib/nodes.js
@@ -255,8 +255,8 @@
|
|||||||
return new Expressions(nodes);
|
return new Expressions(nodes);
|
||||||
};
|
};
|
||||||
exports.LiteralNode = (function() {
|
exports.LiteralNode = (function() {
|
||||||
LiteralNode = function(value) {
|
LiteralNode = function(_b) {
|
||||||
this.value = value;
|
this.value = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(LiteralNode, BaseNode);
|
__extends(LiteralNode, BaseNode);
|
||||||
@@ -277,8 +277,8 @@
|
|||||||
return LiteralNode;
|
return LiteralNode;
|
||||||
})();
|
})();
|
||||||
exports.ReturnNode = (function() {
|
exports.ReturnNode = (function() {
|
||||||
ReturnNode = function(expression) {
|
ReturnNode = function(_b) {
|
||||||
this.expression = expression;
|
this.expression = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ReturnNode, BaseNode);
|
__extends(ReturnNode, BaseNode);
|
||||||
@@ -310,9 +310,10 @@
|
|||||||
return ReturnNode;
|
return ReturnNode;
|
||||||
})();
|
})();
|
||||||
exports.ValueNode = (function() {
|
exports.ValueNode = (function() {
|
||||||
ValueNode = function(base, properties) {
|
ValueNode = function(_b, _c) {
|
||||||
this.base = base;
|
this.properties = _c;
|
||||||
this.properties = properties || [];
|
this.base = _b;
|
||||||
|
this.properties = this.properties || [];
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ValueNode, BaseNode);
|
__extends(ValueNode, BaseNode);
|
||||||
@@ -403,8 +404,8 @@
|
|||||||
return ValueNode;
|
return ValueNode;
|
||||||
})();
|
})();
|
||||||
exports.CommentNode = (function() {
|
exports.CommentNode = (function() {
|
||||||
CommentNode = function(lines) {
|
CommentNode = function(_b) {
|
||||||
this.lines = lines;
|
this.lines = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(CommentNode, BaseNode);
|
__extends(CommentNode, BaseNode);
|
||||||
@@ -423,11 +424,12 @@
|
|||||||
return CommentNode;
|
return CommentNode;
|
||||||
})();
|
})();
|
||||||
exports.CallNode = (function() {
|
exports.CallNode = (function() {
|
||||||
CallNode = function(variable, args) {
|
CallNode = function(variable, _b) {
|
||||||
|
this.args = _b;
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
this.isSuper = variable === 'super';
|
this.isSuper = variable === 'super';
|
||||||
this.variable = this.isSuper ? null : variable;
|
this.variable = this.isSuper ? null : variable;
|
||||||
this.args = (args || []);
|
this.args = this.args || [];
|
||||||
this.compileSplatArguments = function(o) {
|
this.compileSplatArguments = function(o) {
|
||||||
return SplatNode.compileSplattedArray.call(this, this.args, o);
|
return SplatNode.compileSplattedArray.call(this, this.args, o);
|
||||||
};
|
};
|
||||||
@@ -501,9 +503,9 @@
|
|||||||
return CallNode;
|
return CallNode;
|
||||||
})();
|
})();
|
||||||
exports.ExtendsNode = (function() {
|
exports.ExtendsNode = (function() {
|
||||||
ExtendsNode = function(child, parent) {
|
ExtendsNode = function(_b, _c) {
|
||||||
this.child = child;
|
this.parent = _c;
|
||||||
this.parent = parent;
|
this.child = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ExtendsNode, BaseNode);
|
__extends(ExtendsNode, BaseNode);
|
||||||
@@ -517,8 +519,8 @@
|
|||||||
return ExtendsNode;
|
return ExtendsNode;
|
||||||
})();
|
})();
|
||||||
exports.AccessorNode = (function() {
|
exports.AccessorNode = (function() {
|
||||||
AccessorNode = function(name, tag) {
|
AccessorNode = function(_b, tag) {
|
||||||
this.name = name;
|
this.name = _b;
|
||||||
this.prototype = tag === 'prototype' ? '.prototype' : '';
|
this.prototype = tag === 'prototype' ? '.prototype' : '';
|
||||||
this.soakNode = tag === 'soak';
|
this.soakNode = tag === 'soak';
|
||||||
return this;
|
return this;
|
||||||
@@ -536,8 +538,8 @@
|
|||||||
return AccessorNode;
|
return AccessorNode;
|
||||||
})();
|
})();
|
||||||
exports.IndexNode = (function() {
|
exports.IndexNode = (function() {
|
||||||
IndexNode = function(index) {
|
IndexNode = function(_b) {
|
||||||
this.index = index;
|
this.index = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(IndexNode, BaseNode);
|
__extends(IndexNode, BaseNode);
|
||||||
@@ -553,9 +555,9 @@
|
|||||||
return IndexNode;
|
return IndexNode;
|
||||||
})();
|
})();
|
||||||
exports.RangeNode = (function() {
|
exports.RangeNode = (function() {
|
||||||
RangeNode = function(from, to, exclusive) {
|
RangeNode = function(_b, _c, exclusive) {
|
||||||
this.from = from;
|
this.to = _c;
|
||||||
this.to = to;
|
this.from = _b;
|
||||||
this.exclusive = !!exclusive;
|
this.exclusive = !!exclusive;
|
||||||
this.equals = this.exclusive ? '' : '=';
|
this.equals = this.exclusive ? '' : '=';
|
||||||
return this;
|
return this;
|
||||||
@@ -650,8 +652,8 @@
|
|||||||
return RangeNode;
|
return RangeNode;
|
||||||
})();
|
})();
|
||||||
exports.SliceNode = (function() {
|
exports.SliceNode = (function() {
|
||||||
SliceNode = function(range) {
|
SliceNode = function(_b) {
|
||||||
this.range = range;
|
this.range = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(SliceNode, BaseNode);
|
__extends(SliceNode, BaseNode);
|
||||||
@@ -714,8 +716,9 @@
|
|||||||
return ObjectNode;
|
return ObjectNode;
|
||||||
})();
|
})();
|
||||||
exports.ArrayNode = (function() {
|
exports.ArrayNode = (function() {
|
||||||
ArrayNode = function(objects) {
|
ArrayNode = function(_b) {
|
||||||
this.objects = objects || [];
|
this.objects = _b;
|
||||||
|
this.objects = this.objects || [];
|
||||||
this.compileSplatLiteral = function(o) {
|
this.compileSplatLiteral = function(o) {
|
||||||
return SplatNode.compileSplattedArray.call(this, this.objects, o);
|
return SplatNode.compileSplattedArray.call(this, this.objects, o);
|
||||||
};
|
};
|
||||||
@@ -748,10 +751,11 @@
|
|||||||
return ArrayNode;
|
return ArrayNode;
|
||||||
})();
|
})();
|
||||||
exports.ClassNode = (function() {
|
exports.ClassNode = (function() {
|
||||||
ClassNode = function(variable, parent, props) {
|
ClassNode = function(_b, _c, _d) {
|
||||||
this.variable = variable;
|
this.properties = _d;
|
||||||
this.parent = parent;
|
this.parent = _c;
|
||||||
this.properties = props || [];
|
this.variable = _b;
|
||||||
|
this.properties = this.properties || [];
|
||||||
this.returns = false;
|
this.returns = false;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@@ -830,10 +834,10 @@
|
|||||||
return ClassNode;
|
return ClassNode;
|
||||||
})();
|
})();
|
||||||
exports.AssignNode = (function() {
|
exports.AssignNode = (function() {
|
||||||
AssignNode = function(variable, value, context) {
|
AssignNode = function(_b, _c, _d) {
|
||||||
this.variable = variable;
|
this.context = _d;
|
||||||
this.value = value;
|
this.value = _c;
|
||||||
this.context = context;
|
this.variable = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(AssignNode, BaseNode);
|
__extends(AssignNode, BaseNode);
|
||||||
@@ -948,9 +952,11 @@
|
|||||||
return AssignNode;
|
return AssignNode;
|
||||||
})();
|
})();
|
||||||
exports.CodeNode = (function() {
|
exports.CodeNode = (function() {
|
||||||
CodeNode = function(params, body, tag) {
|
CodeNode = function(_b, _c, tag) {
|
||||||
this.params = params || [];
|
this.body = _c;
|
||||||
this.body = body || new Expressions();
|
this.params = _b;
|
||||||
|
this.params = this.params || [];
|
||||||
|
this.body = this.body || new Expressions();
|
||||||
this.bound = tag === 'boundfunc';
|
this.bound = tag === 'boundfunc';
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@@ -1185,10 +1191,11 @@
|
|||||||
return WhileNode;
|
return WhileNode;
|
||||||
})();
|
})();
|
||||||
exports.OpNode = (function() {
|
exports.OpNode = (function() {
|
||||||
OpNode = function(operator, first, second, flip) {
|
OpNode = function(_b, _c, _d, flip) {
|
||||||
this.first = first;
|
this.second = _d;
|
||||||
this.second = second;
|
this.first = _c;
|
||||||
this.operator = this.CONVERSIONS[operator] || operator;
|
this.operator = _b;
|
||||||
|
this.operator = this.CONVERSIONS[this.operator] || this.operator;
|
||||||
this.flip = !!flip;
|
this.flip = !!flip;
|
||||||
this.first instanceof ValueNode && this.first.base instanceof ObjectNode ? (this.first = new ParentheticalNode(this.first)) : null;
|
this.first instanceof ValueNode && this.first.base instanceof ObjectNode ? (this.first = new ParentheticalNode(this.first)) : null;
|
||||||
return this;
|
return this;
|
||||||
@@ -1275,9 +1282,9 @@
|
|||||||
return OpNode;
|
return OpNode;
|
||||||
})();
|
})();
|
||||||
exports.InNode = (function() {
|
exports.InNode = (function() {
|
||||||
InNode = function(object, array) {
|
InNode = function(_b, _c) {
|
||||||
this.object = object;
|
this.array = _c;
|
||||||
this.array = array;
|
this.object = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(InNode, BaseNode);
|
__extends(InNode, BaseNode);
|
||||||
@@ -1323,11 +1330,11 @@
|
|||||||
return InNode;
|
return InNode;
|
||||||
})();
|
})();
|
||||||
exports.TryNode = (function() {
|
exports.TryNode = (function() {
|
||||||
TryNode = function(attempt, error, recovery, ensure) {
|
TryNode = function(_b, _c, _d, _e) {
|
||||||
this.attempt = attempt;
|
this.ensure = _e;
|
||||||
this.recovery = recovery;
|
this.recovery = _d;
|
||||||
this.ensure = ensure;
|
this.error = _c;
|
||||||
this.error = error;
|
this.attempt = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(TryNode, BaseNode);
|
__extends(TryNode, BaseNode);
|
||||||
@@ -1358,8 +1365,8 @@
|
|||||||
return TryNode;
|
return TryNode;
|
||||||
})();
|
})();
|
||||||
exports.ThrowNode = (function() {
|
exports.ThrowNode = (function() {
|
||||||
ThrowNode = function(expression) {
|
ThrowNode = function(_b) {
|
||||||
this.expression = expression;
|
this.expression = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ThrowNode, BaseNode);
|
__extends(ThrowNode, BaseNode);
|
||||||
@@ -1377,8 +1384,8 @@
|
|||||||
return ThrowNode;
|
return ThrowNode;
|
||||||
})();
|
})();
|
||||||
exports.ExistenceNode = (function() {
|
exports.ExistenceNode = (function() {
|
||||||
ExistenceNode = function(expression) {
|
ExistenceNode = function(_b) {
|
||||||
this.expression = expression;
|
this.expression = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ExistenceNode, BaseNode);
|
__extends(ExistenceNode, BaseNode);
|
||||||
@@ -1397,8 +1404,8 @@
|
|||||||
return ExistenceNode;
|
return ExistenceNode;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
exports.ParentheticalNode = (function() {
|
exports.ParentheticalNode = (function() {
|
||||||
ParentheticalNode = function(expression) {
|
ParentheticalNode = function(_b) {
|
||||||
this.expression = expression;
|
this.expression = _b;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
__extends(ParentheticalNode, BaseNode);
|
__extends(ParentheticalNode, BaseNode);
|
||||||
@@ -1429,20 +1436,21 @@
|
|||||||
return ParentheticalNode;
|
return ParentheticalNode;
|
||||||
})();
|
})();
|
||||||
exports.ForNode = (function() {
|
exports.ForNode = (function() {
|
||||||
ForNode = function(body, source, name, index) {
|
ForNode = function(_b, source, _c, _d) {
|
||||||
var _b;
|
var _e;
|
||||||
this.body = body;
|
this.index = _d;
|
||||||
this.name = name;
|
this.name = _c;
|
||||||
this.index = index || null;
|
this.body = _b;
|
||||||
|
this.index = this.index || null;
|
||||||
this.source = source.source;
|
this.source = source.source;
|
||||||
this.guard = source.guard;
|
this.guard = source.guard;
|
||||||
this.step = source.step;
|
this.step = source.step;
|
||||||
this.raw = !!source.raw;
|
this.raw = !!source.raw;
|
||||||
this.object = !!source.object;
|
this.object = !!source.object;
|
||||||
if (this.object) {
|
if (this.object) {
|
||||||
_b = [this.index, this.name];
|
_e = [this.index, this.name];
|
||||||
this.name = _b[0];
|
this.name = _e[0];
|
||||||
this.index = _b[1];
|
this.index = _e[1];
|
||||||
}
|
}
|
||||||
this.pattern = this.name instanceof ValueNode;
|
this.pattern = this.name instanceof ValueNode;
|
||||||
if (this.index instanceof ValueNode) {
|
if (this.index instanceof ValueNode) {
|
||||||
@@ -1564,10 +1572,11 @@
|
|||||||
return ForNode;
|
return ForNode;
|
||||||
})();
|
})();
|
||||||
exports.IfNode = (function() {
|
exports.IfNode = (function() {
|
||||||
IfNode = function(condition, body, tags) {
|
IfNode = function(_b, _c, _d) {
|
||||||
this.condition = condition;
|
this.tags = _d;
|
||||||
this.body = body;
|
this.body = _c;
|
||||||
this.tags = tags || {};
|
this.condition = _b;
|
||||||
|
this.tags = this.tags || {};
|
||||||
if (this.tags.invert) {
|
if (this.tags.invert) {
|
||||||
this.condition = new OpNode('!', new ParentheticalNode(this.condition));
|
this.condition = new OpNode('!', new ParentheticalNode(this.condition));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,8 +236,7 @@ exports.LiteralNode = class LiteralNode extends BaseNode
|
|||||||
|
|
||||||
class: 'LiteralNode'
|
class: 'LiteralNode'
|
||||||
|
|
||||||
constructor: (value) ->
|
constructor: (@value) ->
|
||||||
@value = value
|
|
||||||
|
|
||||||
# Break and continue must be treated as pure statements -- they lose their
|
# Break and continue must be treated as pure statements -- they lose their
|
||||||
# meaning when wrapped in a closure.
|
# meaning when wrapped in a closure.
|
||||||
@@ -264,8 +263,7 @@ exports.ReturnNode = class ReturnNode extends BaseNode
|
|||||||
isPureStatement: -> yes
|
isPureStatement: -> yes
|
||||||
children: ['expression']
|
children: ['expression']
|
||||||
|
|
||||||
constructor: (expression) ->
|
constructor: (@expression) ->
|
||||||
@expression = expression
|
|
||||||
|
|
||||||
makeReturn: ->
|
makeReturn: ->
|
||||||
this
|
this
|
||||||
@@ -291,9 +289,8 @@ exports.ValueNode = class ValueNode extends BaseNode
|
|||||||
children: ['base', 'properties']
|
children: ['base', 'properties']
|
||||||
|
|
||||||
# A **ValueNode** has a base and a list of property accesses.
|
# A **ValueNode** has a base and a list of property accesses.
|
||||||
constructor: (base, properties) ->
|
constructor: (@base, @properties) ->
|
||||||
@base = base
|
@properties = or []
|
||||||
@properties = properties or []
|
|
||||||
|
|
||||||
# Add a property access to the list.
|
# Add a property access to the list.
|
||||||
push: (prop) ->
|
push: (prop) ->
|
||||||
@@ -378,8 +375,7 @@ exports.CommentNode = class CommentNode extends BaseNode
|
|||||||
class: 'CommentNode'
|
class: 'CommentNode'
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
constructor: (lines) ->
|
constructor: (@lines) ->
|
||||||
@lines = lines
|
|
||||||
|
|
||||||
makeReturn: ->
|
makeReturn: ->
|
||||||
this
|
this
|
||||||
@@ -397,11 +393,11 @@ exports.CallNode = class CallNode extends BaseNode
|
|||||||
class: 'CallNode'
|
class: 'CallNode'
|
||||||
children: ['variable', 'args']
|
children: ['variable', 'args']
|
||||||
|
|
||||||
constructor: (variable, args) ->
|
constructor: (variable, @args) ->
|
||||||
@isNew = false
|
@isNew = false
|
||||||
@isSuper = variable is 'super'
|
@isSuper = variable is 'super'
|
||||||
@variable = if @isSuper then null else variable
|
@variable = if @isSuper then null else variable
|
||||||
@args = (args or [])
|
@args = or []
|
||||||
@compileSplatArguments = (o) ->
|
@compileSplatArguments = (o) ->
|
||||||
SplatNode.compileSplattedArray.call(this, @args, o)
|
SplatNode.compileSplattedArray.call(this, @args, o)
|
||||||
|
|
||||||
@@ -471,9 +467,7 @@ exports.ExtendsNode = class ExtendsNode extends BaseNode
|
|||||||
class: 'ExtendsNode'
|
class: 'ExtendsNode'
|
||||||
children: ['child', 'parent']
|
children: ['child', 'parent']
|
||||||
|
|
||||||
constructor: (child, parent) ->
|
constructor: (@child, @parent) ->
|
||||||
@child = child
|
|
||||||
@parent = parent
|
|
||||||
|
|
||||||
# Hooks one constructor into another's prototype chain.
|
# Hooks one constructor into another's prototype chain.
|
||||||
compileNode: (o) ->
|
compileNode: (o) ->
|
||||||
@@ -489,8 +483,7 @@ exports.AccessorNode = class AccessorNode extends BaseNode
|
|||||||
class: 'AccessorNode'
|
class: 'AccessorNode'
|
||||||
children: ['name']
|
children: ['name']
|
||||||
|
|
||||||
constructor: (name, tag) ->
|
constructor: (@name, tag) ->
|
||||||
@name = name
|
|
||||||
@prototype = if tag is 'prototype' then '.prototype' else ''
|
@prototype = if tag is 'prototype' then '.prototype' else ''
|
||||||
@soakNode = tag is 'soak'
|
@soakNode = tag is 'soak'
|
||||||
|
|
||||||
@@ -508,8 +501,7 @@ exports.IndexNode = class IndexNode extends BaseNode
|
|||||||
class: 'IndexNode'
|
class: 'IndexNode'
|
||||||
children: ['index']
|
children: ['index']
|
||||||
|
|
||||||
constructor: (index) ->
|
constructor: (@index) ->
|
||||||
@index = index
|
|
||||||
|
|
||||||
compileNode: (o) ->
|
compileNode: (o) ->
|
||||||
o.chainRoot.wrapped = or @soakNode
|
o.chainRoot.wrapped = or @soakNode
|
||||||
@@ -527,9 +519,7 @@ exports.RangeNode = class RangeNode extends BaseNode
|
|||||||
class: 'RangeNode'
|
class: 'RangeNode'
|
||||||
children: ['from', 'to']
|
children: ['from', 'to']
|
||||||
|
|
||||||
constructor: (from, to, exclusive) ->
|
constructor: (@from, @to, exclusive) ->
|
||||||
@from = from
|
|
||||||
@to = to
|
|
||||||
@exclusive = !!exclusive
|
@exclusive = !!exclusive
|
||||||
@equals = if @exclusive then '' else '='
|
@equals = if @exclusive then '' else '='
|
||||||
|
|
||||||
@@ -600,8 +590,7 @@ exports.SliceNode = class SliceNode extends BaseNode
|
|||||||
class: 'SliceNode'
|
class: 'SliceNode'
|
||||||
children: ['range']
|
children: ['range']
|
||||||
|
|
||||||
constructor: (range) ->
|
constructor: (@range) ->
|
||||||
@range = range
|
|
||||||
|
|
||||||
compileNode: (o) ->
|
compileNode: (o) ->
|
||||||
from = @range.from.compile(o)
|
from = @range.from.compile(o)
|
||||||
@@ -643,8 +632,8 @@ exports.ArrayNode = class ArrayNode extends BaseNode
|
|||||||
class: 'ArrayNode'
|
class: 'ArrayNode'
|
||||||
children: ['objects']
|
children: ['objects']
|
||||||
|
|
||||||
constructor: (objects) ->
|
constructor: (@objects) ->
|
||||||
@objects = objects or []
|
@objects = or []
|
||||||
@compileSplatLiteral = (o) ->
|
@compileSplatLiteral = (o) ->
|
||||||
SplatNode.compileSplattedArray.call(this, @objects, o)
|
SplatNode.compileSplattedArray.call(this, @objects, o)
|
||||||
|
|
||||||
@@ -678,10 +667,8 @@ exports.ClassNode = class ClassNode extends BaseNode
|
|||||||
|
|
||||||
# Initialize a **ClassNode** with its name, an optional superclass, and a
|
# Initialize a **ClassNode** with its name, an optional superclass, and a
|
||||||
# list of prototype property assignments.
|
# list of prototype property assignments.
|
||||||
constructor: (variable, parent, props) ->
|
constructor: (@variable, @parent, @properties) ->
|
||||||
@variable = variable
|
@properties = or []
|
||||||
@parent = parent
|
|
||||||
@properties = props or []
|
|
||||||
@returns = false
|
@returns = false
|
||||||
|
|
||||||
makeReturn: ->
|
makeReturn: ->
|
||||||
@@ -751,10 +738,7 @@ exports.AssignNode = class AssignNode extends BaseNode
|
|||||||
class: 'AssignNode'
|
class: 'AssignNode'
|
||||||
children: ['variable', 'value']
|
children: ['variable', 'value']
|
||||||
|
|
||||||
constructor: (variable, value, context) ->
|
constructor: (@variable, @value, @context) ->
|
||||||
@variable = variable
|
|
||||||
@value = value
|
|
||||||
@context = context
|
|
||||||
|
|
||||||
topSensitive: ->
|
topSensitive: ->
|
||||||
true
|
true
|
||||||
@@ -853,9 +837,9 @@ exports.CodeNode = class CodeNode extends BaseNode
|
|||||||
class: 'CodeNode'
|
class: 'CodeNode'
|
||||||
children: ['params', 'body']
|
children: ['params', 'body']
|
||||||
|
|
||||||
constructor: (params, body, tag) ->
|
constructor: (@params, @body, tag) ->
|
||||||
@params = params or []
|
@params = or []
|
||||||
@body = body or new Expressions
|
@body = or new Expressions
|
||||||
@bound = tag is 'boundfunc'
|
@bound = tag is 'boundfunc'
|
||||||
|
|
||||||
# Compilation creates a new scope unless explicitly asked to share with the
|
# Compilation creates a new scope unless explicitly asked to share with the
|
||||||
@@ -1068,10 +1052,8 @@ exports.OpNode = class OpNode extends BaseNode
|
|||||||
class: 'OpNode'
|
class: 'OpNode'
|
||||||
children: ['first', 'second']
|
children: ['first', 'second']
|
||||||
|
|
||||||
constructor: (operator, first, second, flip) ->
|
constructor: (@operator, @first, @second, flip) ->
|
||||||
@first = first
|
@operator = @CONVERSIONS[@operator] or @operator
|
||||||
@second = second
|
|
||||||
@operator = @CONVERSIONS[operator] or operator
|
|
||||||
@flip = !!flip
|
@flip = !!flip
|
||||||
if @first instanceof ValueNode and @first.base instanceof ObjectNode
|
if @first instanceof ValueNode and @first.base instanceof ObjectNode
|
||||||
@first = new ParentheticalNode @first
|
@first = new ParentheticalNode @first
|
||||||
@@ -1133,9 +1115,7 @@ exports.InNode = class InNode extends BaseNode
|
|||||||
class: 'InNode'
|
class: 'InNode'
|
||||||
children: ['object', 'array']
|
children: ['object', 'array']
|
||||||
|
|
||||||
constructor: (object, array) ->
|
constructor: (@object, @array) ->
|
||||||
@object = object
|
|
||||||
@array = array
|
|
||||||
|
|
||||||
isArray: ->
|
isArray: ->
|
||||||
@array instanceof ValueNode and @array.isArray()
|
@array instanceof ValueNode and @array.isArray()
|
||||||
@@ -1164,11 +1144,7 @@ exports.TryNode = class TryNode extends BaseNode
|
|||||||
children: ['attempt', 'recovery', 'ensure']
|
children: ['attempt', 'recovery', 'ensure']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
constructor: (attempt, error, recovery, ensure) ->
|
constructor: (@attempt, @error, @recovery, @ensure) ->
|
||||||
@attempt = attempt
|
|
||||||
@recovery = recovery
|
|
||||||
@ensure = ensure
|
|
||||||
@error = error
|
|
||||||
|
|
||||||
makeReturn: ->
|
makeReturn: ->
|
||||||
@attempt = @attempt.makeReturn() if @attempt
|
@attempt = @attempt.makeReturn() if @attempt
|
||||||
@@ -1195,8 +1171,7 @@ exports.ThrowNode = class ThrowNode extends BaseNode
|
|||||||
children: ['expression']
|
children: ['expression']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
constructor: (expression) ->
|
constructor: (@expression) ->
|
||||||
@expression = expression
|
|
||||||
|
|
||||||
# A **ThrowNode** is already a return, of sorts...
|
# A **ThrowNode** is already a return, of sorts...
|
||||||
makeReturn: ->
|
makeReturn: ->
|
||||||
@@ -1215,8 +1190,7 @@ exports.ExistenceNode = class ExistenceNode extends BaseNode
|
|||||||
class: 'ExistenceNode'
|
class: 'ExistenceNode'
|
||||||
children: ['expression']
|
children: ['expression']
|
||||||
|
|
||||||
constructor: (expression) ->
|
constructor: (@expression) ->
|
||||||
@expression = expression
|
|
||||||
|
|
||||||
compileNode: (o) ->
|
compileNode: (o) ->
|
||||||
ExistenceNode.compileTest(o, @expression)
|
ExistenceNode.compileTest(o, @expression)
|
||||||
@@ -1240,8 +1214,7 @@ exports.ParentheticalNode = class ParentheticalNode extends BaseNode
|
|||||||
class: 'ParentheticalNode'
|
class: 'ParentheticalNode'
|
||||||
children: ['expression']
|
children: ['expression']
|
||||||
|
|
||||||
constructor: (expression) ->
|
constructor: (@expression) ->
|
||||||
@expression = expression
|
|
||||||
|
|
||||||
isStatement: ->
|
isStatement: ->
|
||||||
@expression.isStatement()
|
@expression.isStatement()
|
||||||
@@ -1276,10 +1249,8 @@ exports.ForNode = class ForNode extends BaseNode
|
|||||||
children: ['body', 'source', 'guard']
|
children: ['body', 'source', 'guard']
|
||||||
isStatement: -> yes
|
isStatement: -> yes
|
||||||
|
|
||||||
constructor: (body, source, name, index) ->
|
constructor: (@body, source, @name, @index) ->
|
||||||
@body = body
|
@index = or null
|
||||||
@name = name
|
|
||||||
@index = index or null
|
|
||||||
@source = source.source
|
@source = source.source
|
||||||
@guard = source.guard
|
@guard = source.guard
|
||||||
@step = source.step
|
@step = source.step
|
||||||
@@ -1367,10 +1338,8 @@ exports.IfNode = class IfNode extends BaseNode
|
|||||||
class: 'IfNode'
|
class: 'IfNode'
|
||||||
children: ['condition', 'switchSubject', 'body', 'elseBody', 'assigner']
|
children: ['condition', 'switchSubject', 'body', 'elseBody', 'assigner']
|
||||||
|
|
||||||
constructor: (condition, body, tags) ->
|
constructor: (@condition, @body, @tags) ->
|
||||||
@condition = condition
|
@tags = or {}
|
||||||
@body = body
|
|
||||||
@tags = tags or {}
|
|
||||||
@condition = new OpNode('!', new ParentheticalNode(@condition)) if @tags.invert
|
@condition = new OpNode('!', new ParentheticalNode(@condition)) if @tags.invert
|
||||||
@elseBody = null
|
@elseBody = null
|
||||||
@isChain = false
|
@isChain = false
|
||||||
|
|||||||
Reference in New Issue
Block a user