Skip to content

Commit 8a38986

Browse files
committed
0.0.1
1 parent 4ebb8c2 commit 8a38986

174 files changed

Lines changed: 14394 additions & 6348 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Cargo.lock
1717
node_modules/
1818
cache/
1919
dist/
20+
pnpm-lock.yaml
2021

2122
# Logs
2223
*.txt

Cargo.toml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
[workspace]
22
resolver = "3"
33
members = [
4-
"compilers/ruby",
5-
"compilers/ruby-macros",
6-
"compilers/ruby-tools",
7-
"compilers/ruby-types",
4+
"compilers/*",
85
]
96
default-members = [
10-
"compilers/ruby",
11-
"compilers/ruby-macros",
12-
"compilers/ruby-tools",
13-
"compilers/ruby-types",
7+
"compilers/*",
148
]
159

1610

1711
[workspace.package]
18-
version = "0.0.0"
12+
version = "0.0.1"
1913
edition = "2024"
2014
authors = ["RBQ Team"]
2115
license = "MIT OR Apache-2.0"
2216
repository = "https://github.com/nyar-vm/rusty-ruby"
2317

2418
[workspace.dependencies]
2519
async-stream = "0.3"
26-
tokio = { version = "1.36", features = ["rt-multi-thread", "macros", "net", "time", "sync", "io-util"] }
20+
tokio = { version = "1.36", features = ["rt-multi-thread", "macros", "net", "time", "sync", "io-util", "io-std"] }
2721
async-trait = { version = "0.1" }
2822
serde = { version = "1.0.227", features = ["derive"] }
2923
serde_json = "1.0"
@@ -41,20 +35,32 @@ chrono = { version = "0.4", features = ["serde"] }
4135
dashmap = "6.1.0"
4236
bytes = "1.5"
4337
byteorder = "1.5"
38+
libloading = "0.8.1"
39+
cranelift = "0.103.0"
40+
cranelift-codegen = "0.103.0"
41+
cranelift-frontend = "0.103.0"
42+
cranelift-module = "0.103.0"
43+
cranelift-jit = "0.103.0"
4444

4545
# Oak parsers
46-
oak-lsp = { path = "../oaks/projects/oak-lsp", version = "0.0.9" }
47-
oak-core = { path = "../oaks/projects/oak-core", version = "0.0.9" }
48-
oak-vfs = { path = "../oaks/projects/oak-vfs", version = "0.0.9" }
49-
oak-mcp = { path = "../oaks/projects/oak-mcp", version = "0.0.9" }
50-
oak-json = { path = "../oaks/examples/oak-json", version = "0.0.9" }
51-
oak-toml = { path = "../oaks/examples/oak-toml", version = "0.0.9" }
52-
oak-ruby = { path = "../oaks/examples/oak-ruby", version = "0.0.9" }
46+
oak-lsp = { git = "https://github.com/ygg-lang/oaks.git", branch = "dev", version = "0.0.10" }
47+
oak-core = { git = "https://github.com/ygg-lang/oaks.git", branch = "dev", version = "0.0.10" }
48+
oak-vfs = { git = "https://github.com/ygg-lang/oaks.git", branch = "dev", version = "0.0.10" }
49+
oak-mcp = { git = "https://github.com/ygg-lang/oaks.git", branch = "dev", version = "0.0.10" }
50+
oak-json = { git = "https://github.com/ygg-lang/oaks.git", branch = "dev", version = "0.0.10" }
51+
oak-toml = { git = "https://github.com/ygg-lang/oaks.git", branch = "dev", version = "0.0.10" }
52+
oak-ruby = { git = "https://github.com/ygg-lang/oaks.git", branch = "dev", version = "0.0.10" }
5353

5454
# Rusty Ruby crates
55-
ruby-types = { path = "compilers/ruby-types" }
55+
ruby-types = { path = "compilers/ruby-types" , version = "0.0.1" }
56+
ruby-ir = { path = "compilers/ruby-ir" , version = "0.0.1" }
57+
ruby = { path = "compilers/ruby" , version = "0.0.1" }
5658

5759
# Macro dependencies
5860
syn = { version = "2.0", features = ["full", "extra-traits"] }
5961
quote = "1.0"
6062
proc-macro2 = "1.0"
63+
64+
# WASM dependencies
65+
wasm-bindgen = "0.2.92"
66+
wasm-bindgen-futures = "0.4.42"

