|
1 | 1 | Class { |
2 | 2 | #name : 'FASTPythonCFGVisitor', |
3 | | - #superclass : 'Object', |
4 | | - #traits : 'FASTTCFGVisitor + FASTPyTVisitor', |
5 | | - #classTraits : 'FASTTCFGVisitor classTrait + FASTPyTVisitor classTrait', |
| 3 | + #superclass : 'FASTPythonVisitor', |
| 4 | + #traits : 'FASTTCFGVisitor', |
| 5 | + #classTraits : 'FASTTCFGVisitor classTrait', |
6 | 6 | #category : 'FAST-Python-Tools-CFG/DataFlow', |
7 | 7 | #package : 'FAST-Python-Tools', |
8 | 8 | #tag : 'CFG/DataFlow' |
9 | 9 | } |
| 10 | + |
| 11 | +{ #category : 'visiting' } |
| 12 | +FASTPythonCFGVisitor >> visitFASTPyExpression: aFASTPyExpression [ |
| 13 | + "We ignore expressions that are not in a statement block" |
| 14 | + |
| 15 | + aFASTPyExpression isExpressionStatement ifTrue: [ ^ super visitFASTPyExpression: aFASTPyExpression ] |
| 16 | +] |
| 17 | + |
| 18 | +{ #category : 'visiting' } |
| 19 | +FASTPythonCFGVisitor >> visitFASTPyFunctionDefinition: aFunction [ |
| 20 | + |
| 21 | + super visitFASTPyFunctionDefinition: aFunction. |
| 22 | + |
| 23 | + cfgBuilder basicBlocks first isStart: true. |
| 24 | + |
| 25 | + "case where method has no return instruction (void signature)" |
| 26 | + cfgBuilder currentBlock ifNotNil: [ cfgBuilder chainPendingBlocksTo: FASTNullBlock new ] |
| 27 | +] |
| 28 | + |
| 29 | +{ #category : 'visiting' } |
| 30 | +FASTPythonCFGVisitor >> visitFASTTStatement: aStatement [ |
| 31 | + |
| 32 | + | currentBlock | |
| 33 | + cfgBuilder currentBlock ifNil: [ cfgBuilder newBasicBlock: FASTBasicBlock ]. |
| 34 | + |
| 35 | + currentBlock := cfgBuilder currentBlock. |
| 36 | + |
| 37 | + super visitFASTTStatement: aStatement. |
| 38 | + |
| 39 | + "only adding statement if no expression made changes to the CFG" |
| 40 | + currentBlock = cfgBuilder currentBlock ifTrue: [ cfgBuilder currentBlock addStatement: aStatement ] |
| 41 | +] |
| 42 | + |
| 43 | +{ #category : 'visiting' } |
| 44 | +FASTPythonCFGVisitor >> visitFASTTStatementBlock: aFASTTStatementBlock [ |
| 45 | + "We do not consider the block as a statemert." |
| 46 | + |
| 47 | + self visitCollection: aFASTTStatementBlock statements |
| 48 | +] |
0 commit comments