--- a/Method.st Sun Jul 11 08:16:49 2010 +0100
+++ b/Method.st Mon Jul 12 06:58:22 2010 +0100
@@ -358,15 +358,15 @@
!
annotations
-
- annotations ifNotNil:[^annotations].
-
- (self hasResource and:[annotations isNil])
- ifTrue:[self parseAnnotations].
-
+ "Returns annotations"
+
+ annotations ifNil:[^#()].
+ "iterate over annotation array to
+ trigger lazy-loading"
+ self annotationsDo:[:ignored].
^ annotations
- "Modified: / 10-07-2010 / 21:21:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-07-2010 / 19:25:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
annotations: anObject
@@ -383,12 +383,12 @@
annotationsDo: aBlock
- self annotations ifNil:[^nil].
+ annotations ifNil:[^nil].
1 to: annotations size do:
[:i|aBlock value: (self annotationAtIndex: i)].
"Created: / 02-07-2010 / 22:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-07-2010 / 21:22:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-07-2010 / 19:38:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
category
@@ -498,11 +498,10 @@
lookupObject: anObject
- bindObject := anObject.
- ObjectMemory flushCaches.
+ self setLookupObject: anObject.
"Created: / 28-04-2010 / 18:36:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 20-05-2010 / 11:35:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-07-2010 / 19:32:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
makeLocalStringSource
@@ -1764,14 +1763,21 @@
annotationAtIndex: index
- | annotation |
- self annotations.
+ "return annotation at given index.
+ any raw annotation array is lazily
+ initialized"
+
+ | annotation args |
annotations ifNil:[^nil].
annotation := annotations at: index.
- annotation isArray ifTrue:[
+ annotation isArray ifTrue:[
+ args := annotation size == 2
+ ifTrue:[annotation second]
+ ifFalse:[#()].
+ args isArray ifFalse:[args := Array with: args].
annotation := Annotation
key: annotation first
- arguments: annotation second.
+ arguments: args.
annotation isUnknown ifFalse:[
annotations at: index put: annotation.
annotation annotatesMethod: self
@@ -1780,13 +1786,16 @@
^annotation
"Created: / 02-07-2010 / 22:30:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-07-2010 / 21:23:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-07-2010 / 19:39:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
annotationIndexOf: key
- self annotations ifNil:[^nil].
-
+ "Returns index of annotation with given key
+ or nil if there is no such annotation"
+
+ annotations ifNil:[^nil].
+
annotations keysAndValuesDo:
[:index :annotationOrArray|
annotationOrArray isArray
@@ -1795,7 +1804,7 @@
^nil.
"Created: / 19-05-2010 / 16:40:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-07-2010 / 21:23:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-07-2010 / 19:23:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
cacheSourceStream:aStream
@@ -1815,6 +1824,14 @@
].
!
+getAnnotations
+
+ ^annotations
+
+ "Created: / 10-07-2010 / 21:55:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-07-2010 / 19:30:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
getLookupObject
^bindObject
@@ -2029,6 +2046,15 @@
"Modified: / 26-11-2006 / 22:33:38 / cg"
!
+setLookupObject: lookup
+ "set the lookupObject (low level - use lookupObject:)"
+
+ bindObject := lookup.
+ ObjectMemory flushCaches.
+
+ "Created: / 11-07-2010 / 19:31:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
sourceChunkFromStream:aStream
PositionError handle:[:ex |
^ nil
@@ -2174,6 +2200,25 @@
^ self literalsDetect:[:lit | lit isExternalLibraryFunction] ifNone:nil
!
+hasAnnotation
+
+ "Return true iff method has any annotation"
+
+ ^annotations notNil
+
+ "Created: / 11-07-2010 / 19:27:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hasAnnotation: key
+
+ "Return true iff method is annotated with
+ given key"
+
+ ^(self annotationIndexOf: key) notNil
+
+ "Created: / 11-07-2010 / 19:28:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
hasAnyResource:aCollectionOfSymbols
"return true if the method has a <resource> definition for any symbol in aCollectionOfSymbols"
@@ -3258,7 +3303,7 @@
!Method class methodsFor:'documentation'!
version
- ^ '$Id: Method.st 10541 2010-07-11 07:16:49Z vranyj1 $'
+ ^ '$Id: Method.st 10542 2010-07-12 05:58:22Z vranyj1 $'
!
version_CVS
@@ -3266,7 +3311,7 @@
!
version_SVN
- ^ '$Id: Method.st 10541 2010-07-11 07:16:49Z vranyj1 $'
+ ^ '$Id: Method.st 10542 2010-07-12 05:58:22Z vranyj1 $'
! !
Method initialize!