File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -985,7 +985,7 @@ FASTPythonCFGTest >> testFunctionWithWhileWithBreakInIfThen2 [
985985 break
986986 c()
987987 d()' .
988- self skip. " To fix "
988+
989989 self assert: startBlock isConditional.
990990 self deny: startBlock isFinal.
991991 self assert: startBlock statements size equals: 1 .
@@ -1015,7 +1015,7 @@ FASTPythonCFGTest >> testFunctionWithWhileWithBreakInIfThen2 [
10151015
10161016 nullBlock := startBlock nextFalseBlock.
10171017 self assert: nullBlock isNullBlock.
1018- self assert: endOfWhile nextBlock equals: nullBlock.
1018+ self assert: thenBlock nextBlock equals: nullBlock.
10191019 self assert: nullBlock isFinal
10201020]
10211021
@@ -1273,7 +1273,7 @@ FASTPythonCFGTest >> testFunctionWithWhileWithIfInElif [
12731273 else:
12741274 e()
12751275 f()' .
1276- self skip. " Not working for now because break are not well managed "
1276+
12771277 self assert: startBlock isConditional.
12781278 self deny: startBlock isFinal.
12791279 self assert: startBlock statements size equals: 1 .
Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ FASTCFGAbstractBlock >> allFollowingBlocks [
2929 ^ self deep: #nextBlocks collect: #yourself
3030]
3131
32+ { #category : ' testing' }
33+ FASTCFGAbstractBlock >> endsWithBreakStatement [
34+
35+ ^ self subclassResponsibility
36+ ]
37+
3238{ #category : ' initialization' }
3339FASTCFGAbstractBlock >> initialize [
3440
@@ -91,6 +97,15 @@ FASTCFGAbstractBlock >> previousBlocks [
9197 ^ previousBlocks
9298]
9399
100+ { #category : ' asserting' }
101+ FASTCFGAbstractBlock >> shouldBreakInContext: context [
102+ " I should breack this node if it's a breack and that we are currently visiting a loop. This node is breaking the loop in all cases of the current branch. "
103+
104+ self endsWithBreakStatement ifFalse: [ ^ false ].
105+
106+ ^ context anySatisfy: #isLoop
107+ ]
108+
94109{ #category : ' accessing' }
95110FASTCFGAbstractBlock >> sourceCode [
96111
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ FASTCFGNullBlock >> addNextBlock: aBlock [
1212 self error: ' A null block cannot have a next block since it represent a virtual block merging all exit points if the exit point is not unique.'
1313]
1414
15+ { #category : ' testing' }
16+ FASTCFGNullBlock >> endsWithBreakStatement [
17+ " I cannot contain a breack"
18+
19+ ^ false
20+ ]
21+
1522{ #category : ' testing' }
1623FASTCFGNullBlock >> isNullBlock [
1724
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ FASTTCFGUtility >> managePreviousBlocksOf: newBlock [
143143
144144 topContext currentBlocks ifEmpty: [ topContext conditional addNextBlock: newBlock ] ifNotEmpty: [ :blocksAtScope |
145145 (blocksAtScope flatCollect: #withAllFollowingBlocks )
146- reject: [ :block | block isFull ]
146+ reject: [ :block | block isFull or : [ block shouldBreakInContext: context ] ]
147147 thenDo: [ :block | block addNextBlock: newBlock ] ]
148148]
149149
You can’t perform that action at this time.
0 commit comments