Issue 3677 in pharo: A to:do: loop cannot modify the limit inside the block

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

Issue 3677 in pharo: A to:do: loop cannot modify the limit inside the block

pharo
Status: FixedWaitingToBePharoed
Owner: [hidden email]
Labels: Milestone-1.3 Type-Squeak

New issue 3677 by [hidden email]: A to:do: loop cannot modify the  
limit inside the block
http://code.google.com/p/pharo/issues/detail?id=3677

Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.184.mcz

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

Name: Compiler-nice.184
Author: nice
Time: 12 January 2011, 10:09:27.038 pm
UUID: ba12fb9c-6c57-429b-b415-1188e1faba8b
Ancestors: Compiler-nice.183

Fix DecompilerTests>>#testDecompileLoopWithMovingLimit
A to:do: loop cannot modify the limit inside the block

=============== Diff against Compiler-nice.183 ===============

Item was changed:
  ----- Method: MessageNode>>toDoFromWhileWithInit: (in category 'macro  
transformations') -----
  toDoFromWhileWithInit: initStmt
        "Return nil, or a to:do: expression equivalent to this whileTrue:"
        | variable increment limit toDoBlock body test |
        (selector key == #whileTrue:
         and: [initStmt isAssignmentNode
         and: [initStmt variable isTemp]]) ifFalse:
                [^nil].
        body := arguments last statements.
        variable := initStmt variable.
        increment := body last toDoIncrement: variable.
        (increment == nil
         or: [receiver statements size ~= 1]) ifTrue:
                [^nil].
        test := receiver statements first.
        "Note: test chould really be checked that <= or >= comparison
        jibes with the sign of the (constant) increment"
        (test isMessageNode
         and: [(limit := test toDoLimit: variable) notNil]) ifFalse:
                [^nil].
+       "The block must not overwrite the limit"
+       (limit isVariableNode and: [body anySatisfy: [:e | e  
isAssignmentNode and: [e variable = limit]]])
+               ifTrue: [^nil].
        toDoBlock := BlockNode statements: body allButLast returns: false.
        toDoBlock arguments: (Array with: variable).
        variable scope: -1.
        variable beBlockArg.
        ^MessageNode new
                receiver: initStmt value
                selector: (SelectorNode new key: #to:by:do: code: #macro)
                arguments: (Array with: limit with: increment with:  
toDoBlock)
                precedence: precedence!



Reply | Threaded
Open this post in threaded view
|

Re: Issue 3677 in pharo: A to:do: loop cannot modify the limit inside the block

pharo
Updates:
        Status: FixProposed

Comment #1 on issue 3677 by [hidden email]: A to:do: loop cannot  
modify the limit inside the block
http://code.google.com/p/pharo/issues/detail?id=3677

SLICE-Issue-3677-DoNotDecompileAWhileLoopIntoAToDoLoopWhenTheLoopWouldModifyTheLimit-nice.1


Test and fix from trunk


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3677 in pharo: A to:do: loop cannot modify the limit inside the block

pharo
Updates:
        Status: Closed

Comment #2 on issue 3677 by [hidden email]: A to:do: loop cannot  
modify the limit inside the block
http://code.google.com/p/pharo/issues/detail?id=3677

in 13126