Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tjit

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

Features

  • Lexer, parser, and static type checker lowering to Cranelift IR with a typed AST HIR
  • Algebraic data types (struct + enums with payload)
  • Pattern matching (ranges, destructuring, wildcards)
  • Bit-packing for arbitrary-width integers (u13, i42) packed to maximize L1 cache density and promoted during execution.
  • Fixed size arrays
  • Pipeline operator (|>)
  • Libc FFI for I/O

Example

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 (Drop heap allocation at the end of scope)
  • Borrow checker with mutability XOR aliasing via custom MIR (non-cranelift one) lowering and non-lexical lifetimes.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages