← Back to articles

LSL to C#

Instead of compiling LSL directly, I first translate it to C# — simpler for other OpenSim developers to contribute to, and the same translator can double as a learning tool for people moving from LSL to C#. Written in less than a day with regex and a couple of passes.

Tedd

To compile LSL code I figured the best way would be to first translate it into C#.
Since LL will be supporting both LSL and C# we can use the same translator on a web page or similar to help people who know LSL to understand C#.
Also it is much simpler for other developers on OpenSim to contribute to the code when its C# instead of MSIL.

The translator uses some regex and a couple of byte-by-byte passes over the code. Written in less than a day, no big magic involved.

In-memory compile to assembly (that will be cached for later reuse).
Assembly is dynamically loaded in same way as LSO.

The script inherits from a LSL_BaseClass.cs that contains all the builtin-functions like llSay(), llWhisper, etc.

Written by Tedd · Oslo, Norway

Follow the journal via RSS