Package org.ek9lang.compiler.common
Class CodeFlowMap
java.lang.Object
org.ek9lang.compiler.common.CodeFlowMap
- All Implemented Interfaces:
CodeFlowAnalyzer
- Direct Known Subclasses:
UninitialisedVariableAnalyzer
,UnSafePropertyAccessAnalyzer
Designed to be used in a transient manner when interacting with variables.
This is typically through the flow of variable use within a bounded scope.
For example within a function or a method.
It is transient in the sense that it does not live beyond the parsing of a specific source file.
So it is not attached to any scopes or symbols. Instead, those scopes and symbols are used as keys to be
able to access specific meta-data that is recorded/accessed during flow of the ek9 code.
This approach has been taken to ensure that memory is not excessively used and the scope/symbol concepts are not mixed with what is in effect a sort of interpreter assessment. In addition, the nature of these checks means that it is sort of necessary to almost interpret and hold state for variables the flow is followed through the code block.
While the initial reason for this was assessment of variables being initialised or not within branching structures. It will probably also be useful for the checking of Optional (is-set) and Result ('ok'/'error'). It may even be extendable to assess if conditionals are always true/false and for assessing cyclo metric complexity.
This approach has been taken to ensure that memory is not excessively used and the scope/symbol concepts are not mixed with what is in effect a sort of interpreter assessment. In addition, the nature of these checks means that it is sort of necessary to almost interpret and hold state for variables the flow is followed through the code block.
While the initial reason for this was assessment of variables being initialised or not within branching structures. It will probably also be useful for the checking of Optional (is-set) and Result ('ok'/'error'). It may even be extendable to assess if conditionals are always true/false and for assessing cyclo metric complexity.
-
Constructor Summary
ModifierConstructorDescriptionprotected
CodeFlowMap
(Predicate<ISymbol> isVariableToBeChecked, Predicate<SymbolAccess> meetsCriteria, Consumer<SymbolAccess> markAsMeetingCriteria) -
Method Summary
Modifier and TypeMethodDescriptionboolean
doesSymbolMeetAcceptableCriteria
(ISymbol identifierSymbol, IScope inScope) Check if a variable meets the criteria of being acceptable.Just provide a list of variables that have not been marked as meeting acceptable criteria in the scope.void
markSymbolAsMeetingAcceptableCriteria
(ISymbol identifierSymbol, IScope inScope) Ensures that an identifier symbol is now marked as meeting the criteria of being acceptable.void
recordSymbol
(ISymbol identifierSymbol, IScope inScope) Records a symbol against the specific scope if it a variable to be analysed.
-
Constructor Details
-
CodeFlowMap
protected CodeFlowMap(Predicate<ISymbol> isVariableToBeChecked, Predicate<SymbolAccess> meetsCriteria, Consumer<SymbolAccess> markAsMeetingCriteria)
-
-
Method Details
-
getSymbolsNotMeetingAcceptableCriteria
Just provide a list of variables that have not been marked as meeting acceptable criteria in the scope.- Specified by:
getSymbolsNotMeetingAcceptableCriteria
in interfaceCodeFlowAnalyzer
-
doesSymbolMeetAcceptableCriteria
Check if a variable meets the criteria of being acceptable.- Specified by:
doesSymbolMeetAcceptableCriteria
in interfaceCodeFlowAnalyzer
-
recordSymbol
Records a symbol against the specific scope if it a variable to be analysed.- Specified by:
recordSymbol
in interfaceCodeFlowAnalyzer
-
markSymbolAsMeetingAcceptableCriteria
Ensures that an identifier symbol is now marked as meeting the criteria of being acceptable.- Specified by:
markSymbolAsMeetingAcceptableCriteria
in interfaceCodeFlowAnalyzer
-