/** * Filter out disallowed V8 runtime functions. */ function neuterDisallowedV8Natives(ast) { babelTraverse(ast, { CallExpression(path) { if (!babelTypes.isIdentifier(path.node.callee) || !path.node.callee.name.startsWith(V8_BUILTIN_PREFIX)) { return; } const functionName = path.node.callee.name.substr( V8_BUILTIN_PREFIX.length); if (!exceptions.isAllowedRuntimeFunction(functionName)) { path.replaceWith(babelTypes.callExpression( babelTypes.identifier('nop'), [])); } } }); }
const paramIds = property.params.map(p => p.name); const isAsync = !!property.async; result.push({
Identifier(path) { if (globalIdentifiers.has(path.node.name) && path.node.name != 'eval') { if (propertyNames.has(path.node.name) && path.parentPath.isMemberExpression() && path.parentKey !== 'object') { let binding = path.scope.getBinding(path.node.name); if (!binding) { if (path.node.name.startsWith('VAR_')) { newName = path.node.name; } else if (babelTypes.isFunctionDeclaration(binding.path.node) || babelTypes.isFunctionExpression(binding.path.node) || } else { newName = 'VAR_' + varIndex++; path.scope.rename(path.node.name, newName); path.node.__idDependencies = path.node.__idDependencies || []; if (path.node.__idDependencies.length <= MAX_DEPENDENCIES) { path.node.__idDependencies.push(newName);