/** * 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 result = []; objectProperties.forEach((property) => { const functionName = property.key.name; const name = `${objName}.${functionName}`; if (t.isArrowFunctionExpression(property.value)) { const paramIds = property.value.params.map(p => p.name); const isAsync = !!property.value.async; result.push({ const paramIds = property.params.map(p => p.name); const isAsync = !!property.async; result.push({ const subObjName = `${objName}.${property.key.name}`; const { properties } = property.value; const subResult = traverseProperties(subObjName, properties);
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);