1438 1st argument to the methodDictionary. Flushes all caches." |
1439 1st argument to the methodDictionary. Flushes all caches." |
1439 |
1440 |
1440 |oldMethod ns nsName selector newLookupObject| |
1441 |oldMethod ns nsName selector newLookupObject| |
1441 |
1442 |
1442 (newSelector isMemberOf:Symbol) ifFalse:[ |
1443 (newSelector isMemberOf:Symbol) ifFalse:[ |
1443 self error:'invalid selector'. |
1444 self error:'invalid selector'. |
1444 ]. |
1445 ]. |
1445 |
1446 |
1446 ns := newMethod nameSpace. |
1447 ns := newMethod nameSpace. |
1447 (ns notNil and:[(nsName := ns name) ~= self programmingLanguage defaultSelectorNameSpacePrefix]) ifTrue:[ |
1448 (ns notNil and:[(nsName := ns name) ~= self programmingLanguage defaultSelectorNameSpacePrefix]) ifTrue:[ |
1448 selector := (':' , nsName , '::' , newSelector) asSymbol. |
1449 selector := (':' , nsName , '::' , newSelector) asSymbol. |
1449 newLookupObject := Smalltalk at: #NamespaceAwareLookup. "/ so it can be nilled to disable that feature |
1450 newLookupObject := Smalltalk at: #NamespaceAwareLookup. "/ so it can be nilled to disable that feature |
1450 ] ifFalse:[ |
1451 ] ifFalse:[ |
1451 selector := newSelector |
1452 selector := newSelector |
1452 ]. |
1453 ]. |
1453 |
1454 |
1454 "/ Q (cg): isn't that something that the caller should decide? |
1455 "/ Q (cg): isn't that something that the caller should decide? |
1455 oldMethod := self compiledMethodAt:selector. |
1456 oldMethod := self compiledMethodAt:selector. |
1456 oldMethod notNil ifTrue:[ |
1457 oldMethod notNil ifTrue:[ |
1457 newMethod restricted:(oldMethod isRestricted). |
1458 newMethod restricted:(oldMethod isRestricted). |
1458 newMethod setPrivacy:(oldMethod privacy) flushCaches:false. |
1459 newMethod setPrivacy:(oldMethod privacy) flushCaches:false. |
1459 ]. |
1460 ]. |
1460 |
1461 |
1461 (self primAddSelector:selector withMethod:newMethod) ifFalse:[^ false]. |
1462 (self primAddSelector:selector withMethod:newMethod) ifFalse:[^ false]. |
1462 |
1463 |
1463 newLookupObject notNil ifTrue:[ |
1464 newLookupObject notNil ifTrue:[ |
1464 lookupObject ~= newLookupObject ifTrue:[ |
1465 lookupObject ~= newLookupObject ifTrue:[ |
1465 self lookupObject: newLookupObject |
1466 self lookupObject: newLookupObject |
1466 ] |
1467 ] |
1467 ]. |
1468 ]. |
1468 |
1469 |
1469 " |
1470 " |
1470 if I have no subclasses, all we have to flush is cached |
1471 if I have no subclasses, all we have to flush is cached |
1471 data for myself ... (actually, in any case all that needs |
1472 data for myself ... (actually, in any case all that needs |
1472 to be flushed is info for myself and all of my subclasses) |
1473 to be flushed is info for myself and all of my subclasses) |
1473 " |
1474 " |
1474 " |
1475 " |
1475 problem: this is slower; since looking for all subclasses is (currently) |
1476 problem: this is slower; since looking for all subclasses is (currently) |
1476 a bit slow :-( |
1477 a bit slow :-( |
1477 We need the hasSubclasses-info bit in Behavior; now |
1478 We need the hasSubclasses-info bit in Behavior; now |
1478 |
1479 |
1479 self withAllSubclassesDo:[:aClass | |
1480 self withAllSubclassesDo:[:aClass | |
1480 ObjectMemory flushInlineCachesFor:aClass withArgs:nargs. |
1481 ObjectMemory flushInlineCachesFor:aClass withArgs:nargs. |
1481 ObjectMemory flushMethodCacheFor:aClass |
1482 ObjectMemory flushMethodCacheFor:aClass |
1482 ]. |
1483 ]. |
1483 " |
1484 " |
1484 |
1485 |
1485 "/ |
1486 "/ |
1486 "/ pass the selector AND the old method as changeArg |
1487 "/ pass the selector AND the old method as changeArg |
2522 a garbage collect. |
2523 a garbage collect. |
2523 This means, that the VM wanted to get some more memory from the |
2524 This means, that the VM wanted to get some more memory from the |
2524 Operatingsystem, which was not kind enough to give it. |
2525 Operatingsystem, which was not kind enough to give it. |
2525 Bad luck - you should increase the swap space on your machine. |
2526 Bad luck - you should increase the swap space on your machine. |
2526 " |
2527 " |
2527 ^ ObjectMemory allocationFailureSignal raise. |
2528 ^ AllocationFailure raise. |
2528 ! |
2529 ! |
2529 |
2530 |
2530 basicNew:anInteger |
2531 basicNew:anInteger |
2531 "return an instance of myself with anInteger indexed variables. |
2532 "return an instance of myself with anInteger indexed variables. |
2532 If the receiver-class has no indexed instvars, this is only allowed |
2533 If the receiver-class has no indexed instvars, this is only allowed |
2888 a garbage collect. |
2889 a garbage collect. |
2889 This means, that the VM wanted to get some more memory from the |
2890 This means, that the VM wanted to get some more memory from the |
2890 Operatingsystem, which was not kind enough to give it. |
2891 Operatingsystem, which was not kind enough to give it. |
2891 Bad luck - you should increase the swap space on your machine. |
2892 Bad luck - you should increase the swap space on your machine. |
2892 " |
2893 " |
2893 ^ ObjectMemory allocationFailureSignal raise. |
2894 ^ AllocationFailure raise. |
2894 ! |
2895 ! |
2895 |
2896 |
2896 decodeFromLiteralArray:anArray |
2897 decodeFromLiteralArray:anArray |
2897 "create & return a new instance from information encoded in anArray." |
2898 "create & return a new instance from information encoded in anArray." |
2898 |
2899 |
4781 "return true, if the receiver implements aSelector. |
4782 "return true, if the receiver implements aSelector. |
4782 (i.e. implemented in THIS class - NOT in a superclass). |
4783 (i.e. implemented in THIS class - NOT in a superclass). |
4783 This is semantically equivalent to includesSelector: (which is ST/80/Squeak compatibility). |
4784 This is semantically equivalent to includesSelector: (which is ST/80/Squeak compatibility). |
4784 |
4785 |
4785 Caveat: |
4786 Caveat: |
4786 This simply checks for the selector being present in the classes |
4787 This simply checks for the selector being present in the classes |
4787 selector table - therefore, it does not care for ignoredMethods. |
4788 selector table - therefore, it does not care for ignoredMethods. |
4788 (but: you should not use this method for protocol-testing, anyway). |
4789 (but: you should not use this method for protocol-testing, anyway). |
4789 |
4790 |
4790 Hint: |
4791 Hint: |
4791 Dont use this method to check if someone responds to a message - |
4792 Don't use this method to check if someone responds to a message - |
4792 use #canUnderstand: on the class or #respondsTo: on the instance |
4793 use #canUnderstand: on the class or #respondsTo: on the instance |
4793 to do this." |
4794 to do this." |
4794 |
4795 |
4795 ^ self includesSelector:aSelector |
4796 ^ self includesSelector:aSelector |
4796 |
4797 |
4797 " |
4798 " |
4798 notice: this is class protocol |
4799 notice: this is class protocol |