Readme.md

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,66 @@
1-
Rust Template Project
2-
=====================
1+
# Rusty Ruby
32

4-
Rust template project for monorepo
3+
A modern, high-performance Ruby implementation written in Rust, designed for speed, safety, and reliability.
54

6-
## Change the initial commit
5+
## 🎯 Project Overview
76

8-
```shell
9-
git commit --amend --message "🎂 Project initialized!" --date "2012-12-12"
7+
Rusty Ruby is a comprehensive Ruby implementation that combines the elegance of Ruby with the performance and safety of Rust. It features a multi-tier compilation architecture, advanced garbage collection, and a rich ecosystem of tools and libraries.
8+
9+
## 🌟 Key Features
10+
11+
- **Multi-tier Compilation**: Interpreter, baseline compiler, and optimizing compiler for balanced performance
12+
- **Advanced Garbage Collection**: Generational, incremental, and concurrent GC strategies
13+
- **JIT Compilation**: Just-In-Time compilation for hot code paths
14+
- **WebAssembly Support**: Run Ruby code in the browser with WASI
15+
- **Language Server Protocol**: Modern IDE integration
16+
- **Comprehensive Tooling**: Pure Rust implementations of ruby, irb, gem, rake, rdoc, ri, and testrb
17+
- **Type Safety**: Core type definitions for seamless Rust-Ruby integration
18+
- **Macros**: Procedural macros for easy Ruby class and method definition in Rust
19+
20+
## 🚀 Quick Start
21+
22+
```bash
23+
# Build the project
24+
cargo build
25+
26+
# Run Ruby scripts
27+
cargo run --bin ruby script.rb
28+
29+
# Start interactive Ruby shell
30+
cargo run --bin irb
31+
```
32+
33+
## 📁 Project Structure
34+
35+
The Rusty Ruby project is organized into multiple crates:
36+
37+
- **compilers/ruby**: Main Ruby compiler and runtime
38+
- **compilers/ruby-ir**: Intermediate Representation for Ruby code
39+
- **compilers/ruby-lsp**: Language Server Protocol implementation
40+
- **compilers/ruby-macros**: Procedural macros for Ruby integration
41+
- **compilers/ruby-tools**: Ruby language tools (ruby, irb, gem, etc.)
42+
- **compilers/ruby-types**: Core type definitions
43+
- **compilers/ruby-wasi**: WebAssembly support
44+
- **frontends/ruby-ts**: TypeScript frontend for WASM integration
45+
46+
## 🔧 Development
47+
48+
```bash
49+
# Run tests
50+
cargo test
51+
52+
# Build in release mode
53+
cargo build --release
54+
55+
# Run benchmarks
56+
cargo bench
1057
```
1158

12-
## Emoji Comment
59+
## 🤝 Contributing
60+
61+
Contributions are welcome! Feel free to open issues or submit pull requests to help improve Rusty Ruby.
62+
63+
## 📄 Emoji Guide
1364

1465
| Emoji | Meaning |
1566
|--------|------------------------------|

biome.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"indentStyle": "space",
6+
"indentWidth": 4,
7+
"lineWidth": 100
8+
},
9+
"javascript": {
10+
"formatter": {
11+
"arrowParentheses": "always",
12+
"bracketSameLine": false,
13+
"bracketSpacing": true,
14+
"jsxQuoteStyle": "double",
15+
"quoteProperties": "asNeeded",
16+
"semicolons": "always",
17+
"trailingCommas": "all"
18+
}
19+
},
20+
"json": {
21+
"formatter": {
22+
"enabled": true,
23+
"indentWidth": 4
24+
},
25+
"parser": {
26+
"allowComments": true
27+
}
28+
},
29+
"files": {
30+
"ignore": ["**/node_modules", "**/target", "**/dist", "**/.git", "**/public"]
31+
}
32+
}

compilers/ruby-ir/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "ruby-ir"
3+
version.workspace = true
4+
description = "Intermediate Representation for Ruby code"
5+
edition.workspace = true
6+
authors.workspace = true
7+
license.workspace = true
8+
9+
[dependencies]
10+
ruby-types = { workspace = true }
11+
serde = { workspace = true }
12+
serde_json = { workspace = true }

compilers/ruby-ir/readme.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Ruby IR
2+
3+
Intermediate Representation for Ruby code in Rusty Ruby, providing a foundation for optimization and code generation.
4+
5+
## 🎯 Project Overview
6+
7+
Ruby-IR is a crate that provides the intermediate representation (IR) for Ruby code compilation in the Rusty Ruby project. It defines the data structures and traversal utilities for representing Ruby code in a form suitable for optimization and code generation.
8+
9+
## 🌟 Key Features
10+
11+
- **Abstract Syntax Tree (AST) Representation**: Structured representation of Ruby code
12+
- **Traversal Utilities**: Tools for navigating and manipulating IR nodes
13+
- **Serialization Support**: Convert IR objects to and from serialized formats
14+
- **Optimization Framework**: Foundation for code optimization passes
15+
- **Integration**: Seamlessly works with other Rusty Ruby components
16+
17+
## 🚀 Quick Start
18+
19+
```rust
20+
use ruby_ir::*;
21+
22+
// Create IR nodes
23+
let expression = Expression::Constant(Constant::Integer(42));
24+
25+
// Traverse and manipulate IR
26+
struct MyVisitor;
27+
28+
impl Visitor for MyVisitor {
29+
fn visit_expression(&mut self, expr: &Expression) {
30+
match expr {
31+
Expression::Constant(constant) => println!("Found constant: {:?}", constant),
32+
_ => {}
33+
}
34+
}
35+
}
36+
37+
let mut visitor = MyVisitor;
38+
visitor.visit_expression(&expression);
39+
```
40+
41+
## 🏗️ Architecture
42+
43+
### Core Components
44+
45+
- **Expressions**: Represent Ruby expressions like constants, variables, method calls, etc.
46+
- **Statements**: Represent Ruby statements like assignments, conditionals, loops, etc.
47+
- **Symbols**: Represent Ruby symbols and identifiers
48+
- **Types**: Represent Ruby types and type information
49+
- **Traversal**: Utilities for visiting and manipulating IR nodes
50+
51+
### Optimization Passes
52+
53+
- **Constant Folding**: Evaluate constant expressions at compile time
54+
- **Dead Code Elimination**: Remove unreachable code
55+
- **Inline Expansion**: Inline method calls for better performance
56+
- **Type Inference**: Infer types for variables and expressions
57+
58+
## 🛠️ Development
59+
60+
```bash
61+
# Build the project
62+
cargo build
63+
64+
# Run tests
65+
cargo test
66+
67+
# Build in release mode
68+
cargo build --release
69+
```
70+
71+
## 📚 Usage Examples
72+
73+
### Basic IR Creation
74+
75+
```rust
76+
use ruby_ir::*;
77+
78+
// Create a binary expression: 1 + 2
79+
let left = Expression::Constant(Constant::Integer(1));
80+
let right = Expression::Constant(Constant::Integer(2));
81+
let add_expr = Expression::BinaryOp(
82+
BinaryOp::Add,
83+
Box::new(left),
84+
Box::new(right)
85+
);
86+
87+
// Create an assignment statement
88+
let variable = Expression::Variable("result".to_string());
89+
let assignment = Statement::Assignment(
90+
Box::new(variable),
91+
Box::new(add_expr)
92+
);
93+
94+
// Create a program
95+
let program = Program {
96+
statements: vec![assignment]
97+
};
98+
```
99+
100+
### IR Traversal
101+
102+
```rust
103+
use ruby_ir::*;
104+
105+
struct ConstantCollector {
106+
constants: Vec<Constant>
107+
}
108+
109+
impl Visitor for ConstantCollector {
110+
fn visit_constant(&mut self, constant: &Constant) {
111+
self.constants.push(constant.clone());
112+
}
113+
}
114+
115+
let mut collector = ConstantCollector { constants: vec![] };
116+
collector.visit_program(&program);
117+
118+
println!("Found constants: {:?}", collector.constants);
119+
```
120+
121+
## 🤝 Contributing
122+
123+
Contributions are welcome! Feel free to open issues or submit pull requests to help improve Ruby-IR.

0 commit comments

Comments
 (0)