Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.436.mcz
==================== Summary ====================
Name: Collections-ul.436
Author: ul
Time: 1 April 2011, 9:25:17.967 pm
UUID: f684fc31-c114-bf41-aecb-98f347ccb43e
Ancestors: Collections-nice.435
Improved #beginsWith: and #endsWith: implementations.
=============== Diff against Collections-nice.435 ===============
Item was changed:
+ ----- Method: ByteString>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer whether the receiver begins with the given sequence. The comparison is case-sensitive. Overridden for better performance."
- ----- Method: ByteString>>beginsWith: (in category 'comparing') -----
- beginsWith: prefix
- "Answer whether the receiver begins with the given prefix string.
- The comparison is case-sensitive."
+ | sequenceSize |
+ sequence class isBytes ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
+ "The following method uses a suboptimal algorithm (brute force pattern matching with O(n^2) worst case runtime), but the primitive in C is so fast (assuming large alphabets), that it's still worth using it instead of linear time pure smalltalk implementation. There are some obvious cases when the brute force algorithm is suboptimal, e.g. when the first elements don't match, so let's compare them here before using the primitive."
+ (self basicAt: 1) = (sequence basicAt: 1) ifFalse: [ ^false ].
+ ^(self findSubstring: sequence in: self startingAt: 1 matchTable: CaseSensitiveOrder) = 1!
-
- "IMPLEMENTATION NOTE:
- following algorithm is optimized in primitive only in case self and prefix are bytes like.
- Otherwise, if self is wide, then super outperforms,
- Otherwise, if prefix is wide, primitive is not correct"
-
- prefix class isBytes ifFalse: [^super beginsWith: prefix].
-
- self size < prefix size ifTrue: [^ false].
- ^ (self findSubstring: prefix in: self startingAt: 1
- matchTable: CaseSensitiveOrder) = 1
- !
Item was changed:
+ ----- Method: ByteSymbol>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer whether the receiver begins with the given sequence. The comparison is case-sensitive. Overridden for better performance."
- ----- Method: ByteSymbol>>beginsWith: (in category 'comparing') -----
- beginsWith: prefix
- "Answer whether the receiver begins with the given prefix string.
- The comparison is case-sensitive."
+ | sequenceSize |
+ sequence class isBytes ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
+ "The following method uses a suboptimal algorithm (brute force pattern matching with O(n^2) worst case runtime), but the primitive in C is so fast (assuming large alphabets), that it's still worth using it instead of linear time pure smalltalk implementation. There are some obvious cases when the brute force algorithm is suboptimal, e.g. when the first elements don't match, so let's compare them here before using the primitive."
+ (self basicAt: 1) = (sequence basicAt: 1) ifFalse: [ ^false ].
+ ^(self findSubstring: sequence in: self startingAt: 1 matchTable: CaseSensitiveOrder) = 1!
-
- "IMPLEMENTATION NOTE:
- following algorithm is optimized in primitive only in case self and prefix are bytes like.
- Otherwise, if self is wide, then super outperforms,
- Otherwise, if prefix is wide, primitive is not correct"
-
- prefix class isBytes ifFalse: [^super beginsWith: prefix].
-
- self size < prefix size ifTrue: [^ false].
- ^ (self findSubstring: prefix in: self startingAt: 1
- matchTable: CaseSensitiveOrder) = 1
- !
Item was changed:
----- Method: SequenceableCollection>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer true if the receiver starts with the argument collection."
+
+ | sequenceSize |
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequence size ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence at: index) = (self at: index) ifFalse: [ ^false ] ].
- beginsWith: aSequenceableCollection
- "Answer true if the receiver starts with the argument collection"
- (aSequenceableCollection isEmpty or: [self size < aSequenceableCollection size]) ifTrue: [^false].
- aSequenceableCollection withIndexDo: [:each :index | (self at: index) ~= each ifTrue: [^false]].
^true!
Item was changed:
----- Method: SequenceableCollection>>endsWith: (in category 'testing') -----
+ endsWith: sequence
+ "Answer true if the receiver ends with the argument collection."
+
+ | sequenceSize offset |
+ ((sequenceSize := sequence size) = 0 or: [ (offset := self size - sequence size) < 0 ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence at: index) = (self at: index + offset) ifFalse: [ ^false ] ].
- endsWith: aSequenceableCollection
- "Answer true if the receiver ends with the argument collection"
- | start |
- (aSequenceableCollection isEmpty or: [self size < aSequenceableCollection size]) ifTrue: [^false].
- start := self size - aSequenceableCollection size.
- aSequenceableCollection withIndexDo: [:each :index | (self at: start + index) ~= each ifTrue: [^false]].
^true!
Item was added:
+ ----- Method: String>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer true if the receiver starts with the argument collection. The comparison is case-sensitive. Overridden for better performance."
+
+ | sequenceSize |
+ sequence isString ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequence size ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence basicAt: index) = (self basicAt: index) ifFalse: [ ^false ] ].
+ ^true!
Item was changed:
----- Method: String>>endsWith: (in category 'testing') -----
endsWith: suffix
+ "Answer true if the receiver ends with the argument collection. The comparison is case-sensitive. Overridden for better performance."
- "Answer whether the tail end of the receiver is the same as suffix.
- The comparison is case-sensitive."
+ | offset |
+ (offset := self size - suffix size) < 0 ifTrue: [ ^false ].
+ ^(self findString: suffix startingAt: offset + 1) ~= 0!
- | extra |
- (extra := self size - suffix size) < 0 ifTrue: [^ false].
- ^ (self findString: suffix startingAt: extra + 1) > 0
- "
- 'Elvis' endsWith: 'vis'
- "!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.436.mcz
==================== Summary ====================
Name: Collections-ul.436
Author: ul
Time: 1 April 2011, 9:25:17.967 pm
UUID: f684fc31-c114-bf41-aecb-98f347ccb43e
Ancestors: Collections-nice.435
Improved #beginsWith: and #endsWith: implementations.
=============== Diff against Collections-nice.435 ===============
Item was changed:
+ ----- Method: ByteString>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer whether the receiver begins with the given sequence. The comparison is case-sensitive. Overridden for better performance."
- ----- Method: ByteString>>beginsWith: (in category 'comparing') -----
- beginsWith: prefix
- "Answer whether the receiver begins with the given prefix string.
- The comparison is case-sensitive."
+ | sequenceSize |
+ sequence class isBytes ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
+ "The following method uses a suboptimal algorithm (brute force pattern matching with O(n^2) worst case runtime), but the primitive in C is so fast (assuming large alphabets), that it's still worth using it instead of linear time pure smalltalk implementation. There are some obvious cases when the brute force algorithm is suboptimal, e.g. when the first elements don't match, so let's compare them here before using the primitive."
+ (self basicAt: 1) = (sequence basicAt: 1) ifFalse: [ ^false ].
+ ^(self findSubstring: sequence in: self startingAt: 1 matchTable: CaseSensitiveOrder) = 1!
-
- "IMPLEMENTATION NOTE:
- following algorithm is optimized in primitive only in case self and prefix are bytes like.
- Otherwise, if self is wide, then super outperforms,
- Otherwise, if prefix is wide, primitive is not correct"
-
- prefix class isBytes ifFalse: [^super beginsWith: prefix].
-
- self size < prefix size ifTrue: [^ false].
- ^ (self findSubstring: prefix in: self startingAt: 1
- matchTable: CaseSensitiveOrder) = 1
- !
Item was changed:
+ ----- Method: ByteSymbol>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer whether the receiver begins with the given sequence. The comparison is case-sensitive. Overridden for better performance."
- ----- Method: ByteSymbol>>beginsWith: (in category 'comparing') -----
- beginsWith: prefix
- "Answer whether the receiver begins with the given prefix string.
- The comparison is case-sensitive."
+ | sequenceSize |
+ sequence class isBytes ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
+ "The following method uses a suboptimal algorithm (brute force pattern matching with O(n^2) worst case runtime), but the primitive in C is so fast (assuming large alphabets), that it's still worth using it instead of linear time pure smalltalk implementation. There are some obvious cases when the brute force algorithm is suboptimal, e.g. when the first elements don't match, so let's compare them here before using the primitive."
+ (self basicAt: 1) = (sequence basicAt: 1) ifFalse: [ ^false ].
+ ^(self findSubstring: sequence in: self startingAt: 1 matchTable: CaseSensitiveOrder) = 1!
-
- "IMPLEMENTATION NOTE:
- following algorithm is optimized in primitive only in case self and prefix are bytes like.
- Otherwise, if self is wide, then super outperforms,
- Otherwise, if prefix is wide, primitive is not correct"
-
- prefix class isBytes ifFalse: [^super beginsWith: prefix].
-
- self size < prefix size ifTrue: [^ false].
- ^ (self findSubstring: prefix in: self startingAt: 1
- matchTable: CaseSensitiveOrder) = 1
- !
Item was changed:
----- Method: SequenceableCollection>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer true if the receiver starts with the argument collection."
+
+ | sequenceSize |
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequence size ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence at: index) = (self at: index) ifFalse: [ ^false ] ].
- beginsWith: aSequenceableCollection
- "Answer true if the receiver starts with the argument collection"
- (aSequenceableCollection isEmpty or: [self size < aSequenceableCollection size]) ifTrue: [^false].
- aSequenceableCollection withIndexDo: [:each :index | (self at: index) ~= each ifTrue: [^false]].
^true!
Item was changed:
----- Method: SequenceableCollection>>endsWith: (in category 'testing') -----
+ endsWith: sequence
+ "Answer true if the receiver ends with the argument collection."
+
+ | sequenceSize offset |
+ ((sequenceSize := sequence size) = 0 or: [ (offset := self size - sequence size) < 0 ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence at: index) = (self at: index + offset) ifFalse: [ ^false ] ].
- endsWith: aSequenceableCollection
- "Answer true if the receiver ends with the argument collection"
- | start |
- (aSequenceableCollection isEmpty or: [self size < aSequenceableCollection size]) ifTrue: [^false].
- start := self size - aSequenceableCollection size.
- aSequenceableCollection withIndexDo: [:each :index | (self at: start + index) ~= each ifTrue: [^false]].
^true!
Item was added:
+ ----- Method: String>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer true if the receiver starts with the argument collection. The comparison is case-sensitive. Overridden for better performance."
+
+ | sequenceSize |
+ sequence isString ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequence size ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence basicAt: index) = (self basicAt: index) ifFalse: [ ^false ] ].
+ ^true!
Item was changed:
----- Method: String>>endsWith: (in category 'testing') -----
endsWith: suffix
+ "Answer true if the receiver ends with the argument collection. The comparison is case-sensitive. Overridden for better performance."
- "Answer whether the tail end of the receiver is the same as suffix.
- The comparison is case-sensitive."
+ | offset |
+ (offset := self size - suffix size) < 0 ifTrue: [ ^false ].
+ ^(self findString: suffix startingAt: offset + 1) ~= 0!
- | extra |
- (extra := self size - suffix size) < 0 ifTrue: [^ false].
- ^ (self findString: suffix startingAt: extra + 1) > 0
- "
- 'Elvis' endsWith: 'vis'
- "!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.436.mcz
==================== Summary ====================
Name: Collections-ul.436
Author: ul
Time: 1 April 2011, 9:25:17.967 pm
UUID: f684fc31-c114-bf41-aecb-98f347ccb43e
Ancestors: Collections-nice.435
Improved #beginsWith: and #endsWith: implementations.
=============== Diff against Collections-nice.435 ===============
Item was changed:
+ ----- Method: ByteString>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer whether the receiver begins with the given sequence. The comparison is case-sensitive. Overridden for better performance."
- ----- Method: ByteString>>beginsWith: (in category 'comparing') -----
- beginsWith: prefix
- "Answer whether the receiver begins with the given prefix string.
- The comparison is case-sensitive."
+ | sequenceSize |
+ sequence class isBytes ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
+ "The following method uses a suboptimal algorithm (brute force pattern matching with O(n^2) worst case runtime), but the primitive in C is so fast (assuming large alphabets), that it's still worth using it instead of linear time pure smalltalk implementation. There are some obvious cases when the brute force algorithm is suboptimal, e.g. when the first elements don't match, so let's compare them here before using the primitive."
+ (self basicAt: 1) = (sequence basicAt: 1) ifFalse: [ ^false ].
+ ^(self findSubstring: sequence in: self startingAt: 1 matchTable: CaseSensitiveOrder) = 1!
-
- "IMPLEMENTATION NOTE:
- following algorithm is optimized in primitive only in case self and prefix are bytes like.
- Otherwise, if self is wide, then super outperforms,
- Otherwise, if prefix is wide, primitive is not correct"
-
- prefix class isBytes ifFalse: [^super beginsWith: prefix].
-
- self size < prefix size ifTrue: [^ false].
- ^ (self findSubstring: prefix in: self startingAt: 1
- matchTable: CaseSensitiveOrder) = 1
- !
Item was changed:
+ ----- Method: ByteSymbol>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer whether the receiver begins with the given sequence. The comparison is case-sensitive. Overridden for better performance."
- ----- Method: ByteSymbol>>beginsWith: (in category 'comparing') -----
- beginsWith: prefix
- "Answer whether the receiver begins with the given prefix string.
- The comparison is case-sensitive."
+ | sequenceSize |
+ sequence class isBytes ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
+ "The following method uses a suboptimal algorithm (brute force pattern matching with O(n^2) worst case runtime), but the primitive in C is so fast (assuming large alphabets), that it's still worth using it instead of linear time pure smalltalk implementation. There are some obvious cases when the brute force algorithm is suboptimal, e.g. when the first elements don't match, so let's compare them here before using the primitive."
+ (self basicAt: 1) = (sequence basicAt: 1) ifFalse: [ ^false ].
+ ^(self findSubstring: sequence in: self startingAt: 1 matchTable: CaseSensitiveOrder) = 1!
-
- "IMPLEMENTATION NOTE:
- following algorithm is optimized in primitive only in case self and prefix are bytes like.
- Otherwise, if self is wide, then super outperforms,
- Otherwise, if prefix is wide, primitive is not correct"
-
- prefix class isBytes ifFalse: [^super beginsWith: prefix].
-
- self size < prefix size ifTrue: [^ false].
- ^ (self findSubstring: prefix in: self startingAt: 1
- matchTable: CaseSensitiveOrder) = 1
- !
Item was changed:
----- Method: SequenceableCollection>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer true if the receiver starts with the argument collection."
+
+ | sequenceSize |
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequence size ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence at: index) = (self at: index) ifFalse: [ ^false ] ].
- beginsWith: aSequenceableCollection
- "Answer true if the receiver starts with the argument collection"
- (aSequenceableCollection isEmpty or: [self size < aSequenceableCollection size]) ifTrue: [^false].
- aSequenceableCollection withIndexDo: [:each :index | (self at: index) ~= each ifTrue: [^false]].
^true!
Item was changed:
----- Method: SequenceableCollection>>endsWith: (in category 'testing') -----
+ endsWith: sequence
+ "Answer true if the receiver ends with the argument collection."
+
+ | sequenceSize offset |
+ ((sequenceSize := sequence size) = 0 or: [ (offset := self size - sequence size) < 0 ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence at: index) = (self at: index + offset) ifFalse: [ ^false ] ].
- endsWith: aSequenceableCollection
- "Answer true if the receiver ends with the argument collection"
- | start |
- (aSequenceableCollection isEmpty or: [self size < aSequenceableCollection size]) ifTrue: [^false].
- start := self size - aSequenceableCollection size.
- aSequenceableCollection withIndexDo: [:each :index | (self at: start + index) ~= each ifTrue: [^false]].
^true!
Item was added:
+ ----- Method: String>>beginsWith: (in category 'testing') -----
+ beginsWith: sequence
+ "Answer true if the receiver starts with the argument collection. The comparison is case-sensitive. Overridden for better performance."
+
+ | sequenceSize |
+ sequence isString ifFalse: [ ^super beginsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ self size < sequence size ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence basicAt: index) = (self basicAt: index) ifFalse: [ ^false ] ].
+ ^true!
Item was changed:
----- Method: String>>endsWith: (in category 'testing') -----
endsWith: suffix
+ "Answer true if the receiver ends with the argument collection. The comparison is case-sensitive. Overridden for better performance."
- "Answer whether the tail end of the receiver is the same as suffix.
- The comparison is case-sensitive."
+ | offset |
+ (offset := self size - suffix size) < 0 ifTrue: [ ^false ].
+ ^(self findString: suffix startingAt: offset + 1) ~= 0!
- | extra |
- (extra := self size - suffix size) < 0 ifTrue: [^ false].
- ^ (self findString: suffix startingAt: extra + 1) > 0
- "
- 'Elvis' endsWith: 'vis'
- "!
Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.304.mcz
==================== Summary ====================
Name: Tools-eem.304
Author: eem
Time: 31 March 2011, 6:29:51.619 pm
UUID: bf2886ee-1f33-47ad-9025-c7253c619dd8
Ancestors: Tools-nice.303
Debugger:
- use the selectedContext's method when browsing
senders and implementors.
- do not discard changes if the compilation of an edited
method fails when in a block.
=============== Diff against Tools-nice.303 ===============
Item was changed:
----- Method: Debugger>>browseMessages (in category 'context stack menu') -----
browseMessages
"Present a menu of all messages sent by the currently selected message.
Open a message set browser of all implementors of the message chosen.
Do nothing if no message is chosen."
contextStackIndex = 0 ifTrue: [^ self].
+ self withSelectorAndMessagesIn: self selectedContext method
- self withSelectorAndMessagesIn: currentCompiledMethod
evaluate: [:selector| self systemNavigation browseAllImplementorsOf: selector]!
Item was changed:
----- Method: Debugger>>browseSendersOfMessages (in category 'context stack menu') -----
browseSendersOfMessages
"Present a menu of the currently selected message, as well as all
messages sent by it. Open a message set browser of all senders
of the message chosen."
contextStackIndex = 0 ifTrue: [^ self].
+ self withSelectorAndMessagesIn: self selectedContext method
- self withSelectorAndMessagesIn: currentCompiledMethod
evaluate: [:selector| self systemNavigation browseAllCallsOn: selector]!
Item was changed:
----- Method: Debugger>>contents:notifying: (in category 'accessing') -----
contents: aText notifying: aController
"The retrieved information has changed and its source must now be updated.
In this case, the retrieved information is the method of the selected context."
| result selector classOfMethod category h ctxt newMethod |
contextStackIndex = 0 ifTrue:
[^false].
self selectedContext isExecutingBlock ifTrue:
[h := self selectedContext activeHome.
h ifNil:
[self inform: 'Method for block not found on stack, can''t edit and continue'.
^false].
(self confirm: 'I will have to revert to the method from\which this block originated. Is that OK?' withCRs) ifFalse:
[^false].
self resetContext: h.
+ "N.B. Only reset the contents if the compilation succeeds. If contents are reset
+ when compilation fails both compiler error message and modifications are lost."
+ (result := self contents: aText notifying: aController) ifTrue:
+ [self contentsChanged].
- result := self contents: aText notifying: aController.
- self contentsChanged.
^result].
classOfMethod := self selectedClass.
category := self selectedMessageCategoryName.
selector := self selectedClass newParser parseSelector: aText.
(selector == self selectedMessageName
or: [(self selectedMessageName beginsWith: 'DoIt')
and: [selector numArgs = self selectedMessageName numArgs]]) ifFalse:
[self inform: 'can''t change selector'.
^false].
selector := classOfMethod
compile: aText
classified: category
notifying: aController.
selector ifNil: [^false]. "compile cancelled"
contents := aText.
newMethod := classOfMethod compiledMethodAt: selector.
newMethod isQuick ifTrue:
[self down.
self selectedContext jump: (self selectedContext previousPc - self selectedContext pc)].
ctxt := interruptedProcess popTo: self selectedContext.
ctxt == self selectedContext
ifFalse:
[self inform: 'Method saved, but current context unchanged\because of unwind error. Click OK to see error' withCRs]
ifTrue:
[newMethod isQuick ifFalse:
[interruptedProcess
restartTopWith: newMethod;
stepToSendOrReturn].
contextVariablesInspector object: nil].
self resetContext: ctxt.
Smalltalk isMorphic ifTrue:
[World
addAlarm: #changed:
withArguments: #(contentsSelection)
for: self
at: (Time millisecondClockValue + 200)].
^true!
Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.304.mcz
==================== Summary ====================
Name: Tools-eem.304
Author: eem
Time: 31 March 2011, 6:29:51.619 pm
UUID: bf2886ee-1f33-47ad-9025-c7253c619dd8
Ancestors: Tools-nice.303
Debugger:
- use the selectedContext's method when browsing
senders and implementors.
- do not discard changes if the compilation of an edited
method fails when in a block.
=============== Diff against Tools-nice.303 ===============
Item was changed:
----- Method: Debugger>>browseMessages (in category 'context stack menu') -----
browseMessages
"Present a menu of all messages sent by the currently selected message.
Open a message set browser of all implementors of the message chosen.
Do nothing if no message is chosen."
contextStackIndex = 0 ifTrue: [^ self].
+ self withSelectorAndMessagesIn: self selectedContext method
- self withSelectorAndMessagesIn: currentCompiledMethod
evaluate: [:selector| self systemNavigation browseAllImplementorsOf: selector]!
Item was changed:
----- Method: Debugger>>browseSendersOfMessages (in category 'context stack menu') -----
browseSendersOfMessages
"Present a menu of the currently selected message, as well as all
messages sent by it. Open a message set browser of all senders
of the message chosen."
contextStackIndex = 0 ifTrue: [^ self].
+ self withSelectorAndMessagesIn: self selectedContext method
- self withSelectorAndMessagesIn: currentCompiledMethod
evaluate: [:selector| self systemNavigation browseAllCallsOn: selector]!
Item was changed:
----- Method: Debugger>>contents:notifying: (in category 'accessing') -----
contents: aText notifying: aController
"The retrieved information has changed and its source must now be updated.
In this case, the retrieved information is the method of the selected context."
| result selector classOfMethod category h ctxt newMethod |
contextStackIndex = 0 ifTrue:
[^false].
self selectedContext isExecutingBlock ifTrue:
[h := self selectedContext activeHome.
h ifNil:
[self inform: 'Method for block not found on stack, can''t edit and continue'.
^false].
(self confirm: 'I will have to revert to the method from\which this block originated. Is that OK?' withCRs) ifFalse:
[^false].
self resetContext: h.
+ "N.B. Only reset the contents if the compilation succeeds. If contents are reset
+ when compilation fails both compiler error message and modifications are lost."
+ (result := self contents: aText notifying: aController) ifTrue:
+ [self contentsChanged].
- result := self contents: aText notifying: aController.
- self contentsChanged.
^result].
classOfMethod := self selectedClass.
category := self selectedMessageCategoryName.
selector := self selectedClass newParser parseSelector: aText.
(selector == self selectedMessageName
or: [(self selectedMessageName beginsWith: 'DoIt')
and: [selector numArgs = self selectedMessageName numArgs]]) ifFalse:
[self inform: 'can''t change selector'.
^false].
selector := classOfMethod
compile: aText
classified: category
notifying: aController.
selector ifNil: [^false]. "compile cancelled"
contents := aText.
newMethod := classOfMethod compiledMethodAt: selector.
newMethod isQuick ifTrue:
[self down.
self selectedContext jump: (self selectedContext previousPc - self selectedContext pc)].
ctxt := interruptedProcess popTo: self selectedContext.
ctxt == self selectedContext
ifFalse:
[self inform: 'Method saved, but current context unchanged\because of unwind error. Click OK to see error' withCRs]
ifTrue:
[newMethod isQuick ifFalse:
[interruptedProcess
restartTopWith: newMethod;
stepToSendOrReturn].
contextVariablesInspector object: nil].
self resetContext: ctxt.
Smalltalk isMorphic ifTrue:
[World
addAlarm: #changed:
withArguments: #(contentsSelection)
for: self
at: (Time millisecondClockValue + 200)].
^true!
Eliot Miranda uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-eem.304.mcz
==================== Summary ====================
Name: Tools-eem.304
Author: eem
Time: 31 March 2011, 6:29:51.619 pm
UUID: bf2886ee-1f33-47ad-9025-c7253c619dd8
Ancestors: Tools-nice.303
Debugger:
- use the selectedContext's method when browsing
senders and implementors.
- do not discard changes if the compilation of an edited
method fails when in a block.
=============== Diff against Tools-nice.303 ===============
Item was changed:
----- Method: Debugger>>browseMessages (in category 'context stack menu') -----
browseMessages
"Present a menu of all messages sent by the currently selected message.
Open a message set browser of all implementors of the message chosen.
Do nothing if no message is chosen."
contextStackIndex = 0 ifTrue: [^ self].
+ self withSelectorAndMessagesIn: self selectedContext method
- self withSelectorAndMessagesIn: currentCompiledMethod
evaluate: [:selector| self systemNavigation browseAllImplementorsOf: selector]!
Item was changed:
----- Method: Debugger>>browseSendersOfMessages (in category 'context stack menu') -----
browseSendersOfMessages
"Present a menu of the currently selected message, as well as all
messages sent by it. Open a message set browser of all senders
of the message chosen."
contextStackIndex = 0 ifTrue: [^ self].
+ self withSelectorAndMessagesIn: self selectedContext method
- self withSelectorAndMessagesIn: currentCompiledMethod
evaluate: [:selector| self systemNavigation browseAllCallsOn: selector]!
Item was changed:
----- Method: Debugger>>contents:notifying: (in category 'accessing') -----
contents: aText notifying: aController
"The retrieved information has changed and its source must now be updated.
In this case, the retrieved information is the method of the selected context."
| result selector classOfMethod category h ctxt newMethod |
contextStackIndex = 0 ifTrue:
[^false].
self selectedContext isExecutingBlock ifTrue:
[h := self selectedContext activeHome.
h ifNil:
[self inform: 'Method for block not found on stack, can''t edit and continue'.
^false].
(self confirm: 'I will have to revert to the method from\which this block originated. Is that OK?' withCRs) ifFalse:
[^false].
self resetContext: h.
+ "N.B. Only reset the contents if the compilation succeeds. If contents are reset
+ when compilation fails both compiler error message and modifications are lost."
+ (result := self contents: aText notifying: aController) ifTrue:
+ [self contentsChanged].
- result := self contents: aText notifying: aController.
- self contentsChanged.
^result].
classOfMethod := self selectedClass.
category := self selectedMessageCategoryName.
selector := self selectedClass newParser parseSelector: aText.
(selector == self selectedMessageName
or: [(self selectedMessageName beginsWith: 'DoIt')
and: [selector numArgs = self selectedMessageName numArgs]]) ifFalse:
[self inform: 'can''t change selector'.
^false].
selector := classOfMethod
compile: aText
classified: category
notifying: aController.
selector ifNil: [^false]. "compile cancelled"
contents := aText.
newMethod := classOfMethod compiledMethodAt: selector.
newMethod isQuick ifTrue:
[self down.
self selectedContext jump: (self selectedContext previousPc - self selectedContext pc)].
ctxt := interruptedProcess popTo: self selectedContext.
ctxt == self selectedContext
ifFalse:
[self inform: 'Method saved, but current context unchanged\because of unwind error. Click OK to see error' withCRs]
ifTrue:
[newMethod isQuick ifFalse:
[interruptedProcess
restartTopWith: newMethod;
stepToSendOrReturn].
contextVariablesInspector object: nil].
self resetContext: ctxt.
Smalltalk isMorphic ifTrue:
[World
addAlarm: #changed:
withArguments: #(contentsSelection)
for: self
at: (Time millisecondClockValue + 200)].
^true!