Giter VIP home page Giter VIP logo

dotnow-interpreter's Introduction

dotnow Interpreter

License: MIT

A pure C# CIL interpreter designed to load and execute managed code on AOT/IL2CPP (Unity) platforms.

Being able to run dynamically loaded code can be a great thing, especially in game development as it allows for modding support and much more. Combine it iwith a runtime compiler like Roslyn and the possibilities are practically endless. Unfortunately, it is not possible to natviley load code dynamically if AOT is used, since JIT is not available. dotnow was created to make this possible by interpreting the managed CIL instructions in software, and replicating the runtime environment.

Project Goals

The end goal is to create a performant and feature complete runtime for managed code with support for AOT platforms including IL2CPP (Unity).

  • Full support for generic types and members.
  • Full reflection of interpreted types, as if they were loaded nativley.
  • Implement all CIL instructions and runtime features.
  • Support for inheritance of interop types (via proxy bindings).
  • Execute code as fast as is reasonably possible.
  • Support for debugging.

Dependencies

  • Mono.Cecil (0.10.0.0) or newer. Used to read managed assembly images into memory.

Limitations

dotnow is still very in early development although it is able to run most CIL code in its current form. There are however a few inherant limitations to the project:

  • In order for user types to derive from interpreted types defined in external assemblies, a proxy binding must be created ahead of time.
  • Invoking interop methods can be very slow unless a direct call binding is implemented ahead of time.
  • Code stripping can cause issues in builds. You can use link.xml or direct call bindings to get around the problem.
  • AOT code for some generic types may not be emitted at build, causing runtime errors. For example If 'List`(int)' is not used inside the main project at any time but runtime interpreted code does use this generic type, it will cause a runtime exception stating (correctly) that no AOT code was generated. The workarounds for this are nasty hacks at the moment and involve declaring variables for all potential generic combinations ahead or time.

Getting Started

Take a look at the wiki to get started.

Demos

  • Snake: A simple snake game that is dynamically loaded and interpreted on Unity WebGL with IL2CPP backend. Demo scripts use arrays, collections, generics, enums and derive from MonoBehaviour. Find the demo game here. Find the demo project in 'ExampleProjects/SnakeExample' (Game runtime scripts - dynamically loaded) and 'Assets/Examples/Snake' (Loading and setup code).

Sponsors

You can sponsor this project to help it grow ❤️ Sponsor

dotnow-interpreter's People

Contributors

scottyboy805 avatar lr-k avatar skutteoleg avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.