开发者

Would it even make sense to write a C# compiler that targets LLVM?

开发者 https://www.devze.com 2022-12-20 02:43 出处:网络
I\'m thinking about writing a small C# compiler. One idea I\'ve been toying with is writing a subset of the C# grammar, say up to 2.0 for ANTLR.Then, using this to target the LLVM and write a native

I'm thinking about writing a small C# compiler.

One idea I've been toying with is writing a subset of the C# grammar, say up to 2.0 for ANTLR. Then, using this to target the LLVM and write a native code compiler for C#?

Does this idea even make sense or would this no开发者_JAVA技巧t work? Would there be any way to still make calls to the BCL?

I know there is the CCI (Common Compiler Infrastructure) which would aid me in simply generating .NET executables. But I'm curious if what I said above would be possible?


Mono already can be used with a LLVM backend.

More details in the Mono docs.

Check out the Limitations section, though.

UPDATE: as of Mono 2.8 the LLVM backend has graduated to stable. See the Mono 2.8 release notes.


Beyond Mono already cited, Microsoft is working in its own implementation called LLILC (it isn't just an experiment). So it makes much sense.


Unless you want to rewrite the entire standard library, too, it would be better to find a different project, if you're just looking for something to do. A possibility would be to write a .NET bytecode compiler or an IL assembler.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号