@@ -1609,67 +1609,62 @@ class Parser extends Tapable {
1609
1609
this . walkClass ( expression ) ;
1610
1610
}
1611
1611
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 ;
1636
1621
}
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 ) ;
1649
1624
} ;
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 ) {
1650
1649
if (
1651
1650
expression . callee . type === "MemberExpression" &&
1652
1651
expression . callee . object . type === "FunctionExpression" &&
1653
1652
! expression . callee . computed &&
1654
1653
( expression . callee . property . name === "call" ||
1655
1654
expression . callee . property . name === "bind" ) &&
1656
- expression . arguments &&
1657
1655
expression . arguments . length > 0
1658
1656
) {
1659
1657
// (function(…) { }.call/bind(?, …))
1660
- walkIIFE (
1658
+ this . _walkIIFE (
1661
1659
expression . callee . object ,
1662
1660
expression . arguments . slice ( 1 ) ,
1663
1661
expression . arguments [ 0 ]
1664
1662
) ;
1665
- } else if (
1666
- expression . callee . type === "FunctionExpression" &&
1667
- expression . arguments
1668
- ) {
1663
+ } else if ( expression . callee . type === "FunctionExpression" ) {
1669
1664
// (function(…) { }(…))
1670
- walkIIFE ( expression . callee , expression . arguments , null ) ;
1665
+ this . _walkIIFE ( expression . callee , expression . arguments , null ) ;
1671
1666
} else if ( expression . callee . type === "Import" ) {
1672
- result = this . hooks . importCall . call ( expression ) ;
1667
+ let result = this . hooks . importCall . call ( expression ) ;
1673
1668
if ( result === true ) return ;
1674
1669
1675
1670
if ( expression . arguments ) this . walkExpressions ( expression . arguments ) ;
@@ -1678,14 +1673,14 @@ class Parser extends Tapable {
1678
1673
if ( callee . isIdentifier ( ) ) {
1679
1674
const callHook = this . hooks . call . get ( callee . identifier ) ;
1680
1675
if ( callHook !== undefined ) {
1681
- result = callHook . call ( expression ) ;
1676
+ let result = callHook . call ( expression ) ;
1682
1677
if ( result === true ) return ;
1683
1678
}
1684
1679
let identifier = callee . identifier . replace ( / \. [ ^ . ] + $ / , "" ) ;
1685
1680
if ( identifier !== callee . identifier ) {
1686
1681
const callAnyHook = this . hooks . callAnyMember . get ( identifier ) ;
1687
1682
if ( callAnyHook !== undefined ) {
1688
- result = callAnyHook . call ( expression ) ;
1683
+ let result = callAnyHook . call ( expression ) ;
1689
1684
if ( result === true ) return ;
1690
1685
}
1691
1686
}
0 commit comments