C++ Translation
AssetRipper.Translation.LlvmIR
This tool translates LLVM IR to .NET CIL, enabling conversion of C++ code to C#.
How it works
Clang allows compiling to LLVM IR instead of more traditional outputs like static libraries. This intermediate representation is simple enough to enable robust translation of each individual instruction to an equivalent CIL instruction, or a short series of them. Then, some basic optimizations are applied to improve output quality, and ILSpy decompiles it to pretty C#.
Not emulation
Unlike emulation, this is real translation. The instructions aren't being run on a simulated CPU or anything like that. The generated output runs nearly as fast as the native compilation (C# is a slightly slower language than C++).
AssetRipper.Conversions.FastPng
This C# port of fpng is an example of my tool's capabilities. The library writes PNG files quickly and efficiently, much faster than alternatives like System.Drawing.Common.
Hebron
I also did some work on Hebron, a C translation project.
Differences from AssetRipper.Translation.LlvmIR
Hebron does source translation, which has benefits and drawbacks.
- Comments and local variable names are maintained.
- Compiler errors are possible.
- C only. C++ isn't supported.