[Pkg] The Trunk: EToys-fbs.78.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Jan 29 00:22:33 UTC 2011
Levente Uzonyi uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-fbs.78.mcz
==================== Summary ====================
Name: EToys-fbs.78
Author: fbs
Time: 22 December 2010, 8:46:12.242 am
UUID: b05ca9a9-a9e0-e047-84a8-0fd215cd95e4
Ancestors: EToys-cmm.77
Use Character space instead of $ to avoid Decompiler tests failing.
=============== Diff against EToys-cmm.77 ===============
Item was changed:
----- Method: SyntaxMorph>>replaceKeyWord:menuItem: (in category 'pop ups') -----
replaceKeyWord: evt menuItem: stringMorph
"Replace my entire message (which may be multi-part) with the one specified. Preserve all argument tiles, either in the new message or in the world outside the scriptor. I am a SelectorNode or KeyWordNode."
| menu new news newSel mm newTree newRec newArgs top oldArgNodes share ctrY |
(menu := stringMorph owner owner) class == RectangleMorph ifTrue: [
menu delete].
new := stringMorph contents.
new first = $( ifTrue: [^ self]. "Cancel"
new first = $ ifTrue: [^ self]. "nothing"
news := String streamContents: [:strm | "remove fake args"
+ (new findBetweenSubStrs: {' 5'. Character space.}) do: [:part | strm nextPutAll: part]].
- (new findBetweenSubStrs: #(' 5' $ )) do: [:part | strm nextPutAll: part]].
newSel := stringMorph valueOfProperty: #syntacticallyCorrectContents.
newSel ifNil: [newSel := news].
mm := MessageSend receiver: 5 selector: newSel
arguments: ((Array new: newSel numArgs) atAllPut: 5).
newTree := mm asTilesIn: Object globalNames: false.
newRec := newTree receiverNode.
newArgs := newTree argumentNodes.
ctrY := self fullBoundsInWorld center y.
top := self messageNode.
newRec owner replaceSubmorph: newRec by: top receiverNode.
oldArgNodes := top argumentNodes.
share := newArgs size min: oldArgNodes size.
(newArgs first: share) with: (oldArgNodes first: share) do: [:newNode :oldNode |
newNode owner replaceSubmorph: newNode by: oldNode].
"later get nodes for objects of the right type for new extra args"
top owner replaceSubmorph: top by: newTree.
"Deposit extra args in the World"
(oldArgNodes copyFrom: share+1 to: oldArgNodes size) do: [:leftOver |
(leftOver parseNode class == LiteralNode and: [leftOver decompile asString = '5'])
ifFalse: [newTree pasteUpMorph addMorphFront: leftOver.
leftOver position: newTree enclosingPane fullBoundsInWorld right - 20 @ ctrY.
ctrY := ctrY + 26]
ifTrue: [leftOver delete]].
newTree acceptIfInScriptor.!
Item was changed:
----- Method: SyntaxMorph>>replaceSel:menuItem: (in category 'pop ups') -----
replaceSel: evt menuItem: stringMorph
"I rep a SelectorNode. Replace my selector with new one that was just chosen from a menu"
| menu new old newSel ms oa na case news |
(menu := stringMorph owner owner) class == RectangleMorph ifTrue: [
menu delete].
new := stringMorph contents.
new first = $( ifTrue: [^ self]. "Cancel"
new first = $ ifTrue: [^ self]. "nothing"
news := String streamContents: [:strm | "remove fake args"
+ (new findBetweenSubStrs: {' 5'. Character space.}) do: [:part | strm nextPutAll: part]].
- (new findBetweenSubStrs: #(' 5' $ )) do: [:part | strm nextPutAll: part]].
newSel := stringMorph valueOfProperty: #syntacticallyCorrectContents.
newSel ifNil: [newSel := news].
old := (ms := self findA: StringMorph) valueOfProperty: #syntacticallyCorrectContents.
old ifNil: [old := (self findA: StringMorph) contents].
oa := old numArgs. na := newSel numArgs. case := 5.
(oa = 1) & (na = 1) ifTrue: [case := 1].
(oa = 0) & (na = 0) ifTrue: [case := 2].
(oa = 1) & (na = 0) ifTrue: [case := 3].
(oa = 0) & (na = 1) ifTrue: [case := 4].
case <= 4 ifTrue: ["replace the selector"
ms contents: news. "not multi-part"
ms setProperty: #syntacticallyCorrectContents toValue: newSel].
case = 3 ifTrue: [owner tossOutArg: 1].
case = 4 ifTrue: [self addArg: 1].
"more cases here. Rebuild the entire MessageNode"
self acceptIfInScriptor.!
More information about the Packages
mailing list