GithubHelp home page GithubHelp logo

jssi's Introduction

JSSI

JSSI is a JavaScript to TypeScript compiler.

Installation

Make sure you have node.js installed

git clone https://github.com/pitust/jssi
cd jssi
npm install
npm link

How does it work?

It works by removing some JS constructs, such as loops, adding variable and function call tracers. So for example this:

let i = 0;
export function randomCall() {
  out(i++);
}
out(2);
randomCall();

is transpiled to this (without prepended libJSSI, the runtime):

let i = __varset("0", 0, "0");

function randomCall() {
  let __intcfncid = __funcCalled(this, 0x0, arguments);
  out(i++);
  __returning(__intcfncid);
}

out(2);
randomCall();
__passRetev({vm, fnm});

__passRetev is defined in interp.js Note that by the i++ there is no __varset. This is because pre- and post- incrimination HAVE to input numbers, so their result HAS to be number.

Usage

Usage: jssi <input> [flags]
    Flags:
        -o, --output <output>     Output File
        -D, --defs <deffile>      Definiton File
        -T, --typemap <typemap>   Type Map
        -E, --save-sandbox        Print code sent to the sandbox

Input and Output are fairly self-explanatory. Definition file is YAML with following contents:

<function name>:
  args:
    - <type> <name>
  rets: <return type>

The type map is JSON:

{
    "types": {
        // Here key is the source type and value is mapped type
    },
    // The prefix and suffix is ignored for undefined
    "suffix": " | null",
    "prefix": ""
}

The Save Sandbox option will save the code executed in the sandbox to a file. The file name is determined by removing the file extension and adding .sbx.js.

jssi's People

Contributors

dependabot[bot] avatar pitust avatar

Watchers

 avatar

Forkers

anima-os-dev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.