mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
Enchancing pattern matching with @vars ... issue #721
This commit is contained in:
15
lib/nodes.js
15
lib/nodes.js
@@ -300,11 +300,14 @@
|
||||
return ReturnNode;
|
||||
})();
|
||||
exports.ValueNode = (function() {
|
||||
ValueNode = function(_arg, _arg2) {
|
||||
ValueNode = function(_arg, _arg2, tag) {
|
||||
this.properties = _arg2;
|
||||
this.base = _arg;
|
||||
ValueNode.__super__.constructor.call(this);
|
||||
this.properties || (this.properties = []);
|
||||
if (tag) {
|
||||
this.tags[tag] = true;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
__extends(ValueNode, BaseNode);
|
||||
@@ -798,7 +801,9 @@
|
||||
join = '';
|
||||
}
|
||||
indent = prop instanceof CommentNode ? '' : this.idt(1);
|
||||
if (!(prop instanceof AssignNode || prop instanceof CommentNode)) {
|
||||
if (prop instanceof ValueNode && prop.tags['this']) {
|
||||
prop = new AssignNode(prop.properties[0].name, prop, 'object');
|
||||
} else if (!(prop instanceof AssignNode) && !(prop instanceof CommentNode)) {
|
||||
prop = new AssignNode(prop, prop, 'object');
|
||||
}
|
||||
return indent + prop.compile(o) + join;
|
||||
@@ -1018,7 +1023,11 @@
|
||||
if (obj instanceof AssignNode) {
|
||||
_ref2 = [obj.value, obj.variable.base], obj = _ref2[0], idx = _ref2[1];
|
||||
} else {
|
||||
idx = obj;
|
||||
if (obj.tags['this']) {
|
||||
idx = obj.properties[0].name;
|
||||
} else {
|
||||
idx = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(obj instanceof ValueNode || obj instanceof SplatNode)) {
|
||||
|
||||
Reference in New Issue
Block a user