Improved Source File and Code Structure Modelling
Closes #7 (closed) , #4 (closed)
This MR brings a significant refactoring and several extensions to the modelling of source file structure and contents in the SFG IR, as well as to the way these are constructed by the composer internally.
IR
Replace ir.source_components by ir.entities and ir.syntax
-
ir.entitiesdefines C++ code entities independently from their place in the output file syntax. It defines namespaces (including kernel namespaces and the global namespace), functions, kernels, classes and their members (methods, constructors). It also places these entities in parent-child-relationsships. -
ir.syntaxdefines the classSfgSourceFileto represent source files. It also contains the representation of the above entities as syntactic objects: namespace blocks (one namespace can have multiple blocks), entity declaration and definition nodes, class body and visibility block nodes.
Context and Composer
- The context now manages up to two source files (header and implementation)
- The composer navigates their syntax structure using a cursor
-
sfg.namespacecan now be called multiple times and be used as a context manager to enter and exit nested namespaces - Remove
sfg.define_oncesince it can no longer reliably check definitions for uniqueness - The previously fixed structure "first kernel namespaces, then all the rest" of output files is broken up - syntax elements are now placed in the order they are created in
Generator and Emission
- Replace the old file printers and emitters with a minimal, entirely syntax-oriented printer
- Update
SourceFileGeneratorto prepare the file objects for the context and correctly invoke the printer
Configuration
- Users can now define a sort key for sorting
#includes via theSfgConfig- if one is specified,clang-formatheader sorting will be automatically disabled
Edited by Frederik Hennig