JavaMethod.st
changeset 625 b0d1764545b5
parent 618 1ef28aa96092
child 637 d2e91e3e97c5
equal deleted inserted replaced
624:35975d55bbb5 625:b0d1764545b5
  1478      added to allow browsing"
  1478      added to allow browsing"
  1479 
  1479 
  1480     ^ false.
  1480     ^ false.
  1481 
  1481 
  1482     "Created: 30.7.1997 / 15:34:33 / cg"
  1482     "Created: 30.7.1997 / 15:34:33 / cg"
       
  1483 !
       
  1484 
       
  1485 isJavaClassRef
       
  1486     ^ false
       
  1487 
       
  1488     "Created: / 9.11.1999 / 17:16:20 / cg"
  1483 !
  1489 !
  1484 
  1490 
  1485 isJavaMethod
  1491 isJavaMethod
  1486     ^ true
  1492     ^ true
  1487 
  1493 
  1606 
  1612 
  1607     "Modified: / 14.1.1998 / 13:30:54 / cg"
  1613     "Modified: / 14.1.1998 / 13:30:54 / cg"
  1608     "Created: / 10.11.1998 / 14:18:22 / cg"
  1614     "Created: / 10.11.1998 / 14:18:22 / cg"
  1609 !
  1615 !
  1610 
  1616 
       
  1617 referencesGlobal:aGlobalName
       
  1618     "return true, if this method refers to a global named aGlobalName"
       
  1619 
       
  1620     |walker any|
       
  1621 
       
  1622     "/ quick check, if constantPool includes a methodRef for this
       
  1623     "/ selector.
       
  1624 
       
  1625     any := false.
       
  1626     self javaClass constantPool do:[:const |
       
  1627         (const isNumber 
       
  1628         or:[const isString
       
  1629         or:[const isNil]]) ifFalse:[
       
  1630             const isJavaClass ifTrue:[
       
  1631                 any := any or:[const fullName = aGlobalName].
       
  1632             ] ifFalse:[
       
  1633                 const isJavaClassRef ifTrue:[
       
  1634                     any := any or:[const fullName = aGlobalName].
       
  1635                 ]
       
  1636             ].
       
  1637         ].
       
  1638     ].
       
  1639     any ifFalse:[^ false].
       
  1640 
       
  1641     "/ sigh - must extract all accessed literals ...
       
  1642     "/ must deparse the byteCode in order to do this.
       
  1643 
       
  1644     walker := JavaByteCodeEnumerator new.
       
  1645     walker 
       
  1646         literalAction:
       
  1647             [:pc :slotIndex :const |
       
  1648                 |mSel|
       
  1649 
       
  1650                 (const isNumber 
       
  1651                 or:[const isString
       
  1652                 or:[const isNil]]) ifFalse:[
       
  1653                     const isJavaClass ifTrue:[
       
  1654                         mSel := const fullName.
       
  1655                     ] ifFalse:[
       
  1656                         const isJavaClassRef ifTrue:[
       
  1657                             mSel := const fullName.
       
  1658                         ]
       
  1659                     ].
       
  1660                 ].
       
  1661                 mSel notNil ifTrue:[
       
  1662                     "/ Transcript showCR:mSel.
       
  1663                     mSel = aGlobalName ifTrue:[
       
  1664                         ^ true
       
  1665                     ]
       
  1666                 ].
       
  1667             ].
       
  1668     walker decompile:self to:nil.
       
  1669 
       
  1670     "Created: / 9.11.1999 / 17:15:46 / cg"
       
  1671     "Modified: / 9.11.1999 / 17:18:02 / cg"
       
  1672 !
       
  1673 
  1611 sends:aSelectorSymbol
  1674 sends:aSelectorSymbol
  1612     "return true, if this method contains a message-send
  1675     "return true, if this method contains a message-send
  1613      with aSelectorSymbol as selector."
  1676      with aSelectorSymbol as selector."
  1614 
       
  1615     "/ sigh - must first extract all accessed literals ...
       
  1616     "/ must deparse the byteCode in order to do this.
       
  1617 
  1677 
  1618     |walker any|
  1678     |walker any|
  1619 
  1679 
  1620     "/ quick check, if constantPool includes a methodRef for this
  1680     "/ quick check, if constantPool includes a methodRef for this
  1621     "/ selector.
  1681     "/ selector.
  1633                 ]
  1693                 ]
  1634             ].
  1694             ].
  1635         ].
  1695         ].
  1636     ].
  1696     ].
  1637     any ifFalse:[^ false].
  1697     any ifFalse:[^ false].
       
  1698 
       
  1699     "/ sigh - must extract all accessed literals ...
       
  1700     "/ must deparse the byteCode in order to do this.
  1638 
  1701 
  1639     walker := JavaByteCodeEnumerator new.
  1702     walker := JavaByteCodeEnumerator new.
  1640     walker 
  1703     walker 
  1641         literalAction:
  1704         literalAction:
  1642             [:pc :slotIndex :const |
  1705             [:pc :slotIndex :const |
  1661                 ].
  1724                 ].
  1662             ].
  1725             ].
  1663     walker decompile:self to:nil.
  1726     walker decompile:self to:nil.
  1664 
  1727 
  1665     "Created: / 9.11.1999 / 15:38:14 / cg"
  1728     "Created: / 9.11.1999 / 15:38:14 / cg"
  1666     "Modified: / 9.11.1999 / 15:50:50 / cg"
  1729     "Modified: / 9.11.1999 / 17:06:03 / cg"
  1667 !
  1730 !
  1668 
  1731 
  1669 who
  1732 who
  1670     "return the class and selector of where I am defined in."
  1733     "return the class and selector of where I am defined in."
  1671 
  1734 
  1707 ! !
  1770 ! !
  1708 
  1771 
  1709 !JavaMethod class methodsFor:'documentation'!
  1772 !JavaMethod class methodsFor:'documentation'!
  1710 
  1773 
  1711 version
  1774 version
  1712     ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.89 1999/11/09 14:54:16 cg Exp $'
  1775     ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.90 1999/11/09 16:58:38 cg Exp $'
  1713 ! !
  1776 ! !
  1714 JavaMethod initialize!
  1777 JavaMethod initialize!