mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
fixes #1234 ... :: now creates an intermediary "prototype" Access node before any additional property accesses
This commit is contained in:
parent
e5b77b180a
commit
29a44b84d5
7 changed files with 33 additions and 26 deletions
|
@ -382,6 +382,10 @@
|
|||
this.properties.push(prop);
|
||||
return this;
|
||||
};
|
||||
Value.prototype.concat = function(props) {
|
||||
this.properties = this.properties.concat(props);
|
||||
return this;
|
||||
};
|
||||
Value.prototype.hasProperties = function() {
|
||||
return !!this.properties.length;
|
||||
};
|
||||
|
@ -686,14 +690,17 @@
|
|||
function Access(name, tag) {
|
||||
this.name = name;
|
||||
this.name.asKey = true;
|
||||
this.proto = tag === 'proto' ? '.prototype' : '';
|
||||
this.soak = tag === 'soak';
|
||||
}
|
||||
Access.prototype.children = ['name'];
|
||||
Access.prototype.compile = function(o) {
|
||||
var name;
|
||||
name = this.name.compile(o);
|
||||
return this.proto + (IDENTIFIER.test(name) ? "." + name : "[" + name + "]");
|
||||
if (IDENTIFIER.test(name)) {
|
||||
return "." + name;
|
||||
} else {
|
||||
return "[" + name + "]";
|
||||
}
|
||||
};
|
||||
Access.prototype.isComplex = NO;
|
||||
return Access;
|
||||
|
@ -705,7 +712,7 @@
|
|||
}
|
||||
Index.prototype.children = ['index'];
|
||||
Index.prototype.compile = function(o) {
|
||||
return (this.proto ? '.prototype' : '') + ("[" + (this.index.compile(o, LEVEL_PAREN)) + "]");
|
||||
return "[" + (this.index.compile(o, LEVEL_PAREN)) + "]";
|
||||
};
|
||||
Index.prototype.isComplex = function() {
|
||||
return this.index.isComplex();
|
||||
|
@ -970,11 +977,11 @@
|
|||
}
|
||||
} else {
|
||||
if (!assign.variable["this"]) {
|
||||
assign.variable = new Value(new Literal(name), [new Access(base, 'proto')]);
|
||||
}
|
||||
if (func instanceof Code && func.bound && !assign.variable["this"]) {
|
||||
this.boundFuncs.push(base);
|
||||
func.bound = false;
|
||||
assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]);
|
||||
if (func instanceof Code && func.bound) {
|
||||
this.boundFuncs.push(base);
|
||||
func.bound = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue