Skip to content

New Code Design #104

@ackava

Description

@ackava

C# Code Generation Design

Pros

  1. Fast to implement
  2. C# code optimizations
  3. Easy to visualize code
  4. Better debugging, we can use dotnet debugger directly.
  5. We can reuse c# default type checker, literals can be used as it is without creating JavaScript object.
  6. Precompilation, JS can be compiled as dll and shipped.
  7. We can use embedded source for debugging.

Cons

  1. No Tail Call optimizations
  2. Generate C# code -> Parse C# Code to generate Assembly.
let a = 3;
return () => a++;
public static JSValue Method(JSContext context, JSValue @this, in Arguments a) {

   var a = 3;

   return new JSFunction((_c, in _args) => a = a.Add(1));
}

Persistent Assembly Generation

Pros

  1. Tail call optimizations
  2. Smaller storage
  3. Faster code generation

Cons

  1. Compilated logic
  2. Will require rewrite of most of logic
  3. Deal with IL generation complications such as block scope etc, you cannot jump in and out of block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions