[BUG][FIX] Replacement for cs 2344

Bob Arning arning at charm.net
Tue Jun 13 22:55:45 UTC 2000


On Tue, 13 Jun 2000 18:37:32 -0400 (EDT) Bob Arning <arning at charm.net> wrote:
>On Tue, 13 Jun 2000 12:07:31 -0700 Jim Heyne <jheyne at exobox.com> wrote:
>>I started with the most recent posted 2.8 zip image.
>>
>>Looks like there are some missing methods in 2344...
>>
>>
>>13 June 2000 12:06:55 pm
>>MessageNotUnderstood: method:context:encoder:
>>Parser(Object)>>doesNotUnderstand:
>>[] in Parser>>parse:class:noPattern:context:notifying:ifFail:
>
>Hi Jim,
>
>That's a boo-boo. The change set I submitted earlier today to fix the problem in printIt was based on and, in one case, depends on 2.9a. Unfortunately it was added to both the 2.8 bug fix list as well as the 2.9a update list. 
>
>If you really want pure 2.8, then you need to stop updating before 2344 (which is, I think, the only substantive update in that stream). You could retrieve the updates to disk without applying them and then manually delete the Parser change before filing it in.
>
>If you want 2.9a, then changing your version before getting updates should avoid 2344 altogether.
>
>Note to Ted: We ought to pull this from the 2.8 stream and substitute something less troublesome (without the Parser method would be a good start).

Ted, Jim,

Here is a replacement for change set 2344 which does not include the alternate syntax code that caused the problem.

Cheers,
Bob

===== code follows =====
'From Squeak2.9alpha of 13 June 2000 [latest update: #2404] on 13 June 2000 at 10:58:36 am'!
"Change Set:		printItFix
Date:			13 June 2000
Author:			Bob Arning

Fixes a couple of problems with #printIt

1. Since code evaluated from a text pane arrives at the parser in a stream based on a range of positions in the text pane (see #selectionAsStream) and since removal of unreferenced variables will alter the text, the technique of a second compilation to insure that source and bytecodes agree as to variable offset is unreliable. Solution: disable second compilation in these cases.

2. Use of the menu to invoke printIt and/or messages popping up during the evaluation process can cause loss of focus on the text pane and replacement of the editor. Since the original editor is actually processing the evaluation, this causes the text, editors and paragraphs to get out of sync, resulting in values printing in odd places or not at all. Solution: preserve pertinent data from old editor across the evaluation.
"!


!Parser methodsFor: 'public access' stamp: 'RAA 6/13/2000 18:48'!
parse: sourceStream class: class noPattern: noPattern context: ctxt notifying: req ifFail: aBlock 
	"Answer a MethodNode for the argument, sourceStream, that is the root of 
	a parse tree. Parsing is done with respect to the argument, class, to find 
	instance, class, and pool variables; and with respect to the argument, 
	ctxt, to find temporary variables. Errors in parsing are reported to the 
	argument, req, if not nil; otherwise aBlock is evaluated. The argument 
	noPattern is a Boolean that is true if the the sourceStream does not 
	contain a method header (i.e., for DoIts)."

	 | meth repeatNeeded myStream |
	myStream _ sourceStream.
	[repeatNeeded _ false.
	self init: myStream notifying: req failBlock: [^aBlock value].
	doitFlag _ noPattern.
	encoder _ Encoder new init: class context: ctxt notifying: self.
	failBlock_ aBlock.
	[meth _ self method: noPattern context: ctxt] 
		on: ParserRemovedUnusedTemps 
		do: 
			[ :ex | repeatNeeded _ (requestor isKindOf: TextMorphEditor) not.
			myStream _ ReadStream on: requestor text string.
			ex resume].
	repeatNeeded] whileTrue.
	encoder _ failBlock _ requestor _ parseNode _ nil. "break cycles & mitigate refct overflow"
	^ meth! !


!PluggableTextMorph methodsFor: 'menu commands' stamp: 'RAA 6/13/2000 10:55'!
printIt
	| result oldEditor |

	textMorph editor selectFrom: selectionInterval first to: selectionInterval last;
						model: model.  "For, eg, evaluateSelection"
	textMorph handleEdit: [result _ (oldEditor _ textMorph editor) evaluateSelection].
	((result isKindOf: FakeClassPool) or: [result == #failedDoit]) ifTrue: [^self flash].
	selectionInterval _ oldEditor selectionInterval.
	textMorph installEditorToReplace: oldEditor.
	textMorph handleEdit: [oldEditor afterSelectionInsertAndSelect: result printString].
	selectionInterval _ oldEditor selectionInterval.
	
	textMorph editor selectFrom: selectionInterval first to: selectionInterval last.
	self scrollSelectionIntoView.

! !


!TextMorph methodsFor: 'editing' stamp: 'RAA 6/13/2000 10:35'!
handleInteraction: interactionBlock fromEvent: evt
	| oldEditor |
	"Perform the changes in interactionBlock, noting any change in selection"

	"Also couple ParagraphEditor to Morphic keyboard events"
	self editor sensor: (KeyboardBuffer new startingEvent: evt).
	oldEditor _ editor.
	self selectionChanged.  "Note old selection"

		interactionBlock value.

	editor _ oldEditor.	"since it may have been changes while in block"
	self selectionChanged.  "Note new selection"! !





More information about the Squeak-dev mailing list