1818 ContainsDigitPredicate ,
1919 ContainsSpecialPredicate ,
2020 EmptyBytesPredicate ,
21+ FunctionErrorPredicate ,
2122)
2223from sflkit .analysis .spectra import Line , Function , Loop , DefUse , Length
2324from sflkit .model .scope import Scope
@@ -429,6 +430,29 @@ def get_analysis(self, event, scope: Scope = None) -> List[AnalysisObject]:
429430 return self .objects [key ][:]
430431
431432
433+ class FunctionErrorFactory (AnalysisFactory ):
434+ def __init__ (self ):
435+ super ().__init__ ()
436+ self .function_mapping = dict ()
437+
438+ def get_analysis (self , event , scope : Scope = None ) -> List [AnalysisObject ]:
439+ if event .event_type == EventType .FUNCTION_ENTER :
440+ self .function_mapping [event .function_id ] = event .line
441+ if event .event_type in (EventType .FUNCTION_ERROR , EventType .FUNCTION_EXIT ):
442+ line = self .function_mapping [event .function_id ]
443+ key = (
444+ FunctionErrorPredicate .analysis_type (),
445+ event .file ,
446+ line ,
447+ event .function_id ,
448+ )
449+ if key not in self .objects :
450+ self .objects [key ] = FunctionErrorPredicate (
451+ event .file , line , event .function
452+ )
453+ return [self .objects [key ]]
454+
455+
432456analysis_factory_mapping = {
433457 AnalysisType .LINE : LineFactory ,
434458 AnalysisType .BRANCH : BranchFactory ,
@@ -446,4 +470,5 @@ def get_analysis(self, event, scope: Scope = None) -> List[AnalysisObject]:
446470 AnalysisType .VARIABLE : VariableFactory ,
447471 AnalysisType .SCALAR_PAIR : ScalarPairFactory ,
448472 AnalysisType .FUNCTION : FunctionFactory ,
473+ AnalysisType .FUNCTION_ERROR : FunctionErrorFactory ,
449474}
0 commit comments