[Mono-list] Re: Javascript and Mono

Steve Newman steve@snewman.net
Mon, 6 Jan 2003 15:14:00 -0800

At 22:49:37 +0100 1/6/03, Jeroen Janssen <japj@xs4all.nl> wrote:

>>Yes, I think you will find that Microsoft's JScript is using helper functions.  At any rate, I don't know how you would implement J[ava]Script without them, because (unlike C#) there is a lot of potentially complex logic implied in basic operations like "+" -- see Miguel's AddTwoThings example.
>We probably need to know exactly what helperfunctions (runtime)
>Microsoft JScript contains (don't know exactly where to find it in the
>Microsoft documentation)..

There may not be any documentation.  Typically, this sort of internal runtime support is not well documented.  Someone on this list who has been digging into Microsoft's runtime support for C# and/or Visual Basic may know more.

>>In the JANET source, the files JPrimitive.cs, JObjects.cs, and JRuntime.cs are essentially all "helper code" in this sense.  The other files are only needed for compilation (and operations like "eval"), but these three files, two of which are fairly large, are needed to support the compiled code.
>Ok, so there is good 'seperation' of runtime and compiler? (or do we
>need to make this more explicit?)

Well... the one really strong dividing line is the code generator interface (JCodeGeneratorIntf.cs).  This stands more or less between the front and back ends of the compiler.

Above this interface, we have the tokenizer, parser, and command-line frontend:


Below this interface is the code generator and the support code:


So, of the compiler, only JGenCSharp.cs is tied to the runtime.  This file will need to be rewritten anyway to move to direct generation of IL code.

>>One key point is that currently, JANET generates a call to the support library for every operation.  This is because so far I've only implemented ECMAScript 3, which doesn't include type declarations.  In JScript, you may have type information at compile time, in which case the support library operations can often be optimized away.  I haven't tried to address that yet in JANET.
>In what way does the support library look like the Microsoft JScript
>'helper' functions (or not at all yet?)

Not at all, yet.  I fear that extensive reverse engineering would be required to achieve this.

-- Steve