Ls2csc

From ismods.com: dedicated to promoting white hat, EULA-compliant Inner Space and LavishScript mods
Jump to: navigation, search

ls2csc is a C# compiler that outputs LS2IL.

Getting Started with ls2csc

First, you will need the LS2 Module SDK.

ls2csc is built with and requires Microsoft's Roslyn compiler toolkit. Because Roslyn is currently in the CTP (preview) phase of development, it is not meant for use in a release environment, and so we are currently instructed not to redistribute the necessary parts ourselves. Roslyn is designed to be used with Visual Studio 2012, and requires Visual Studio 2012 to be installed, even if you will not be using the related features of Roslyn.

So your requirements so far are:

  1. LS2 Module SDK
  2. Roslyn compiler toolkit (you must have this installed to run ls2csc)
  3. Visual Studio 2012 (you must have this installed to install Roslyn) -- a free "express" version should be sufficient

Create HelloWorld.cs

HelloWorld.cs
namespace HelloWorld
{
   class Program
   {
      static void Main()
      {
          System.Console.WriteLine("Hello, World!");
      }
   }
}

Build HelloWorld.cs into HelloWorld.LS2IL

ls2csc.exe is in the LS2Module\sdk1\bin folder. For now it is left to the reader to know how to access it!


Syntax cheat sheet
ls2csc.exe --help
C# Compiler for LavishScript 2.0 Virtual Machine
- Building for LS2IL version 0.9.20121123.1
Usage: ls2csc -i input.cs -o output.il
  -i, --input=file           Input file
  -r, --reference=file       Reference file
  -o, --output=file          Output file
  -h, -?, --help             Show this help and exit
  -s, --silent               Silence, 1 per level
Build HelloWorld.cs into HelloWorld.LS2IL
ls2csc.exe -i HelloWorld.cs -o HelloWorld.LS2IL

Executing HelloWorld.LS2IL with ls2il.exe

Simple enough...
ls2il.exe HelloWorld.LS2IL

Executing HelloWorld.LS2IL with Inner Space

Register, then Start
LavishScript2.RegisterScript[-ls2il,helloworld,HelloWorld.LS2IL]:Start

Note: RegisterScript will normally read bytecode (similar to a .NET assembly). The -ls2il switch tells it to build the bytecode in memory by parsing an LS2IL file.

See Also