-
Notifications
You must be signed in to change notification settings - Fork 62
Passes
Passes get a prebuilt CPG that at least contains the CPG-AST and output a modified graph. Their purpose is to extend the syntactic representation of code with additional nodes and edges to represent the semantics of the program. Passes can be executed in sequence, where the output of the previous pass serves as input of the next pass.
The user of the cpg library can implement her own passes. Each pass needs to extend the class Pass
and implement its base function accept(TranslationResult result)
. The remaining structure of the pass is free to be designed by the implementer.
A newly created pass has to be registered with the TranslationManager
through its builder by calling TranslationConfiguration.builder(). ... .registerPass(...)
.
A preexisting pass can be modified by extending it and overwriting its functions. For this purpose, all member functions of existing library passes have the visibility protected
. Depending on the modified pass, internal constructs have to be respected.
For example, the EvaluationOrderGraphPass
uses an internal handle structure. When extending this pass, it is necessary to add handlers of new Node types to the internal handler map. If a developer needs to override an exisiting handler, the handle has to be implemented with the same signature to use the polymorphism feature. Additionally the mapping of node type -> handler
needs to be replaced by a new entry node type -> overridden
handler.