File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1933,17 +1933,17 @@ FASTPythonCFGTest >> testFunctionWithTry [
19331933 self assert: tryBlock isConditional.
19341934 self assert: tryBlock isTry.
19351935 self deny: tryBlock isFinal.
1936- self assert: tryBlock statements size equals: 1 .
1936+ self assert: tryBlock statements size equals: 3 .
19371937 self assert: (tryBlock statements first isOfType: FASTPyCall ).
1938+ self assert: (tryBlock statements second isOfType: FASTPyCall ).
1939+ self assert: (tryBlock statements third isOfType: FASTPyCall ).
19381940
19391941 self assert: ((tryBlock patterns at: 1 ) isOfType: FASTPyIdentifier ).
19401942 exceptBlock := tryBlock nextBlocks at: 1 .
19411943 self deny: exceptBlock isConditional.
19421944 self deny: exceptBlock isFinal.
1943- self assert: exceptBlock statements size equals: 3 .
1945+ self assert: exceptBlock statements size equals: 1 .
19441946 self assert: (exceptBlock statements first isOfType: FASTPyCall ).
1945- self assert: (exceptBlock statements second isOfType: FASTPyCall ).
1946- self assert: (exceptBlock statements third isOfType: FASTPyCall ).
19471947
19481948 self assert: (tryBlock patterns at: 2 ) isNil.
19491949 lastBlock := tryBlock nextBlocks at: 2 .
Original file line number Diff line number Diff line change 22 #name : ' FASTCFGAbstractMultipleConditionBlock' ,
33 #superclass : ' FASTCFGAbstractConditionalBlock' ,
44 #instVars : [
5- ' isFull' ,
65 ' blocksMap'
76 ],
87 #category : ' FAST-Python-Tools-CFG/DataFlow' ,
@@ -39,20 +38,7 @@ FASTCFGAbstractMultipleConditionBlock >> addPattern: aFASTNode [
3938FASTCFGAbstractMultipleConditionBlock >> initialize [
4039
4140 super initialize.
42- blocksMap := OrderedDictionary new .
43- isFull := false
44- ]
45-
46- { #category : ' accessing' }
47- FASTCFGAbstractMultipleConditionBlock >> isFull [
48- " In the case of a switch, we cannot know with just the node so the algo will tell us when it is full at the closing of the switch.."
49-
50- ^ isFull
51- ]
52-
53- { #category : ' accessing' }
54- FASTCFGAbstractMultipleConditionBlock >> isFull: anObject [
55- isFull := anObject
41+ blocksMap := OrderedDictionary new
5642]
5743
5844{ #category : ' accessing' }
Original file line number Diff line number Diff line change 11Class {
22 #name : ' FASTCFGSwitchBlock' ,
33 #superclass : ' FASTCFGAbstractMultipleConditionBlock' ,
4+ #instVars : [
5+ ' isFull'
6+ ],
47 #category : ' FAST-Python-Tools-CFG/DataFlow' ,
58 #package : ' FAST-Python-Tools' ,
69 #tag : ' CFG/DataFlow'
@@ -18,6 +21,25 @@ FASTCFGSwitchBlock >> includesPattern: aPattern [
1821 ^ self patterns anySatisfy: [ :pattern | pattern isSameAsCFGCasePattern: aPattern ]
1922]
2023
24+ { #category : ' initialization' }
25+ FASTCFGSwitchBlock >> initialize [
26+
27+ super initialize.
28+ isFull := false
29+ ]
30+
31+ { #category : ' accessing' }
32+ FASTCFGSwitchBlock >> isFull [
33+ " In the case of a switch, we cannot know with just the node so the algo will tell us when it is full at the closing of the switch.."
34+
35+ ^ isFull
36+ ]
37+
38+ { #category : ' accessing' }
39+ FASTCFGSwitchBlock >> isFull: anObject [
40+ isFull := anObject
41+ ]
42+
2143{ #category : ' testing' }
2244FASTCFGSwitchBlock >> isSwitch [
2345
Original file line number Diff line number Diff line change 66 #tag : ' CFG/DataFlow'
77}
88
9+ { #category : ' testing' }
10+ FASTCFGTryBlock >> isFull [
11+ " I am full when I have a branch pointing what happens if there is no exception caught and this branch has a nil pattern."
12+
13+ ^ blocksMap
14+ at: nil
15+ ifPresent: [ :value | value isNotNil ]
16+ ifAbsent: [ false ]
17+ ]
18+
919{ #category : ' testing' }
1020FASTCFGTryBlock >> isTry [
1121
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ FASTPythonCFGVisitor >> visitFASTPyElifClause: anElifClause [
7878 self visitFASTTStatementBlock: anElifClause
7979]
8080
81+ { #category : ' visiting' }
82+ FASTPythonCFGVisitor >> visitFASTPyExceptClause: anExceptClause [
83+
84+ | try |
85+ try := context top conditional.
86+ self assert: try isTry.
87+
88+ try addPattern: anExceptClause expression.
89+
90+ self visitFASTTStatementBlock: anExceptClause
91+ ]
92+
8193{ #category : ' visiting' }
8294FASTPythonCFGVisitor >> visitFASTPyExpression: aFASTPyExpression [
8395 " We ignore expressions that are not in a statement block"
@@ -134,13 +146,11 @@ FASTPythonCFGVisitor >> visitFASTPyMatchStatement: aMatchStatement [
134146FASTPythonCFGVisitor >> visitFASTPyTryStatement: aTryStatement [
135147
136148 self buildBlockIfNeeded.
137-
138149 self visitCollection: aTryStatement statements.
139150
140- self buildAndUse: FASTCFGTryBlock during: [
141- self visitFASTPyTWithElseClause: aTryStatement.
142-
151+ self buildAndUseTryDuring: [
143152 self visitCollection: aTryStatement excepts.
153+ self visitFASTPyTWithElseClause: aTryStatement.
144154 self visitEntity: aTryStatement finally ]
145155]
146156
Original file line number Diff line number Diff line change @@ -88,9 +88,9 @@ FASTTCFGUtility >> buildAndUseSwitchDuring: aBlock [
8888{ #category : ' running' }
8989FASTTCFGUtility >> buildAndUseTryDuring: aBlock [
9090
91- ^ self buildAndUse: FASTCFGTryBlock during: [ :switch |
92- aBlock cull: switch .
93- switch isFull: true ]
91+ ^ self buildAndUse: FASTCFGTryBlock during: [ :try |
92+ aBlock cull: try .
93+ try isFull ifFalse: [ try addPattern: nil ] ]
9494]
9595
9696{ #category : ' running' }
You can’t perform that action at this time.
0 commit comments