Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tjit

An experimental strongly typed systems language with a JIT compiler written in Rust using Cranelift with a static type checker.

Features

  • ADTs and Arrays
  • Pattern matching (ranges, destructuring, wildcards)
  • Bit-packing for arbitrary-width (<64) integers (u13, i42) packed to maximise cache efficiency.
  • Pipeline operator (|>) as a form of UFCS.
  • Libc FFI for IO

Showcase

Functions

fn add(a: i64, b: i64) -> i64 {
  a + b
}

add(2, 3)

ADTs

struct Point {
  x: i64,
  y: i64,
}

enum Event {
  Click(Point),
  Quit,
}

Pattern matching

let val = 15
let r = match val {
  0..10 => 0,
  10..=20 => 1,
  _ => 2,
}

Arrays

let arr: [i64; 4] = [10, 20, 30, 40]
let x = arr[2]

Arbitrary width integers

struct BitPack {
  is_active: u1,
  day_of_week: u3,
  count: i17,
}

Pipeline operator

fn add(a: i64, b: i64) -> i64 {
  a + b
}

let x = 10 |> add(5)

Building

cargo build --release

Running

cargo run --release -- <file.tjit>

Usage

tjit <filename.tjit>

TODO

  • Heap FFI (alloc / free)
    • Affine type system (move semantics)
    • RAII (and drop traits?)
    • Borrow checker with mutability ^ aliasing (and a MIR for that) and NLLs.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages