Adding methods in the Debugger
Ned Konz
ned at bike-nomad.com
Thu Feb 13 03:17:28 UTC 2003
On Wednesday 12 February 2003 06:52 pm, Andrew P. Black wrote:
> Afterwards, in discussing this experience with someone, I learned
> that the process could be made even better. The trick is to
> enhance the debugger so that when a MNU occurs, it is possible to
> define the missing method right there, in the debugger, and resume.
> I imagine that this makes the whole process smoother; after all,
> the debugger knows exactly what method needs to be defined, and can
> offer a hierarchy of possible classes where it could be located.
>
> My question is: has someone done this for Squeak? For other
> Smalltalks?
Well, you can define a missing method in a separate browser and just
resume in the Debugger. It's just that the Debugger doesn't have any
way to do the editing on a missing method.
One strategy that might work is to have doesNotUnderstand: quickly
write a method that just does a halt, and then call the new method.
This will land you in a Debugger where you can then edit the code and
resume.
doesNotUnderstand: msg
| src i |
i _ 1.
src _ String streamContents: [ :s |
msg selector keywords do: [ :key |
s nextPutAll: key.
(key last = $:) ifTrue: [ s nextPutAll: ' arg'; nextPutAll: i
asString; space ].
i _ i + 1.
].
s cr; tab.
s nextPutAll: 'self halt'
].
self class compile: src classified: 'not yet written'.
^self perform: msg selector withArguments: msg arguments
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|