thautwarm / DianaVM

Diana... 🥳🥳🥳Diana, suki🤤🤤🤤
BSD 3-Clause "New" or "Revised" License
11 stars 0 forks source link

DianaScript

Features

DianaScript is a minimal programming language that aims at interfacing with .NET runtime, especially for game developement in Unity.

  1. No System.Reflection.
  2. Limited APIs provided by the developers. Safe to game users.
  3. C#-friendly interops.
  4. Python-like object system

Usage

You should firstly compile the source code of Ch-lang(创创语言) to Diana bytecode using the compiler written in Python:

python -m dianascript runtests/b.ch --out runtests/b.ran

Then you load the bytecode using Diana VM:

public static int Main(String[] args)
{
    Console.WriteLine("path: " + args[0]);
    var dvm = new DVM();
    var loader = new AWorld.CodeLoder(args[0]);
    var metaInd = loader.LoadCode();    
    var global = GlobalNamespace.GetGlonal();
    dvm.exec_block(metaInd, global);    
    return 0;

}

An exception will get raised to .NET side if it is not handled in DianaScript/DVM. The exception type is compatible to both runtime.

Contributions

You can help us in many aspects:

  1. Implementation for the whole object system.

    For instance, if you want to add + operator support for specific builtin types(bool, int, float, list, dict, None, tuple...), just like __add__ for diana integers; you should

    1. add "add" to ExceptionList1["DInt"]

    2. implement the interface at a proper place:

      public DObj __add__(DObj a)
  2. Writing tests for the language, just like what I did(of course not enough) at test.ch.

  3. Language design: should we use arbitrary-precision integers? Or, should we use dicts as sets, etc..

  4. 绝赞摆烂中