Internal Program Representation (IPR)

repository·main·Indexed 42 days ago

https://github.com/gabrieldosreis/ipr

A C++ library providing data structures for the semantic analysis and transformation of C++ programs, based on research by Bjarne Stroustrup and Gabriel Dos Reis. It utilizes a strict separation between its public interface in <ipr/interface> and internal implementations in <ipr/impl> to ensure stability and efficiency.

Tokens
527
Snippets
0
Records
5
Agent score
4%

What's inside IPR

  1. Overview of Internal Program Representation (IPR)

    main

    The IPR (Internal Program Representation) is an open-source library providing core data structures for the semantics-based analysis and transformation of C++ programs. It is designed to provide a principled, complete, and efficient representation of C++ code.

    For a deep dive into the design principles and the general philosophy of the IPR, refer to the paper: ["A Principled, Complete, and Efficient Representation of C++">(http://www.stroustrup.com/macis09.pdf)].

  2. Use the IPR public interface

    main

    The IPR library follows a strict separation between its public interface and its internal implementation to ensure stability and allow for optimized implementations by different tools or compilers.

    • Public Interface: Use the abstract classes located in <ipr/interface> to interact with the library. By restricting your code to these interfaces, you ensure compatibility even if the underlying implementation changes.
    • Implementations: The library provides reference implementations in <ipr/impl>. However, different tools may provide their own optimized versions of the same interface classes (e.g., an ipr::Fundecl might be implemented differently for a non-defining declaration versus a function definition).

    Best Practice: Always interact with the library through the headers in <ipr/interface> to shield your code from implementation-specific details.

  3. Use logical connectives in C++

    main

    When writing C++ code in this project, use the textual operator keywords for logical operations instead of symbolic operators to improve readability:

    • Use not for logical negation (instead of !)
    • Use and for logical conjunction (instead of &&)
    • Use or for logical disjunction (instead of ||)
  4. Follow factory function naming conventions

    main

    When naming factory functions, distinguish between functions that return existing/cached data and those that allocate new memory/structures:

    • Use the get_xxx prefix for factory functions that return the same output for the same inputs (idempotent/cached).
    • Use the make_xxx prefix for factory functions that always return fresh, newly allocated structures.