Skip to content
Chrono-bytePublic

About

Experimental TypeScript and JavaScript ahead-of-time compiler using Rust and LLVM

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Oats

License Rust LLVM

Compiles TypeScript/JavaScript to native code using LLVM. Still experimental, but it works for basic stuff. Supports multi-file projects, generates standalone executables, and uses reference counting for memory management.

Features

  • Basic types: numbers, booleans, strings, arrays, classes, unions
  • Multi-file compilation with a package system
  • Generics (via monomorphization) and union types
  • Async functions (still in preview, but they work)
  • Reference counting with weak refs and cycle collection
  • Outputs LLVM IR and links to a custom runtime

Getting Started

Prerequisites

You'll need:

  • Rust (install via rustup)
  • LLVM 18 dev headers and tools
  • clang (usually comes with LLVM)

Installing LLVM 18:

Fedora:

sudo dnf install llvm18 llvm18-devel clang18

Quick Start (Recommended)

The easiest way is to use toasty standalone.

Install it:

cargo install --git https://gitlab.com/Chrono-byte/oats toasty

Then compile and run:

# Create a simple program
echo 'export function main(): void { println(5 + 3); }' > add.ts

# Build it
toasty build add.ts

# Or build and run
toasty run add.ts

The runtime gets cached in ~/.oats/runtime/ so subsequent builds are faster.

Environment variables:

  • OATS_RUNTIME_CACHE: Change where the runtime cache goes

Building from Source

If you want to hack on Oats:

git clone https://gitlab.com/Chrono-byte/oats.git
cd oats

# Build everything
cargo build --workspace

# Run an example
cargo run -p toasty --release -- run examples/add.ts

Project Structure

  • crates/oatsc: The actual compiler (parsing, type checking, LLVM IR generation)
  • crates/runtime: Runtime library with ARC, allocators, logging, cycle collector.
  • crates/toasty: CLI tool with build and run commands
  • crates/std: Standard library (console, filesystem, networking, etc.)
  • docs/: Documentation (architecture, dev guides, memory design, roadmap)
  • examples/: Example programs and test suites
  • scripts/: Helper scripts for dev/testing

Check out docs/README.md for more detailed docs.

Contributing

Contributions welcome. Check out docs/ROADMAP.md to see what's planned.

To build and test:

# Build everything
cargo build --workspace

# Run tests
cargo test --workspace

# Run the end-to-end tests
# there is a test suite member called e2e_tests.rs that runs the end-to-end tests

License

Licensed under the zlib/libpng License with Acknowledgement. See the LICENSE file for details.

About

Experimental TypeScript and JavaScript ahead-of-time compiler using Rust and LLVM

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages