mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
self-compiling pattern matching correctly
This commit is contained in:
@@ -779,7 +779,14 @@
|
||||
idx = __b[1];
|
||||
}
|
||||
access_class = this.variable.is_array() ? IndexNode : AccessorNode;
|
||||
obj instanceof SplatNode ? (val = new LiteralNode(obj.compile_value(o, val_var, this.variable.base.objects.indexOf(obj)))) : (val = new ValueNode(new LiteralNode(val_var), [new access_class(idx)]));
|
||||
if (obj instanceof SplatNode) {
|
||||
val = new LiteralNode(obj.compile_value(o, val_var, this.variable.base.objects.indexOf(obj)));
|
||||
} else {
|
||||
if (!(typeof idx === 'object')) {
|
||||
idx = new LiteralNode(idx);
|
||||
}
|
||||
val = new ValueNode(new LiteralNode(val_var), [new access_class(idx)]);
|
||||
}
|
||||
assigns.push(new AssignNode(obj, val).compile(o));
|
||||
}
|
||||
return assigns.join("\n");
|
||||
@@ -853,11 +860,13 @@
|
||||
return this.index ? this.compile_param(o) : this.name.compile(o);
|
||||
},
|
||||
compile_param: function compile_param(o) {
|
||||
o.scope.find(this.name);
|
||||
return this.name + ' = Array.prototype.slice.call(arguments, ' + this.index + ')';
|
||||
var name;
|
||||
name = this.name.compile(o);
|
||||
o.scope.find(name);
|
||||
return name + ' = Array.prototype.slice.call(arguments, ' + this.index + ')';
|
||||
},
|
||||
compile_value: function compile_value(o, name, index) {
|
||||
return "Array.prototype.slice.call(" + this.name + ', ' + this.index + ')';
|
||||
return "Array.prototype.slice.call(" + name + ', ' + index + ')';
|
||||
}
|
||||
}));
|
||||
// A while loop, the only sort of low-level loop exposed by CoffeeScript. From
|
||||
|
||||
Reference in New Issue
Block a user