--- a/JavaMethodAnalyzer.st Mon Sep 02 09:59:56 2013 +0100
+++ b/JavaMethodAnalyzer.st Mon Sep 02 10:08:10 2013 +0100
@@ -98,9 +98,11 @@
!
invinterface
- methodsInvoked add: (constantPool at: self fetchBytes4)
+ methodsInvoked add: (constantPool at: self fetchBytes2).
+ self fetchBytes2 "/ count
"Created: / 30-08-2013 / 17:05:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-08-2013 / 20:28:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
invnonvirt
@@ -145,13 +147,54 @@
"Modified: / 30-08-2013 / 17:01:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!JavaMethodAnalyzer methodsFor:'queries'!
+
+sends: selector
+ ^ self sendsAny: (Array with: selector)
+
+ "Created: / 31-08-2013 / 11:38:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+sends:selector1 or:selector2
+ ^ self sendsAny: (Array with: selector1 with: selector2)
+
+ "Modified: / 31-08-2013 / 11:39:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+sendsAny: selectors
+ selectors do:[:pair|
+ methodsInvoked do:[:methodRef |
+ methodRef selector = pair first ifTrue:[
+ ^ true
+ ]
+ ]
+ ].
+ ^ false
+
+ "Created: / 02-12-2011 / 23:05:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 31-08-2013 / 21:33:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!JavaMethodAnalyzer methodsFor:'queries-statistic'!
messagesPossiblySent
- ^ methodsInvoked collect:[:methodRef | methodRef selector ]
+ ^ #()
"Created: / 30-08-2013 / 14:05:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 30-08-2013 / 17:11:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 31-08-2013 / 10:44:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+messagesSent
+ ^ methodsInvoked collect:[:methodRef |methodRef selector ]
+
+ "Created: / 31-08-2013 / 10:44:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 31-08-2013 / 21:32:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+messagesSentToSelf
+ ^#()
+
+ "Created: / 31-08-2013 / 09:31:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
messagesSentToSuper
@@ -173,18 +216,6 @@
"Modified: / 30-08-2013 / 17:02:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-sends:symbol1 or:symbol2
-
- ^false
-!
-
-sendsAny: selectors
-
- ^false
-
- "Created: / 02-12-2011 / 23:05:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
usedClassVars
^ #() "/ No class vars in Java
@@ -198,3 +229,19 @@
"Modified: / 30-08-2013 / 17:02:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!JavaMethodAnalyzer methodsFor:'queries-statistic-Java'!
+
+methodsInvoked
+ "Return a set of method invoked by the analyzed
+ method.
+
+ Unlike #messagesSent, which return only
+ selectors, this method returns a list of method refs,
+ so the receivers' declared class is also accessible
+ (through ref classRef)"
+
+ ^ methodsInvoked
+
+ "Created: / 31-08-2013 / 23:22:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+