"Every problem in Computer Science can be solved with a level of indirection and every problem in Software Engineering can be solved with a step of code-generation"

Build→It is a lightweight1 type-based2 multi-stage programming3 framework in C++. Besides extracting expressions and statements, Build→It supports extracting rich data-dependent control flow like if-then-else conditions and for and while loops using its novel re-execution strategy to explore all control-flow paths in the program.
Build→It turns -
dyn_var<int> foo(dyn_var<int> x, int &iter, int &max) {
  dyn_var<int> sum = 0;
  for (static_var<int> i = 1; i < iter; i++) {
    if (i * x < max)
      sum = sum + i * x;
  return sum;
int iter = 3;
int max = 10;
context.extract_function_ast(foo, "foo_3_10", iter, max);
into -
int foo_3_10(int arg0) {
  int var0 = 0;
  if (1 * arg0 < 10)
    var0 = var0 + 1 * arg0;
  if (2 * arg0 < 10)
    var0 = var0 + 2 * arg0;
  return var0;
Build→It is available opensource on GitHub under the MIT license. Many more samples are available in the samples/ directory including turning an interpreter for BrainFuck into a compiler using Futamura projections.

1. Build→It uses a purely library based approach and does not require any special compiler modifications making it extremely portable and easy to integrate into existing code bases. Using Build→It is as easy as including a few header files and linking against the Build→It library.
2. Build→It uses the declared types of variables and expressions to decide the binding time. Build→It adds 2 new generic types - static_var<T> and dyn_var<T> which lets the user program with 2 stages. These types can be nested arbitrarily to produce code for more stages.
3. What exactly is multi-stage programming and why it is important for high-performance DSLs is explained here.

If you think this work is useful for your research, please star the repository!