Skip to content
/ jswt Public

JavaScript with types. A toy language aimed at personal scripting

Notifications You must be signed in to change notification settings

nishtahir/jswt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSWT

A JavaScript/TypeScript like language that compiles to web assembly.

Architecture

Compilation takes place in phases described in the following chart. Each of these phases roughly takes place in a module of a similar name.

Wasmer is used as the WASM execution engine.

CLI

USAGE:
    jswt [FLAGS] [OPTIONS] <file>

FLAGS:
    -h, --help        Prints help information
        --log-mem     Log the memory layout after execution
        --minified    Minify WAST output
        --no-std      Do not include the runtime and stdlib
    -V, --version     Prints version information

OPTIONS:
    -o <output>                          Write output to file
        --runtime-path <runtime-path>    Path to runtime sources

ARGS:
    <file>    Input file to begin compiling

Sample

class Array {
    length: i32;
    capacity: i32;
    data: i32;

    constructor(capacity: i32) {
        this.length = 0;
        this.capacity = capacity;
        this.data = malloc(capacity * 4);
    }

    set(index: i32, data: i32) {
        i32Store(this.data + index * 4, data);
    }

    get(index: i32): i32 {
        return i32Load(this.data + index * 4);
    }
}

export function main(): i32 {
    let value: i32 = 10;
    let value2 = value + 33;

    println(value2);

    return 0;
}

Resources

About

JavaScript with types. A toy language aimed at personal scripting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published