Marcel Taeumel uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-ct.369.mcz ==================== Summary ==================== Name: EToys-ct.369 Author: ct Time: 15 October 2019, 9:56:30.25283 pm UUID: 0328de9a-3f0f-fb44-a8d9-12b8bee91796 Ancestors: EToys-ct.366 Refines conversion of MessageNodes into test tiles: Don't fill empty cases with "nil" =============== Diff against EToys-ct.366 =============== Item was changed: ----- Method: BlockNode>>withoutImplicitReturns (in category '*Etoys-tiles') ----- withoutImplicitReturns + (self statements ifEmpty: [^ self]) last isImplicitReturn - (self statements ifEmpty: [^ self]) last isReturnSelf ifFalse: [^ self]. ^ self copy statements: self statements allButLast! Item was changed: ----- Method: MessageNode>>asTileForPlayer: (in category '*Etoys-tiles') ----- asTileForPlayer: aPlayer | receiverType argumentType resultType phrase receiverTiles | "Catch edge case: Color tile" (self receiver isVariableNode and: [self receiver key = (Smalltalk bindingOf: #Color)]) ifTrue: [ | source result | source := String streamContents: (MessageSend receiver: self selector: #shortPrintOn:). result := [Compiler evaluate: source] ifError: [nil]. result isColor ifTrue: [^ result newTileMorphRepresentative]]. "Catch edge case: Test tile" self ifConditionNormalizeAndDo: [:conditionNode :trueNode :falseNode | | compound | compound := StandardScriptingSystem new yesNoComplexOfTiles. compound testPart insertTileRow: (conditionNode asTileSetForPlayer: aPlayer) after: 0. + compound yesPart insertTileRow: (trueNode withoutImplicitReturns asTileSetForPlayer: aPlayer) after: 0. + compound noPart insertTileRow: (falseNode withoutImplicitReturns asTileSetForPlayer: aPlayer) after: 0. - compound yesPart insertTileRow: (trueNode asTileSetForPlayer: aPlayer) after: 0. - compound noPart insertTileRow: (falseNode asTileSetForPlayer: aPlayer) after: 0. compound enforceTileColorPolicy; layoutChanged; fullBounds. ^ compound]. "Otherwise, try to build a phrase tile" self arguments size < 2 ifFalse: [^ self convertToTileError]. receiverType := #unknown. argumentType := self arguments ifEmpty: [nil] ifNotEmpty: [#unknown]. resultType := #unkown. phrase := PhraseTileMorph new. phrase setOperator: self selector key type: resultType rcvrType: receiverType argType: argumentType. receiverTiles := self receiver asTileSetForPlayer: aPlayer. receiverTiles size = 1 ifFalse: [^ self convertToTileError]. phrase firstSubmorph addMorph: receiverTiles first; hResizing: #shrinkWrap; vResizing: #shrinkWrap. self arguments ifNotEmpty: [ | argumentTiles | argumentTiles := self arguments first asTileSetForPlayer: aPlayer. argumentTiles size = 1 ifFalse: [^ self convertToTileError]. phrase lastSubmorph setType: argumentType; addMorph: argumentTiles first; hResizing: #shrinkWrap; vResizing: #shrinkWrap]. ^ phrase hResizing: #shrinkWrap; vResizing: #shrinkWrap; yourself! Item was changed: ----- Method: MessageNode>>ifConditionNormalizeAndDo: (in category '*Etoys-tiles') ----- ifConditionNormalizeAndDo: aBlock | blocks | blocks := self selector key caseOf: { [#ifTrue:ifFalse:] -> [arguments]. [#ifFalse:ifTrue:] -> [self arguments reversed]. + [#ifTrue:] -> [self arguments copyWith: (BlockNode statements: #() returns: #())]. + [#ifFalse:] -> [self arguments copyWithFirst: (BlockNode statements: #() returns: #())] } - [#ifTrue:] -> [self arguments copyWith: BlockNode new]. - [#ifFalse:] -> [self arguments copyWithFirst: BlockNode new] } otherwise: [^ self]. ^ aBlock value: self receiver value: blocks first value: blocks last! Item was added: + ----- Method: ParseNode>>isImplicitReturn (in category '*Etoys-tiles') ----- + isImplicitReturn + + ^false! Item was added: + ----- Method: ReturnNode>>isImplicitReturn (in category '*Etoys-tiles') ----- + isImplicitReturn + + ^ self isReturnSelf! Item was added: + ----- Method: VariableNode>>isImplicitReturn (in category '*Etoys-tiles') ----- + isImplicitReturn + + ^ self = NodeNil! |
Free forum by Nabble | Edit this page |