Working on similar project (SharpLang)

Oct 24, 2014 at 3:29 AM
Hello,

Someone just pointed me out your project, seems nice! Very happy to see such projects taking off.
I am actually working on something similar: SharpLang.

It seems the way you generate code is quite different than what I do, but still, if you think there is any area where part of the code or library we use can be shared and we could collaborate, feel free to let me know!

Current area of work on my side (aside general improvements) are reflection, and later PInvoke and GC.

Good luck with your project!
Virgile
Coordinator
Oct 25, 2014 at 11:25 AM
Edited Oct 25, 2014 at 11:42 AM
Hi Virgile

Thank youf for your post. I have seen your project. But I didn't have time to look carefully at it. I will have a look again.


Alex

EDIT: I could not try it, I do not have VS 2013

PS. Do you have binaries which I can try?
Oct 25, 2014 at 3:22 PM
Hi,

In a nutshell (so you don't have to dig in the code), it works by taking the MSIL bytecode (.dll) and convert that into LLVM bitcode using LLVM C API (one .bc for each .dll).

Codegen is now good enough to be able to convert all of Mono mscorlib, System, System.Core, System.Windows.Forms etc... without choking.
Basically, what is already done:
  • Support most opcodes
  • VTable (virtual calls, static fields, etc...)
  • Static ctor
  • Generics
  • Exception handling
  • Interfaces (no covariance yet)
  • is/as etc...
  • DWARF debug info for GDB debugging
  • StructLayout
  • Delegates (incl. MulticastDelegate)
  • Non-marshalled PInvoke, etc...)
What's left:
  • Reflection (already making good progress -- in a private branch, not available yet)
  • Covariance/contravariance
  • Marshalling
  • corlib internal native methods
  • NullReferenceException (platform specific)
  • Vararg
  • Port to new platforms (Linux, Mac, emscriptem, etc...)
    etc...
All the test code in this folder is known to work as well: https://github.com/xen2/SharpLang/tree/master/src/SharpLang.Compiler.Tests/tests

Unfortunately no binaries yet, will try to sort that out soon (I was waiting for more real-case scenario to work, otherwise it doesn't make sense anyway).
I will let you know as soon as they are available!

Virgile
Coordinator
Oct 25, 2014 at 5:33 PM
I see you have done very big progress, I was not planning doing Reflection at all (but did something for Reflection). I was considering C# native compiler as "pure compiler" such as C++ compiler. I do not GDB debugging support as well (but was thinking about doing it).

recently I have managed to compile generic vertual methods. typeof Now I am rewriting implementation of Single Dimention Arrays. I do not support MultiDelegates but it will be done.

PS.

Alex
Oct 26, 2014 at 8:34 PM
There is also another tool I was looking at a little while ago. I never ended up compiling it and testing it out though. It works by decompiling your .net application/DLL and then translating it into C++ with AST transformations and then recompiling it into a native assembly. I am not too sure how well it works though. https://github.com/AlexAlbala/Alter-Native
Oct 29, 2014 at 3:26 PM
Would you mind to show how the generated LLVM code would be compiled under Linux, Android etc?

Thanks
Coordinator
Oct 30, 2014 at 9:24 AM
I will update projects soon. There I have included Android project which is compiled by C# native compiler (not everything only core libraries)

but in short. You do compile it absolutely the same way you do it for windows.

for Android
1) you need to get .LL file
2) then compile it to .O (object file) (Android NDK has "llc")
3) using g++ create file .A (lib file)
4) include it into "ndk project" and reference it in native code
Nov 2, 2014 at 5:29 PM
Any news here?
Coordinator
Nov 3, 2014 at 8:20 AM
preparing an update, it will take around a week.