@@ -1609,67 +1609,62 @@ class Parser extends Tapable {
16091609 this . walkClass ( expression ) ;
16101610 }
16111611
1612- walkCallExpression ( expression ) {
1613- let result ;
1614-
1615- const walkIIFE = ( functionExpression , options , currentThis ) => {
1616- const renameArgOrThis = argOrThis => {
1617- const renameIdentifier = this . getRenameIdentifier ( argOrThis ) ;
1618- if ( renameIdentifier ) {
1619- const hook = this . hooks . canRename . get ( renameIdentifier ) ;
1620- if ( hook !== undefined && hook . call ( argOrThis ) ) {
1621- const hook = this . hooks . rename . get ( renameIdentifier ) ;
1622- if ( hook === undefined || ! hook . call ( argOrThis ) )
1623- return renameIdentifier ;
1624- }
1625- }
1626- this . walkExpression ( argOrThis ) ;
1627- } ;
1628- const wasTopLevel = this . scope . topLevelScope ;
1629- this . scope . topLevelScope = false ;
1630- const params = functionExpression . params ;
1631- const renameThis = currentThis ? renameArgOrThis ( currentThis ) : null ;
1632- const args = options . map ( renameArgOrThis ) ;
1633- this . inScope ( params . filter ( ( identifier , idx ) => ! args [ idx ] ) , ( ) => {
1634- if ( renameThis ) {
1635- this . scope . renames . set ( "this" , renameThis ) ;
1612+ _walkIIFE ( functionExpression , options , currentThis ) {
1613+ const renameArgOrThis = argOrThis => {
1614+ const renameIdentifier = this . getRenameIdentifier ( argOrThis ) ;
1615+ if ( renameIdentifier ) {
1616+ const hook = this . hooks . canRename . get ( renameIdentifier ) ;
1617+ if ( hook !== undefined && hook . call ( argOrThis ) ) {
1618+ const hook = this . hooks . rename . get ( renameIdentifier ) ;
1619+ if ( hook === undefined || ! hook . call ( argOrThis ) )
1620+ return renameIdentifier ;
16361621 }
1637- for ( let i = 0 ; i < args . length ; i ++ ) {
1638- const param = args [ i ] ;
1639- if ( ! param ) continue ;
1640- if ( ! params [ i ] || params [ i ] . type !== "Identifier" ) continue ;
1641- this . scope . renames . set ( params [ i ] . name , param ) ;
1642- }
1643- if ( functionExpression . body . type === "BlockStatement" ) {
1644- this . prewalkStatement ( functionExpression . body ) ;
1645- this . walkStatement ( functionExpression . body ) ;
1646- } else this . walkExpression ( functionExpression . body ) ;
1647- } ) ;
1648- this . scope . topLevelScope = wasTopLevel ;
1622+ }
1623+ this . walkExpression ( argOrThis ) ;
16491624 } ;
1625+ const params = functionExpression . params ;
1626+ const renameThis = currentThis ? renameArgOrThis ( currentThis ) : null ;
1627+ const args = options . map ( renameArgOrThis ) ;
1628+ const wasTopLevel = this . scope . topLevelScope ;
1629+ this . scope . topLevelScope = false ;
1630+ this . inScope ( params . filter ( ( identifier , idx ) => ! args [ idx ] ) , ( ) => {
1631+ if ( renameThis ) {
1632+ this . scope . renames . set ( "this" , renameThis ) ;
1633+ }
1634+ for ( let i = 0 ; i < args . length ; i ++ ) {
1635+ const param = args [ i ] ;
1636+ if ( ! param ) continue ;
1637+ if ( ! params [ i ] || params [ i ] . type !== "Identifier" ) continue ;
1638+ this . scope . renames . set ( params [ i ] . name , param ) ;
1639+ }
1640+ if ( functionExpression . body . type === "BlockStatement" ) {
1641+ this . prewalkStatement ( functionExpression . body ) ;
1642+ this . walkStatement ( functionExpression . body ) ;
1643+ } else this . walkExpression ( functionExpression . body ) ;
1644+ } ) ;
1645+ this . scope . topLevelScope = wasTopLevel ;
1646+ }
1647+
1648+ walkCallExpression ( expression ) {
16501649 if (
16511650 expression . callee . type === "MemberExpression" &&
16521651 expression . callee . object . type === "FunctionExpression" &&
16531652 ! expression . callee . computed &&
16541653 ( expression . callee . property . name === "call" ||
16551654 expression . callee . property . name === "bind" ) &&
1656- expression . arguments &&
16571655 expression . arguments . length > 0
16581656 ) {
16591657 // (function(…) { }.call/bind(?, …))
1660- walkIIFE (
1658+ this . _walkIIFE (
16611659 expression . callee . object ,
16621660 expression . arguments . slice ( 1 ) ,
16631661 expression . arguments [ 0 ]
16641662 ) ;
1665- } else if (
1666- expression . callee . type === "FunctionExpression" &&
1667- expression . arguments
1668- ) {
1663+ } else if ( expression . callee . type === "FunctionExpression" ) {
16691664 // (function(…) { }(…))
1670- walkIIFE ( expression . callee , expression . arguments , null ) ;
1665+ this . _walkIIFE ( expression . callee , expression . arguments , null ) ;
16711666 } else if ( expression . callee . type === "Import" ) {
1672- result = this . hooks . importCall . call ( expression ) ;
1667+ let result = this . hooks . importCall . call ( expression ) ;
16731668 if ( result === true ) return ;
16741669
16751670 if ( expression . arguments ) this . walkExpressions ( expression . arguments ) ;
@@ -1678,14 +1673,14 @@ class Parser extends Tapable {
16781673 if ( callee . isIdentifier ( ) ) {
16791674 const callHook = this . hooks . call . get ( callee . identifier ) ;
16801675 if ( callHook !== undefined ) {
1681- result = callHook . call ( expression ) ;
1676+ let result = callHook . call ( expression ) ;
16821677 if ( result === true ) return ;
16831678 }
16841679 let identifier = callee . identifier . replace ( / \. [ ^ . ] + $ / , "" ) ;
16851680 if ( identifier !== callee . identifier ) {
16861681 const callAnyHook = this . hooks . callAnyMember . get ( identifier ) ;
16871682 if ( callAnyHook !== undefined ) {
1688- result = callAnyHook . call ( expression ) ;
1683+ let result = callAnyHook . call ( expression ) ;
16891684 if ( result === true ) return ;
16901685 }
16911686 }
0 commit comments