The Inbox: EToys-jl.223.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: EToys-jl.223.mcz

commits-2
A new version of EToys was added to project The Inbox:
http://source.squeak.org/inbox/EToys-jl.223.mcz

==================== Summary ====================

Name: EToys-jl.223
Author: jl
Time: 31 August 2016, 2:30:13.751376 pm
UUID: 05f8b1d1-a505-a248-9a2a-e51f7e0c1689
Ancestors: EToys-jl.222

Implement timesRepeat: tiles for Kedama

=============== Diff against EToys-jl.222 ===============

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: {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]
+ !