Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _this = this;
var i, iz;
// FunctionDeclaration name is defined in upper scope
// NOTE: Not referring variableScope. It is intended.
// Since
// in ES5, FunctionDeclaration should be in FunctionBody.
// in ES6, FunctionDeclaration should be block scoped.
if (node.type === Syntax.FunctionDeclaration) {
// id is defined in upper scope
this.currentScope().__define(node.id, new Definition(Variable.FunctionName, node.id, node, null, null, null));
}
// FunctionExpression with name creates its special scope;
// FunctionExpressionNameScope.
if (node.type === Syntax.FunctionExpression && node.id) {
this.scopeManager.__nestFunctionExpressionNameScope(node);
}
// Consider this function is in the MethodDefinition.
this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
// Process parameter declarations.
for (i = 0, iz = node.params.length; i < iz; ++i) {
this.visitPattern(node.params[i], { processRightHandNodes: true }, function (pattern, info) {
_this.currentScope().__define(pattern, new ParameterDefinition(pattern, node, i, info.rest));
_this.referencingDefaultValue(pattern, info.assignments, null, true);
});
}
// if there's a rest argument, add that
// id is defined in upper scope
this.currentScope().__define(node.id,
new Definition(
Variable.FunctionName,
node.id,
node,
null,
null,
null
));
}
// FunctionExpression with name creates its special scope;
// FunctionExpressionNameScope.
if (node.type === Syntax.FunctionExpression && node.id) {
this.scopeManager.__nestFunctionExpressionNameScope(node);
}
// Consider this function is in the MethodDefinition.
this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
const that = this;
/**
* Visit pattern callback
* @param {pattern} pattern - pattern
* @param {Object} info - info
* @returns {void}
*/
function visitPatternCallback(pattern, info) {
that.currentScope().__define(pattern,
// id is defined in upper scope
this.currentScope().__define(node.id,
new Definition(
Variable.FunctionName,
node.id,
node,
null,
null,
null
));
}
// FunctionExpression with name creates its special scope;
// FunctionExpressionNameScope.
if (node.type === Syntax.FunctionExpression && node.id) {
this.scopeManager.__nestFunctionExpressionNameScope(node);
}
// Consider this function is in the MethodDefinition.
this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
const that = this;
/**
* Visit pattern callback
* @param {pattern} pattern - pattern
* @param {Object} info - info
* @returns {void}
*/
function visitPatternCallback(pattern, info) {
that.currentScope().__define(pattern,
// id is defined in upper scope
this.currentScope().__define(node.id,
new Definition(
Variable.FunctionName,
node.id,
node,
null,
null,
null
));
}
// FunctionExpression with name creates its special scope;
// FunctionExpressionNameScope.
if (node.type === Syntax.FunctionExpression && node.id) {
this.scopeManager.__nestFunctionExpressionNameScope(node);
}
// Consider this function is in the MethodDefinition.
this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
const that = this;
/**
* Visit pattern callback
* @param {pattern} pattern - pattern
* @param {Object} info - info
* @returns {void}
*/
function visitPatternCallback(pattern, info) {
that.currentScope().__define(pattern,
if (node.type === Syntax.FunctionDeclaration) {
// id is defined in upper scope
this.currentScope().__define(node.id,
new Definition(
Variable.FunctionName,
node.id,
node,
null,
null,
null
));
}
// FunctionExpression with name creates its special scope;
// FunctionExpressionNameScope.
if (node.type === Syntax.FunctionExpression && node.id) {
this.scopeManager.__nestFunctionExpressionNameScope(node);
}
// Consider this function is in the MethodDefinition.
this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
// Process parameter declarations.
for (i = 0, iz = node.params.length; i < iz; ++i) {
this.visitPattern(node.params[i], {processRightHandNodes: true}, (pattern, info) => {
this.currentScope().__define(pattern,
new ParameterDefinition(
pattern,
node,
i,
info.rest
));
// id is defined in upper scope
this.currentScope().__define(node.id,
new Definition(
Variable.FunctionName,
node.id,
node,
null,
null,
null
));
}
// FunctionExpression with name creates its special scope;
// FunctionExpressionNameScope.
if (node.type === Syntax.FunctionExpression && node.id) {
this.scopeManager.__nestFunctionExpressionNameScope(node);
}
// Consider this function is in the MethodDefinition.
this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
const that = this;
/**
* Visit pattern callback
* @param {pattern} pattern - pattern
* @param {Object} info - info
* @returns {void}
*/
function visitPatternCallback(pattern, info) {
that.currentScope().__define(pattern,
function naming(node) {
switch (node.type) {
case Syntax.FunctionExpression:
return build.functionExpression(node.id,
[addresses.shift()].concat(node.params),
node.body);
// add a gensym onto the address variable
case Syntax.CallExpression:
if (isPrimitive(node.callee)) {
return node;
} else {
return build.callExpression(node.callee,
[makeAddressExtension(addresses[0])].concat(node.arguments));
}
default:
}
}
var _this = this;
var i, iz;
// FunctionDeclaration name is defined in upper scope
// NOTE: Not referring variableScope. It is intended.
// Since
// in ES5, FunctionDeclaration should be in FunctionBody.
// in ES6, FunctionDeclaration should be block scoped.
if (node.type === Syntax.FunctionDeclaration) {
// id is defined in upper scope
this.currentScope().__define(node.id, new Definition(Variable.FunctionName, node.id, node, null, null, null));
}
// FunctionExpression with name creates its special scope;
// FunctionExpressionNameScope.
if (node.type === Syntax.FunctionExpression && node.id) {
this.scopeManager.__nestFunctionExpressionNameScope(node);
}
// Consider this function is in the MethodDefinition.
this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
// Process parameter declarations.
for (i = 0, iz = node.params.length; i < iz; ++i) {
this.visitPattern(node.params[i], { processRightHandNodes: true }, function (pattern, info) {
_this.currentScope().__define(pattern, new ParameterDefinition(pattern, node, i, info.rest));
_this.referencingDefaultValue(pattern, info.assignments, null, true);
});
}
// if there's a rest argument, add that
function isPrimitive(node) {
switch (node.type) {
case Syntax.FunctionExpression:
case Syntax.Identifier:
case Syntax.CallExpression:
return false;
case Syntax.MemberExpression:
return (types.Identifier.check(node.object) ||
(!node.computed) && types.Identifier.check(node.property));
default:
console.log(node);
throw "isPrimitive doesn't handle node";
}
}
});
}
else {
var x = genvar('result');
return cps(node, buildContinuation(x, metaK(x)));
}
}),
clause(Syntax.ConditionalExpression, function(test, consequent, alternate) {
return atomize(test, function(test) {
var x = genvar('result');
return bindContinuation(buildContinuation(x, metaK(x)), function(k) {
return build.conditionalExpression(test, cps(consequent, k), cps(alternate, k));
});
});
}),
clause(Syntax.FunctionExpression, function(id, params, body) {
return metaK(cpsFunction(id, params, body));
}),
clause(Syntax.Identifier, function() {
return metaK(node);
}),
clause(Syntax.Literal, function() {
return metaK(node);
}),
clause(Syntax.LogicalExpression, function(left, right) {
return atomize(left, function(left) {
var x = genvar('result');
return bindContinuation(buildContinuation(x, metaK(x)), function(k) {
if (node.operator === '||') {
return build.conditionalExpression(left, cps(left, k), cps(right, k));
}
else if (node.operator === '&&') {