Tim Felgentreff uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-tfel.224.mcz ==================== Summary ==================== Name: EToys-tfel.224 Author: tfel Time: 31 August 2016, 2:36:36.089793 pm UUID: 8a75af73-83e6-2e4b-b326-5b6319899e4f Ancestors: EToys-jl.223 evaluate conditions in Kedama parallel for every turtle (so that e.g. randomness is parallel) =============== Diff against EToys-jl.222 =============== Item was changed: ----- Method: KedamaTurtleVectorPlayer2>>test:ifTrue:ifFalse: (in category 'command execution') ----- test: cond ifTrue: trueBlock ifFalse: falseBlock + | origPredicate c actualCond | - | origPredicate c | (cond == true or: [cond == false]) ifTrue: [ ^ cond ifTrue: [trueBlock value: self] ifFalse: [falseBlock value: self]. ]. + actualCond := cond. + cond isBlock ifTrue: [ + actualCond := ByteArray new: predicate size. + 1 to: predicate size do: [:i | actualCond at: i put: (cond value ifTrue: [1] ifFalse: [0])] + ]. origPredicate := predicate clone. + predicate bytesAnd: actualCond. - predicate bytesAnd: cond. trueBlock value: self. + c := actualCond clone. - c := cond clone. c not. predicate replaceFrom: 1 to: (predicate size min: origPredicate size) with: origPredicate startingAt: 1. predicate bytesAnd: c. falseBlock value: self. predicate replaceFrom: 1 to: (predicate size min: origPredicate size) with: origPredicate startingAt: 1.! Item was changed: ----- Method: KedamaVectorParseTreeRewriter>>visit:andParent: (in category 'entry point') ----- visit: node andParent: parent + | newNode possibleSelector selIndex parentRewriterBlock newNodeBlock | - | newNode possibleSelector selIndex | node isLeaf not ifTrue: [ node getAllChildren do: [:child | self visit: child andParent: node. ]. ]. (node rewriteInfoOut notNil) ifTrue: [ ((node isMemberOf: VariableNode) or: [node isMemberOf: LiteralVariableNode]) ifTrue: [ newNode := TempVariableNode new name: node rewriteInfoOut second index: 0 type: 2. parent replaceNode: node with: newNode. ]. - ]. (node isMemberOf: MessageNode) ifTrue: [ (node statementType = #sequential) ifTrue: [ node selector key = #doSequentialCommand: ifTrue: [ (node isStatement) ifTrue: [ node receiver: node primaryBreedPair second. ]. ] ]. ]. + (node isMemberOf: MessageNode) ifTrue: [ + newNodeBlock := [:selector :args | + self + createMessageNode: node + inParentNode: parent + receiverNode: (TempVariableNode new name: node rewriteInfoOut second index: 0 type: 2) + selector: selector + arguments: args]. + - (node isMemberOf: MessageNode) ifTrue: [ ((selIndex := #(parallel sequential die) indexOf: node statementType) > 0) ifTrue: [ possibleSelector := #(doCommand: doSequentialCommand: doDieCommand:) at: selIndex. + + parentRewriterBlock := [:newNod | + self + rewriteMessageNode: node + inParentNode: parent + receiverNode: node rewriteInfoIn second + selector: possibleSelector + arguments: {self + makeBlockNodeArguments: {node rewriteInfoOut second} + statements: {newNod} returns: false}]. + (node messageType = #condition) ifTrue: [ + newNode := newNodeBlock + value: #test:ifTrue:ifFalse: + value: {BlockNode withJust: node receiver. node arguments first. node arguments second}. - newNode := self createMessageNode: node inParentNode: parent receiverNode: (TempVariableNode new name: node rewriteInfoOut second index: 0 type: 2) selector: #test:ifTrue:ifFalse: arguments: (Array with: node receiver with: node arguments first with: node arguments second). (node isStatement) ifFalse: [ parent replaceNode: node with: newNode. ] ifTrue: [ + parentRewriterBlock value: newNode. - self rewriteMessageNode: node inParentNode: parent receiverNode: node rewriteInfoIn second selector: possibleSelector arguments: (Array with: (self makeBlockNodeArguments: (Array with: node rewriteInfoOut second) statements: (Array with: newNode) returns: false)). ]. ] ifFalse: [ + node selector key = #timesRepeat: + ifTrue: [ + newNode := newNodeBlock + value: #times:repeat: + value: {node receiver. node arguments first}. + (node isStatement) ifFalse: [ + parent replaceNode: node with: newNode. + ] ifTrue: [ + parentRewriterBlock value: newNode. + ]. + ] + ifFalse: [(node isStatement) ifTrue: [ + parentRewriterBlock value: node + ]. - (node isStatement) ifTrue: [ - self rewriteMessageNode: node inParentNode: parent receiverNode: node rewriteInfoIn second selector: possibleSelector arguments: (Array with: (self makeBlockNodeArguments: (Array with: node rewriteInfoOut second) statements: (Array with: node) returns: false)). ]. ] ]. ]. (node isMemberOf: BlockNode) ifTrue: [ (node rewriteInfoOut notNil) ifTrue: [ self rewriteBlockNode: node inParentNode: parent arguments: (Array with: (TempVariableNode new name: node rewriteInfoOut second index: 0 type: 2)) statements: node statements returns: false. ]. ]. ! Item was added: + ----- Method: Object>>times:repeat: (in category '*Etoys-Squeakland-Tweak-Kedama') ----- + times: aNumber repeat: aBlock + + aNumber timesRepeat: [aBlock value: self] + ! Item was changed: ----- Method: SpeechBubbleMorph>>balloon (in category 'accessing') ----- balloon ^balloon ifNil: [ | balloonForm | + balloonForm := Form extent: (self extent - (0 @ self tailHeight) max: 1@1) depth: 16. - balloonForm := Form extent: self extent - (0 @ self tailHeight) depth: 16. self drawBalloonOn: balloonForm getCanvas in: balloonForm boundingBox. balloonForm floodFill: self color at: balloonForm center. balloon := (SketchMorph withForm: balloonForm). ]! |
Free forum by Nabble | Edit this page |