Behavior.st
branchjv
changeset 17993 956342c369a2
parent 17976 50c2416f962a
child 18011 deb0c3355881
--- a/Behavior.st	Wed Nov 28 10:22:05 2012 +0000
+++ b/Behavior.st	Fri Nov 30 17:19:23 2012 +0000
@@ -1192,25 +1192,29 @@
     |oldMethod ns selector |
 
     (newSelector isMemberOf:Symbol) ifFalse:[
-	self error:'invalid selector'.
+        self error:'invalid selector'.
     ].
 
     ns := newMethod nameSpace.
     selector := (ns isNil or:[ns == self programmingLanguage])
-		    ifTrue:[newSelector]
-		    ifFalse:[(':' , ns name , '::' , newSelector) asSymbol].
-
-
+                    ifTrue:[newSelector]
+                    ifFalse:[(':' , ns name , '::' , newSelector) asSymbol].
+
+    "/ Q (cg): isn't that something that the caller should decide?
     oldMethod := self compiledMethodAt:selector.
     oldMethod notNil ifTrue:[
-	newMethod restricted:(oldMethod isRestricted).
-	newMethod setPrivacy:(oldMethod privacy) flushCaches:false.
+        newMethod restricted:(oldMethod isRestricted).
+        newMethod setPrivacy:(oldMethod privacy) flushCaches:false.
     ].
 
     (self primAddSelector:selector withMethod:newMethod) ifFalse:[^ false].
 
-    selector isNameSpaceSelector ifTrue:[
-	self lookupObject: NamespaceAwareLookup
+    (Smalltalk at: #NamespaceAwareLookup) notNil ifTrue:[
+        lookupObject ~= NamespaceAwareLookup ifTrue:[
+            selector isNameSpaceSelector ifTrue:[
+                self lookupObject: NamespaceAwareLookup
+            ]
+        ]
     ].
 
     "
@@ -1220,12 +1224,12 @@
     "
 "
     problem: this is slower; since looking for all subclasses is (currently)
-	     a bit slow :-(
-	     We need the hasSubclasses-info bit in Behavior; now
+             a bit slow :-(
+             We need the hasSubclasses-info bit in Behavior; now
 
     self withAllSubclassesDo:[:aClass |
-	ObjectMemory flushInlineCachesFor:aClass withArgs:nargs.
-	ObjectMemory flushMethodCacheFor:aClass
+        ObjectMemory flushInlineCachesFor:aClass withArgs:nargs.
+        ObjectMemory flushMethodCacheFor:aClass
     ].
 "
 
@@ -1335,6 +1339,7 @@
 !
 
 lookupObject: anObject
+    lookupObject == anObject ifTrue:[^ self ].
     anObject isNil ifTrue:[^self setLookupObject: anObject].
 
     (anObject respondsTo: #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:)
@@ -1924,6 +1929,16 @@
     "
 ! !
 
+!Behavior methodsFor:'error handling'!
+
+abstractClassInstantiationError
+    "sent by an abstract classes redefined new method"
+
+    ^ AbstractClassInstantiationError raiseRequest
+
+    "Created: / 02-11-2012 / 10:07:01 / cg"
+! !
+
 !Behavior methodsFor:'initialization'!
 
 deinitialize
@@ -2784,17 +2799,19 @@
     "can be redefined for a private icon in the browser (for me and my subclasses).
      The returned symbol must be a selector of the ToolbarIconLibrary."
 
-    (self isBrowserStartable) ifTrue:[
-	self isVisualStartable ifTrue:[
-	    ^ #visualStartableClassBrowserIcon
-	].
-	^ #startableClassBrowserIcon
+    <resource: #programImage>
+
+    self isLoaded ifFalse:[
+        ^ #autoloadedClassBrowserIcon
     ].
-    self isLoaded ifFalse:[
-	^ #autoloadedClassBrowserIcon
+    (self isBrowserStartable) ifTrue:[
+        self isVisualStartable ifTrue:[
+            ^ #visualStartableClassBrowserIcon
+        ].
+        ^ #startableClassBrowserIcon
     ].
 
-    "/ give ruby and other special metaclasses a chance ot provide their orn icon...
+    "/ give ruby and other special metaclasses a chance to provide their own icon...
     ^ self class iconInBrowserSymbol
 
     "Created: / 20-07-2007 / 08:52:17 / cg"
@@ -3035,9 +3052,11 @@
      If non-nil, no lookup is performed by the VM, instead the lookupObject
      has to provide a method object for message sends."
 
-    lookupObject := aMethodLookupObject.
-    ObjectMemory flushCachesFor: self.
-    self allSubclassesDo:[:cls|ObjectMemory flushCachesFor: cls]
+    lookupObject ~~ aMethodLookupObject ifTrue:[
+        lookupObject := aMethodLookupObject.
+        ObjectMemory flushCachesFor: self.
+        self allSubclassesDo:[:cls|ObjectMemory flushCachesFor: cls]
+    ]
 
     "Modified: / 22-07-2010 / 18:10:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
@@ -3150,6 +3169,10 @@
     "Created: / 06-08-2006 / 15:23:32 / cg"
 !
 
+isAbstract
+    ^ false
+!
+
 isBehavior
     "return true, if the receiver is describing another objects behavior.
      Defined to avoid the need to use isKindOf:"
@@ -4803,13 +4826,13 @@
 !Behavior class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.324 2012/10/22 11:38:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.327 2012/11/25 09:52:30 cg Exp $'
 !
 
 version_CVS
-    ^ '§Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.324 2012/10/22 11:38:58 cg Exp §'
+    ^ 'Header: /cvs/stx/stx/libbasic/Behavior.st,v 1.327 2012/11/25 09:52:30 cg Exp '
 !
 
 version_SVN
-    ^ '$Id: Behavior.st 10858 2012-10-29 22:07:56Z vranyj1 $'
+    ^ '$Id: Behavior.st 10876 2012-11-30 17:19:23Z vranyj1 $'
 ! !