You can:

  * Execute shell commands at compile-time
  * read file at compile-time
  * do computation at compile-time (be aware that this is done in a VM that is 
much slower than compiled-code and not suitable for CPU-intensive computation)



But what you want is basically a JIT.

Here is an example JIT where I translate brainfuck programs to assembly:

  * 
[https://github.com/mratsim/jitterland/blob/master/bfVM_v03_jit.nim](https://github.com/mratsim/jitterland/blob/master/bfVM_v03_jit.nim)



Alternatively you can just use an interpreter.

Some inspiration in C/C++

  * [https://github.com/codeplea/tinyexpr](https://github.com/codeplea/tinyexpr)
  * [https://github.com/zserge/expr](https://github.com/zserge/expr)



Also I'm currently implementing a compiler for deep learning with SIMD support 
(and GPU and parallelism later). For now I'm only supporting compile-time code 
generation but later I will also add runtime code generation, probably via LLVM 
JIT capabilities: 
[https://github.com/mratsim/compute-graph-optim](https://github.com/mratsim/compute-graph-optim)

Reply via email to