DEV Community

Cover image for .NET CIL interpreter in F#
Sergey Todyshev
Sergey Todyshev

Posted on

1

.NET CIL interpreter in F#

I've prepared compact .NET CIL interpreter called Fint in pure F# for NskDotNet Meetup #6.

It can run C# programs with the following features at this point:

  • all control flow statements (if, for, switch, etc)
  • arithmetic operations including bitwise one
  • boolean algebra operators
  • string concatenation
  • static function calls
  • Console.WriteLine calls

It can be easily extended with other features.

Some code in this project is just ported from PageFX project I wrote about recently.

It would be nice to try porting Fint to JavaScript using Fable and run .NET binary code right in a browser.
Later we can try to port Roslyn C# compiler to WASM with Blazor compiler and build online tutorial that:

  • compiles small C# program to .NET PE file in browser
  • runs .NET PE file in browser
  • shows CIL code for given method
  • provides debugging experience of CIL instruction set

This could be a great web resource to help learning .NET code at low-level.

If you like Fint repo please stargaze it on github.

Here is a recording of my presentation. Sorry for speaking so boring ๐Ÿ˜„

Enjoy! EOF ๐Ÿ˜„

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
sergeyt profile image
Sergey Todyshev โ€ข

I am thinking to port this to Rust. Then it can be easily compiled into WebAssembly and run in browser

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay