Method.st
changeset 14237 2e7bbfbda700
parent 14236 d383e9f70795
child 14251 c0d549a59039
--- a/Method.st	Mon Jul 23 11:07:18 2012 +0200
+++ b/Method.st	Mon Jul 23 11:17:47 2012 +0200
@@ -2311,6 +2311,31 @@
     "Modified: 19.6.1997 / 17:54:09 / cg"
 !
 
+accessesField:instVarIndex
+    "return true, if the instvar at instVarIndex is accessed by the receiver.
+     Uses parser (for now); could look at bytecode as well here..."
+
+    |instVarName|
+
+    instVarName := (self mclass allInstVarNames) at:instVarIndex.
+    ^ self accessesInstVar:instVarName
+
+    "Created: / 23-07-2012 / 11:13:54 / cg"
+!
+
+accessesInstVar:instVarName
+    "return true, if the named instvar is accessed by the receiver.
+     Uses parser (for now); could look at bytecode as well here..."
+
+    |usedInstVars|
+
+    (self source includesString:instVarName) ifFalse:[^ false].     "/ that's much faster than parsing...
+    usedInstVars := self parse:#'parseMethodSilent:in:' with:self mclass  return:#usedInstVars or:#().
+    ^ usedInstVars includes:instVarName.
+
+    "Created: / 23-07-2012 / 11:15:02 / cg"
+!
+
 containingClass
     "return the class I am defined in.
      See comment in who."
@@ -3062,11 +3087,25 @@
     "return true, if the instvar at instVarIndex is read by the receiver.
      Uses parser (for now); could look at bytecode as well here..."
 
-    |varName readInstVars|
-
-    varName := (self mclass allInstVarNames) at:instVarIndex.
+    |instVarName|
+
+    instVarName := (self mclass allInstVarNames) at:instVarIndex.
+    ^ self readsInstVar:instVarName
+
+    "Modified: / 23-07-2012 / 11:16:08 / cg"
+!
+
+readsInstVar:instVarName
+    "return true, if the named instvar is read by the receiver.
+     Uses parser (for now); could look at bytecode as well here..."
+
+    |readInstVars|
+
+    (self source includesString:instVarName) ifFalse:[^ false].     "/ that's much faster than parsing...
     readInstVars := self parse:#'parseMethodSilent:in:' with:self mclass  return:#readInstVars or:#().
-    ^ readInstVars includes:varName.
+    ^ readInstVars includes:instVarName.
+
+    "Created: / 23-07-2012 / 11:15:56 / cg"
 !
 
 resourceType
@@ -3369,11 +3408,25 @@
     "return true, if the instvar at instVarIndex is written (modified) by the receiver.
      Uses parser (for now); could look at bytecode as well here..."
 
-    |varName modifiedInstVars|
-
-    varName := (self mclass allInstVarNames) at:instVarIndex.
+    |instVarName|
+
+    instVarName := (self mclass allInstVarNames) at:instVarIndex.
+    ^ self writesInstVar:instVarName
+
+    "Modified: / 23-07-2012 / 11:16:51 / cg"
+!
+
+writesInstVar:instVarName
+    "return true, if the named instvar is written (modified) by the receiver.
+     Uses parser (for now); could look at bytecode as well here..."
+
+    |modifiedInstVars|
+
+    (self source includesString:instVarName) ifFalse:[^ false].     "/ that's much faster than parsing...
     modifiedInstVars := self parse:#'parseMethodSilent:in:' with:self mclass return:#modifiedInstVars or:#().
-    ^ modifiedInstVars includes:varName.
+    ^ modifiedInstVars includes:instVarName.
+
+    "Created: / 23-07-2012 / 11:16:36 / cg"
 ! !
 
 !Method methodsFor:'trap methods'!
@@ -3612,11 +3665,11 @@
 !Method class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.387 2012-07-23 09:07:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.388 2012-07-23 09:17:47 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.387 2012-07-23 09:07:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.388 2012-07-23 09:17:47 cg Exp $'
 !
 
 version_SVN