mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
parent
5b7a7779fb
commit
76e70a6c81
3 changed files with 28 additions and 24 deletions
|
@ -1769,28 +1769,27 @@
|
|||
}
|
||||
|
||||
compileNode(o) {
|
||||
var assign, executableBody, parentName, result;
|
||||
var executableBody, node, parentName;
|
||||
this.name = this.determineName();
|
||||
executableBody = this.walkBody();
|
||||
if (this.parent instanceof Value && !this.parent.hasProperties()) {
|
||||
parentName = this.parent.base.value;
|
||||
}
|
||||
this.hasNameClash = (this.name != null) && this.name === parentName;
|
||||
node = this;
|
||||
if (executableBody || this.hasNameClash) {
|
||||
this.compileNode = this.compileClassDeclaration;
|
||||
result = new ExecutableClassBody(this, executableBody).compileToFragments(o);
|
||||
this.compileNode = this.constructor.prototype.compileNode;
|
||||
} else {
|
||||
result = this.compileClassDeclaration(o);
|
||||
if ((this.name == null) && o.level === LEVEL_TOP) {
|
||||
result = this.wrapInParentheses(result);
|
||||
}
|
||||
node = new ExecutableClassBody(node, executableBody);
|
||||
} else if ((this.name == null) && o.level === LEVEL_TOP) {
|
||||
node = new Parens(node);
|
||||
}
|
||||
if (this.variable) {
|
||||
assign = new Assign(this.variable, new Literal(''), null, {moduleDeclaration: this.moduleDeclaration});
|
||||
return [...assign.compileToFragments(o), ...result];
|
||||
} else {
|
||||
return result;
|
||||
node = new Assign(this.variable, node, null, {moduleDeclaration: this.moduleDeclaration});
|
||||
}
|
||||
this.compileNode = this.compileClassDeclaration;
|
||||
try {
|
||||
return node.compileToFragments(o);
|
||||
} finally {
|
||||
delete this.compileNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue