update alias-functions transformer to use types

This commit is contained in:
Sebastian McKenzie
2014-11-03 21:16:15 +11:00
parent f540c3f4b7
commit e3b9a0dd38

View File

@@ -1,17 +1,16 @@
var traverse = require("../traverse");
var t = require("../types");
var b = require("../builders");
var go = function (getBody, node, file) {
var argumentsId;
var thisId;
var getArgumentsId = function () {
return argumentsId = argumentsId || b.identifier(file.generateUid("arguments"));
return argumentsId = argumentsId || t.identifier(file.generateUid("arguments"));
};
var getThisId = function () {
return thisId = thisId || b.identifier(file.generateUid("this"));
return thisId = thisId || t.identifier(file.generateUid("this"));
};
// traverse the function and find all alias functions so we can alias
@@ -57,17 +56,17 @@ var go = function (getBody, node, file) {
var pushDeclaration = function (id, init) {
body = body || getBody();
body.unshift(b.variableDeclaration("var", [
b.variableDeclarator(id, init)
body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(id, init)
]));
};
if (argumentsId) {
pushDeclaration(argumentsId, b.identifier("arguments"));
pushDeclaration(argumentsId, t.identifier("arguments"));
}
if (thisId) {
pushDeclaration(thisId, b.identifier("this"));
pushDeclaration(thisId, t.identifier("this"));
}
};