No description
- Rust 99.7%
- Shell 0.3%
Add function_attributes, constant_folding and string_builder helpers and several CodeGen utility methods (get_data_ptr_from_object, is_at_function_end, string interning helpers, reachability stubs). Apply optimization attributes to generated functions and use the new data-pointer helper for string literals. Update example main to return a numeric exit code. |
||
|---|---|---|
| .vscode | ||
| crates | ||
| docs | ||
| examples | ||
| scripts | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| AGENTS.md | ||
| Cargo.lock | ||
| Cargo.toml | ||
| clippy.toml | ||
| LICENSE | ||
| Oats.toml.example | ||
| README.md | ||
Oats
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 withbuildandruncommandscrates/std: Standard library (console, filesystem, networking, etc.)docs/: Documentation (architecture, dev guides, memory design, roadmap)examples/: Example programs and test suitesscripts/: 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.