[squeak-dev] The Trunk: Kernel-cmm.612.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Aug 16 02:50:31 UTC 2011
Chris Muller uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-cmm.612.mcz
==================== Summary ====================
Name: Kernel-cmm.612
Author: cmm
Time: 15 August 2011, 9:21:36.435 pm
UUID: 4d1d5cde-63c0-4b82-ba0c-912fc1b880bd
Ancestors: Kernel-cmm.608, Kernel-ul.611
Merged cmm.607 and cmm.608.
=============== Diff against Kernel-cmm.608 ===============
Item was removed:
- ----- Method: Behavior>>allLocalCallsOn: (in category 'user interface') -----
- allLocalCallsOn: aSymbol
- "Answer a SortedCollection of all the methods that call on aSymbol, anywhere in my class hierarchy."
-
- | aSet special byte cls |
- aSet := Set new.
- cls := self theNonMetaClass.
- special := Smalltalk hasSpecialSelector: aSymbol
- ifTrueSetByte: [:b | byte := b ].
- cls withAllSuperAndSubclassesDoGently: [ :class |
- (class whichSelectorsReferTo: aSymbol special: special byte: byte)
- do: [:sel |
- sel isDoIt ifFalse: [aSet add: class name , ' ', sel]]].
- cls class withAllSuperAndSubclassesDoGently: [ :class |
- (class whichSelectorsReferTo: aSymbol special: special byte: byte)
- do: [:sel |
- sel isDoIt ifFalse: [aSet add: class name , ' ', sel]]].
- ^aSet!
Item was changed:
----- Method: Behavior>>compiledMethodAt:ifAbsent: (in category 'accessing method dictionary') -----
compiledMethodAt: selector ifAbsent: aBlock
"Answer the compiled method associated with the argument, selector (a Symbol), a message selector in the receiver's method dictionary. If the selector is not in the dictionary, return the value of aBlock"
+ ^ self methodDict at: selector ifAbsent: aBlock!
- ^ self methodDict at: selector ifAbsent: [aBlock value]!
Item was changed:
----- Method: BlockClosure>>on:do:on:do: (in category 'exceptions') -----
on: exc1 do: block1 on: exc2 do: block2
^[
+ self
- [ self value ]
on: exc1
do: block1 ]
-
on: exc2
do: block2!
Item was changed:
----- Method: BlockClosure>>on:do:on:do:on:do: (in category 'exceptions') -----
on: exc1 do: block1 on: exc2 do: block2 on: exc3 do: block3
^[
+ self
- [ self value ]
on: exc1
do: block1 ]
-
on: exc2
do: block2
-
on: exc3
do: block3!
Item was changed:
----- Method: BlockClosure>>valueSupplyingAnswers: (in category 'evaluating') -----
valueSupplyingAnswers: aListOfPairs
"evaluate the block using a list of questions / answers that might be called upon to
automatically respond to Object>>confirm: or FillInTheBlank requests"
+ ^self
- ^ [self value]
on: ProvideAnswerNotification
+ do: [ :notification |
+ | caption |
+ caption := notification messageText withSeparatorsCompacted. "to remove new lines"
+ aListOfPairs
+ detect: [ :each |
+ caption = each first
+ or: [ (caption includesSubstring: each first caseSensitive: false)
+ or: [ each first match: caption ] ] ]
+ ifFound: [ :answer | notification resume: answer second ]
+ ifNone: [
+ (ProvideAnswerNotification signal: notification messageText)
+ ifNil: [ notification resume ]
+ ifNotNil: [ :outerAnswer | notification resume: outerAnswer ] ] ]!
- do:
- [:notify | | answer caption |
-
- caption := notify messageText withSeparatorsCompacted. "to remove new lines"
- answer := aListOfPairs
- detect:
- [:each | caption = each first
- or: [(caption includesSubstring: each first caseSensitive: false)
- or: [each first match: caption]]]
- ifNone: [nil].
- answer
- ifNotNil: [notify resume: answer second]
- ifNil:
- [ | outerAnswer |
- outerAnswer := ProvideAnswerNotification signal: notify messageText.
- outerAnswer
- ifNil: [notify resume]
- ifNotNil: [notify resume: outerAnswer]]]!
Item was changed:
----- Method: BlockContext>>on:do:on:do: (in category 'exceptions') -----
on: exc1 do: block1 on: exc2 do: block2
^[
+ self
- [ self value ]
on: exc1
do: block1 ]
-
on: exc2
do: block2!
Item was changed:
----- Method: BlockContext>>on:do:on:do:on:do: (in category 'exceptions') -----
on: exc1 do: block1 on: exc2 do: block2 on: exc3 do: block3
^[
+ self
- [ self value ]
on: exc1
do: block1 ]
-
on: exc2
do: block2
-
on: exc3
do: block3!
Item was changed:
----- Method: BlockContext>>valueSupplyingAnswers: (in category 'evaluating') -----
valueSupplyingAnswers: aListOfPairs
"evaluate the block using a list of questions / answers that might be called upon to
automatically respond to Object>>confirm: or FillInTheBlank requests"
+ ^self
- ^ [self value]
on: ProvideAnswerNotification
do:
[:notify | | answer caption |
caption := notify messageText withSeparatorsCompacted. "to remove new lines"
answer := aListOfPairs
detect:
[:each | caption = each first
or: [(caption includesSubstring: each first caseSensitive: false)
or: [each first match: caption]]]
ifNone: [nil].
answer
ifNotNil: [notify resume: answer second]
ifNil:
[ | outerAnswer |
outerAnswer := ProvideAnswerNotification signal: notify messageText.
outerAnswer
ifNil: [notify resume]
ifNotNil: [notify resume: outerAnswer]]]!
Item was changed:
----- Method: CompiledMethod>>hasLiteral: (in category 'literals') -----
hasLiteral: literal
"Answer whether the receiver references the argument, literal."
+ 2 to: self numLiterals - 1 do: "exclude superclass + selector/properties"
+ [:index |
+ ((self objectAt: index) literalEqual: literal) ifTrue: [^true]].
- 2 to: self numLiterals - 1 "exclude superclass + selector/properties"
- do:[:index |
- literal == (self objectAt: index) ifTrue: [^true]].
^false!
Item was changed:
----- Method: CompiledMethod>>hasLiteralThorough: (in category 'literals') -----
hasLiteralThorough: literal
"Answer true if any literal in this method is literal,
even if embedded in array structure."
(self penultimateLiteral isMethodProperties
and: [self penultimateLiteral hasLiteralThorough: literal]) ifTrue:[^true].
2 to: self numLiterals - 1 "exclude superclass + selector/properties"
do:[:index | | lit |
+ (((lit := self objectAt: index) literalEqual: literal)
- ((lit := self objectAt: index) == literal
or: [(lit isVariableBinding and: [lit key == literal])
or: [lit isArray and: [lit hasLiteral: literal]]]) ifTrue:
[^ true]].
^ false !
Item was removed:
- ----- Method: CompiledMethod>>hasLiteralThorough:from: (in category 'literals') -----
- hasLiteralThorough: aLiteral from: aBlock
- "Answer true if any literal in this method is literal, even if embedded in array structure or within its pragmas."
-
- | literal |
- self pragmas do: [ :pragma |
- (pragma hasLiteral: aLiteral) ifTrue: [ ^ true ] ].
- 2 to: self numLiterals + 1 do: [ :index |
- literal := self objectAt: index.
- literal == aLiteral ifTrue: [ ^ true ].
- literal == aBlock ifFalse:[ (literal hasLiteralThorough: aLiteral) ifTrue: [ ^ true ]] ].
- ^ false.!
Item was changed:
Number subclass: #Integer
instanceVariableNames: ''
+ classVariableNames: 'LowBitPerByteTable'
- classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Numbers'!
!Integer commentStamp: '<historical>' prior: 0!
I am a common abstract superclass for all Integer implementations. My implementation subclasses are SmallInteger, LargePositiveInteger, and LargeNegativeInteger.
Integer division consists of:
/ exact division, answers a fraction if result is not a whole integer
// answers an Integer, rounded towards negative infinity
\\ is modulo rounded towards negative infinity
quo: truncated division, rounded towards zero!
Item was changed:
----- Method: Integer class>>initialize (in category 'class initialization') -----
initialize "Integer initialize"
"Ensure we have the right compact class index"
"LPI has been a compact class forever - just ensure basic correctness"
(LargePositiveInteger indexIfCompact = 5) ifFalse:[
(Smalltalk compactClassesArray at: 5)
ifNil:[LargePositiveInteger becomeCompactSimplyAt: 5]
ifNotNil:[self error: 'Unexpected compact class setup']].
"Cog requires LNI to be compact at 4 (replacing PseudoContext)"
(LargeNegativeInteger indexIfCompact = 4) ifFalse:[
"PseudoContext will likely get removed at some point so write this test
without introducing a hard dependency"
(Smalltalk compactClassesArray at: 4) name == #PseudoContext
ifTrue:[Smalltalk compactClassesArray at: 4 put: nil].
(Smalltalk compactClassesArray at: 4)
ifNil:[LargeNegativeInteger becomeCompactSimplyAt: 4]
ifNotNil:[self error: 'Unexpected compact class setup']].
+
+ self initializeLowBitPerByteTable
!
Item was added:
+ ----- Method: Integer class>>initializeLowBitPerByteTable (in category 'class initialization') -----
+ initializeLowBitPerByteTable
+ "Initialize LowBitPerByteTable which is a ByteArray that contains the index of the lowest set bit of the integers between 1 and 255. It's defined as a class variable because it's used from the instance side and subclasses."
+ "The low bits table can be obtained with:
+ ((1 to: 8) inject: #[1] into: [:lowBits :rank | (lowBits copy at: 1 put: lowBits first + 1; yourself) , lowBits]) allButFirst
+ or with it's symmetric pair:
+ ((1 to: 8) inject: #[1] into: [:lowBits :rank | lowBits, (lowBits copy atLast: 1 put: lowBits last + 1; yourself)]) allButLast."
+
+ LowBitPerByteTable := #[1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1]!
Item was changed:
----- Method: Integer>>lowBit (in category 'bit manipulation') -----
lowBit
"Answer the index of the low order bit of this number."
+
+ | index digit |
+ index := 0.
+ [ (digit := self digitAt: (index := index + 1)) = 0 ] whileTrue.
+ ^(LowBitPerByteTable at: digit) + (index - 1 * 8)!
- | index |
- self = 0 ifTrue: [ ^ 0 ].
- index := 1.
- [ (self digitAt: index) = 0 ]
- whileTrue:
- [ index := index + 1 ].
- ^ (self digitAt: index) lowBit + (8 * (index - 1))!
Item was removed:
- ----- Method: Object>>hasLiteralThorough: (in category 'testing') -----
- hasLiteralThorough: literal
- "Answer true if literal is identical to any literal in this array, even if imbedded in further structures. This is the end of the imbedded structure path so return false."
-
- ^ false!
Item was changed:
----- Method: Object>>removeActionsSatisfying:forEvent: (in category 'events-removing') -----
removeActionsSatisfying: aOneArgBlock
forEvent: anEventSelector
self
setActionSequence:
((self actionSequenceForEvent: anEventSelector)
+ reject: aOneArgBlock)
- reject: [:anAction | aOneArgBlock value: anAction])
forEvent: anEventSelector!
Item was changed:
----- Method: SmallInteger>>lowBit (in category 'bit manipulation') -----
lowBit
" Answer the index of the low order one bit.
2r00101000 lowBit (Answers: 4)
2r-00101000 lowBit (Answers: 4)
First we skip bits in groups of 8, then do a lookup in a table.
While not optimal, this is a good tradeoff; long
integer #lowBit always invokes us with bytes."
+
| n result lastByte |
n := self.
n = 0 ifTrue: [ ^ 0 ].
result := 0.
[(lastByte := n bitAnd: 16rFF) = 0]
whileTrue: [
result := result + 8.
n := n bitShift: -8 ].
+ ^result + (LowBitPerByteTable at: lastByte)!
-
- "The low bits table can be obtained with:
- ((1 to: 8) inject: #[1] into: [:lowBits :rank | (lowBits copy at: 1 put: lowBits first + 1; yourself) , lowBits]) allButFirst."
- ^result + ( #[1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1] at: lastByte)!
Item was changed:
----- Method: WeakMessageSend>>valueOtherwise: (in category 'evaluating') -----
valueOtherwise: aBlock
+
^ arguments
ifNil: [
+ self withEnsuredReceiverDo: [ :r | r perform: selector ] otherwise: aBlock ]
- self withEnsuredReceiverDo: [ :r | r perform: selector ] otherwise: [ aBlock value ]]
ifNotNil: [
self
withEnsuredReceiverAndArgumentsDo: [ :r :a |
r
perform: selector
withArguments: a ]
+ otherwise: aBlock ]!
- otherwise: [ aBlock value ]]!
Item was changed:
----- Method: WeakMessageSend>>valueWithArguments:otherwise: (in category 'evaluating') -----
valueWithArguments: anArray otherwise: aBlock
| argsToUse |
"Safe to use, because they are built before ensureing receiver and args..."
argsToUse := self collectArguments: anArray.
^ self
withEnsuredReceiverAndArgumentsDo: [ :r :a |
r
perform: selector
withArguments: argsToUse ]
+ otherwise: aBlock!
- otherwise: [ aBlock value ]!
More information about the Squeak-dev
mailing list
|