move super reference into closure
This commit is contained in:
@@ -58,15 +58,23 @@ Class.prototype.run = function () {
|
||||
t.variableDeclarator(className, constructor)
|
||||
]));
|
||||
|
||||
var closureArgs = [];
|
||||
var closureParams = [];
|
||||
|
||||
//
|
||||
|
||||
if (superName) {
|
||||
// so we're only evaluating it once
|
||||
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
|
||||
body.unshift(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(superRef, superName)
|
||||
]));
|
||||
superName = superRef;
|
||||
closureArgs.push(superName);
|
||||
|
||||
if (!t.isIdentifier(superName)) {
|
||||
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
|
||||
body.unshift(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(superRef, superName)
|
||||
]));
|
||||
superName = superRef;
|
||||
}
|
||||
|
||||
closureParams.push(superName);
|
||||
|
||||
this.superName = superName;
|
||||
body.push(t.expressionStatement(t.callExpression(file.addHelper("inherits"), [className, superName])));
|
||||
@@ -84,8 +92,8 @@ Class.prototype.run = function () {
|
||||
} else {
|
||||
body.push(t.returnStatement(className));
|
||||
init = t.callExpression(
|
||||
t.functionExpression(null, [], t.blockStatement(body)),
|
||||
[]
|
||||
t.functionExpression(null, closureParams, t.blockStatement(body)),
|
||||
closureArgs
|
||||
);
|
||||
}
|
||||
|
||||
@@ -212,25 +220,12 @@ Class.prototype.superProperty = function (property, isStatic, isComputed) {
|
||||
this.file.addHelper("get"),
|
||||
[
|
||||
t.callExpression(
|
||||
t.memberExpression(
|
||||
t.identifier("Object"),
|
||||
t.identifier("getPrototypeOf"),
|
||||
false
|
||||
),
|
||||
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
|
||||
[
|
||||
isStatic ?
|
||||
this.className :
|
||||
t.memberExpression(
|
||||
this.className,
|
||||
t.identifier("prototype"),
|
||||
false
|
||||
)
|
||||
isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
|
||||
]
|
||||
),
|
||||
isComputed ?
|
||||
property :
|
||||
t.literal(property.name),
|
||||
t.thisExpression()
|
||||
isComputed ? property : t.literal(property.name), t.thisExpression()
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
@@ -38,8 +38,7 @@ var _inherits = function (child, parent) {
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _Foo = Foo;
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
var _get2, _get3, _get4, _get5;
|
||||
woops["super"].test();
|
||||
@@ -53,7 +52,7 @@ var Test = (function () {
|
||||
(_get5 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get5, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
_inherits(Test, _Foo);
|
||||
_inherits(Test, Foo);
|
||||
|
||||
Test.prototype.test = function () {
|
||||
var _get6, _get7;
|
||||
@@ -70,5 +69,4 @@ var Test = (function () {
|
||||
};
|
||||
|
||||
return Test;
|
||||
})();
|
||||
|
||||
})(Foo);
|
||||
|
||||
@@ -37,15 +37,13 @@ var _inherits = function (child, parent) {
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _Foo = Foo;
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this);
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever;
|
||||
};
|
||||
|
||||
_inherits(Test, _Foo);
|
||||
_inherits(Test, Foo);
|
||||
|
||||
return Test;
|
||||
})();
|
||||
|
||||
})(Foo);
|
||||
|
||||
@@ -37,19 +37,17 @@ var _inherits = function (child, parent) {
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _Foo = Foo;
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever();
|
||||
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
|
||||
};
|
||||
|
||||
_inherits(Test, _Foo);
|
||||
_inherits(Test, Foo);
|
||||
|
||||
Test.test = function () {
|
||||
return _get(Object.getPrototypeOf(Test), "wow", this).call(this);
|
||||
};
|
||||
|
||||
return Test;
|
||||
})();
|
||||
|
||||
})(Foo);
|
||||
|
||||
@@ -19,13 +19,12 @@ var Test = function Test() {
|
||||
this.state = "test";
|
||||
};
|
||||
|
||||
var Foo = (function () {
|
||||
var _Bar = Bar;
|
||||
var Foo = (function (Bar) {
|
||||
var Foo = function Foo() {
|
||||
this.state = "test";
|
||||
};
|
||||
|
||||
_inherits(Foo, _Bar);
|
||||
_inherits(Foo, Bar);
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
})(Bar);
|
||||
|
||||
@@ -15,7 +15,7 @@ var _inherits = function (child, parent) {
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var BaseController = (function () {
|
||||
var BaseController = (function (_Chaplin$Controller) {
|
||||
var _Chaplin$Controller = Chaplin.Controller;
|
||||
var BaseController = function BaseController() {
|
||||
if (Object.getPrototypeOf(BaseController) !== null) {
|
||||
@@ -26,9 +26,9 @@ var BaseController = (function () {
|
||||
_inherits(BaseController, _Chaplin$Controller);
|
||||
|
||||
return BaseController;
|
||||
})();
|
||||
})(Chaplin.Controller);
|
||||
|
||||
var BaseController2 = (function () {
|
||||
var BaseController2 = (function (_Chaplin$Controller$Another) {
|
||||
var _Chaplin$Controller$Another = Chaplin.Controller.Another;
|
||||
var BaseController2 = function BaseController2() {
|
||||
if (Object.getPrototypeOf(BaseController2) !== null) {
|
||||
@@ -39,4 +39,4 @@ var BaseController2 = (function () {
|
||||
_inherits(BaseController2, _Chaplin$Controller$Another);
|
||||
|
||||
return BaseController2;
|
||||
})();
|
||||
})(Chaplin.Controller.Another);
|
||||
|
||||
@@ -15,15 +15,14 @@ var _inherits = function (child, parent) {
|
||||
if (parent) child.__proto__ = parent;
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _Foo = Foo;
|
||||
var Test = (function (Foo) {
|
||||
var Test = function Test() {
|
||||
if (Object.getPrototypeOf(Test) !== null) {
|
||||
Object.getPrototypeOf(Test).apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(Test, _Foo);
|
||||
_inherits(Test, Foo);
|
||||
|
||||
return Test;
|
||||
})();
|
||||
})(Foo);
|
||||
|
||||
@@ -25,15 +25,14 @@ var _inherits = function (child, parent) {
|
||||
if (parent) _defaults(child, parent);
|
||||
};
|
||||
|
||||
var Foo = (function () {
|
||||
var _Bar = Bar;
|
||||
var Foo = (function (Bar) {
|
||||
var Foo = function Foo() {
|
||||
if (Object.getPrototypeOf(Foo) !== null) {
|
||||
Object.getPrototypeOf(Foo).apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(Foo, _Bar);
|
||||
_inherits(Foo, Bar);
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
})(Bar);
|
||||
|
||||
Reference in New Issue
Block a user