Skip to content

Commit 3d13fb8

Browse files
committed
chant tscl references, fix linting
1 parent 4e1257d commit 3d13fb8

File tree

18 files changed

+622
-643
lines changed

18 files changed

+622
-643
lines changed

PROGRESS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ Unified runtime primitives shared across VM/JIT/AOT backends.
7272

7373
**Key Components:**
7474

75-
- `src/runtime/abi.rs` - NaN-boxed 64-bit `TsclValue` ABI
75+
- `src/runtime/abi.rs` - NaN-boxed 64-bit `OtValue` ABI
7676
- `src/runtime/heap.rs` - Bump allocator, object layouts
7777
- `src/runtime/stubs.rs` - 20+ `extern "C"` stubs for native backends
7878

79-
**Runtime Stubs:** `tscl_alloc_object`, `tscl_add_any`, `tscl_get_prop`, `tscl_set_prop`, `tscl_call`, `tscl_console_log`, etc.
79+
**Runtime Stubs:** `ot_alloc_object`, `ot_add_any`, `ot_get_prop`, `ot_set_prop`, `ot_call`, `ot_console_log`, etc.
8080

8181
---
8282

compiler/backend/llvm/mod.ot

Lines changed: 70 additions & 70 deletions
Large diffs are not rendered by default.

compiler/backend/llvm/runtime.ot

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -18,65 +18,65 @@ function getRuntimeDeclarations(): string {
1818

1919
// Arithmetic operations (NaN-boxed doubles)
2020
lines.push("; Arithmetic stubs");
21-
lines.push("declare i64 @tscl_add_any(i64, i64)");
22-
lines.push("declare i64 @tscl_sub_any(i64, i64)");
23-
lines.push("declare i64 @tscl_mul_any(i64, i64)");
24-
lines.push("declare i64 @tscl_div_any(i64, i64)");
25-
lines.push("declare i64 @tscl_mod_any(i64, i64)");
26-
lines.push("declare i64 @tscl_neg(i64)");
27-
lines.push("declare i64 @tscl_not(i64)");
21+
lines.push("declare i64 @ot_add_any(i64, i64)");
22+
lines.push("declare i64 @ot_sub_any(i64, i64)");
23+
lines.push("declare i64 @ot_mul_any(i64, i64)");
24+
lines.push("declare i64 @ot_div_any(i64, i64)");
25+
lines.push("declare i64 @ot_mod_any(i64, i64)");
26+
lines.push("declare i64 @ot_neg(i64)");
27+
lines.push("declare i64 @ot_not(i64)");
2828
lines.push("");
2929

3030
// Comparison operations
3131
lines.push("; Comparison stubs");
32-
lines.push("declare i64 @tscl_lt_any(i64, i64)");
33-
lines.push("declare i64 @tscl_le_any(i64, i64)");
34-
lines.push("declare i64 @tscl_gt_any(i64, i64)");
35-
lines.push("declare i64 @tscl_ge_any(i64, i64)");
36-
lines.push("declare i64 @tscl_eq_any(i64, i64)");
37-
lines.push("declare i64 @tscl_ne_any(i64, i64)");
38-
lines.push("declare i64 @tscl_eq_strict(i64, i64)");
39-
lines.push("declare i64 @tscl_ne_strict(i64, i64)");
32+
lines.push("declare i64 @ot_lt_any(i64, i64)");
33+
lines.push("declare i64 @ot_le_any(i64, i64)");
34+
lines.push("declare i64 @ot_gt_any(i64, i64)");
35+
lines.push("declare i64 @ot_ge_any(i64, i64)");
36+
lines.push("declare i64 @ot_eq_any(i64, i64)");
37+
lines.push("declare i64 @ot_ne_any(i64, i64)");
38+
lines.push("declare i64 @ot_eq_strict(i64, i64)");
39+
lines.push("declare i64 @ot_ne_strict(i64, i64)");
4040
lines.push("");
4141

4242
// Object operations
4343
lines.push("; Object stubs");
44-
lines.push("declare i64 @tscl_alloc_object()");
45-
lines.push("declare i64 @tscl_get_prop(i64, i64)");
46-
lines.push("declare void @tscl_set_prop(i64, i64, i64)");
44+
lines.push("declare i64 @ot_alloc_object()");
45+
lines.push("declare i64 @ot_get_prop(i64, i64)");
46+
lines.push("declare void @ot_set_prop(i64, i64, i64)");
4747
lines.push("");
4848

4949
// Array operations
5050
lines.push("; Array stubs");
51-
lines.push("declare i64 @tscl_alloc_array(i64)");
52-
lines.push("declare i64 @tscl_get_element(i64, i64)");
53-
lines.push("declare void @tscl_set_element(i64, i64, i64)");
54-
lines.push("declare i64 @tscl_array_length(i64)");
51+
lines.push("declare i64 @ot_alloc_array(i64)");
52+
lines.push("declare i64 @ot_get_element(i64, i64)");
53+
lines.push("declare void @ot_set_element(i64, i64, i64)");
54+
lines.push("declare i64 @ot_array_length(i64)");
5555
lines.push("");
5656

5757
// String operations
5858
lines.push("; String stubs");
59-
lines.push("declare i64 @tscl_alloc_string(i8*, i64)");
60-
lines.push("declare i64 @tscl_string_concat(i64, i64)");
59+
lines.push("declare i64 @ot_alloc_string(i8*, i64)");
60+
lines.push("declare i64 @ot_string_concat(i64, i64)");
6161
lines.push("");
6262

6363
// Function operations
6464
lines.push("; Function stubs");
65-
lines.push("declare i64 @tscl_call(i64, i64, i8*)");
66-
lines.push("declare i64 @tscl_make_closure(i64, i64)");
65+
lines.push("declare i64 @ot_call(i64, i64, i8*)");
66+
lines.push("declare i64 @ot_make_closure(i64, i64)");
6767
lines.push("");
6868

6969
// Console
7070
lines.push("; Console stubs");
71-
lines.push("declare i64 @tscl_console_log(i64)");
71+
lines.push("declare i64 @ot_console_log(i64)");
7272
lines.push("");
7373

7474
// Type conversion
7575
lines.push("; Type conversion stubs");
76-
lines.push("declare i64 @tscl_to_boolean(i64)");
77-
lines.push("declare i64 @tscl_to_number(i64)");
78-
lines.push("declare i64 @tscl_to_string(i64)");
79-
lines.push("declare i64 @tscl_is_truthy(i64)");
76+
lines.push("declare i64 @ot_to_boolean(i64)");
77+
lines.push("declare i64 @ot_to_number(i64)");
78+
lines.push("declare i64 @ot_to_string(i64)");
79+
lines.push("declare i64 @ot_is_truthy(i64)");
8080
lines.push("");
8181

8282
let result = "";
@@ -97,9 +97,9 @@ function getRuntimeDefinitions(): string {
9797
lines.push("@.fmt_num = private unnamed_addr constant [4 x i8] c\"%g\\0A\\00\"");
9898
lines.push("");
9999

100-
// tscl_console_log implementation - prints a NaN-boxed number
101-
lines.push("; tscl_console_log - prints value to stdout");
102-
lines.push("define i64 @tscl_console_log(i64 %value) {");
100+
// ot_console_log implementation - prints a NaN-boxed number
101+
lines.push("; ot_console_log - prints value to stdout");
102+
lines.push("define i64 @ot_console_log(i64 %value) {");
103103
lines.push("entry:");
104104
lines.push(" %dval = bitcast i64 %value to double");
105105
lines.push(" %fmt = getelementptr [4 x i8], [4 x i8]* @.fmt_num, i64 0, i64 0");
@@ -108,9 +108,9 @@ function getRuntimeDefinitions(): string {
108108
lines.push("}");
109109
lines.push("");
110110

111-
// tscl_add_any - add two NaN-boxed numbers
112-
lines.push("; tscl_add_any - add two numbers");
113-
lines.push("define i64 @tscl_add_any(i64 %a, i64 %b) {");
111+
// ot_add_any - add two NaN-boxed numbers
112+
lines.push("; ot_add_any - add two numbers");
113+
lines.push("define i64 @ot_add_any(i64 %a, i64 %b) {");
114114
lines.push("entry:");
115115
lines.push(" %a_fp = bitcast i64 %a to double");
116116
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -120,9 +120,9 @@ function getRuntimeDefinitions(): string {
120120
lines.push("}");
121121
lines.push("");
122122

123-
// tscl_sub_any - subtract two NaN-boxed numbers
124-
lines.push("; tscl_sub_any - subtract two numbers");
125-
lines.push("define i64 @tscl_sub_any(i64 %a, i64 %b) {");
123+
// ot_sub_any - subtract two NaN-boxed numbers
124+
lines.push("; ot_sub_any - subtract two numbers");
125+
lines.push("define i64 @ot_sub_any(i64 %a, i64 %b) {");
126126
lines.push("entry:");
127127
lines.push(" %a_fp = bitcast i64 %a to double");
128128
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -132,9 +132,9 @@ function getRuntimeDefinitions(): string {
132132
lines.push("}");
133133
lines.push("");
134134

135-
// tscl_mul_any - multiply two NaN-boxed numbers
136-
lines.push("; tscl_mul_any - multiply two numbers");
137-
lines.push("define i64 @tscl_mul_any(i64 %a, i64 %b) {");
135+
// ot_mul_any - multiply two NaN-boxed numbers
136+
lines.push("; ot_mul_any - multiply two numbers");
137+
lines.push("define i64 @ot_mul_any(i64 %a, i64 %b) {");
138138
lines.push("entry:");
139139
lines.push(" %a_fp = bitcast i64 %a to double");
140140
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -144,9 +144,9 @@ function getRuntimeDefinitions(): string {
144144
lines.push("}");
145145
lines.push("");
146146

147-
// tscl_div_any - divide two NaN-boxed numbers
148-
lines.push("; tscl_div_any - divide two numbers");
149-
lines.push("define i64 @tscl_div_any(i64 %a, i64 %b) {");
147+
// ot_div_any - divide two NaN-boxed numbers
148+
lines.push("; ot_div_any - divide two numbers");
149+
lines.push("define i64 @ot_div_any(i64 %a, i64 %b) {");
150150
lines.push("entry:");
151151
lines.push(" %a_fp = bitcast i64 %a to double");
152152
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -156,9 +156,9 @@ function getRuntimeDefinitions(): string {
156156
lines.push("}");
157157
lines.push("");
158158

159-
// tscl_mod_any - modulo two NaN-boxed numbers
160-
lines.push("; tscl_mod_any - modulo two numbers");
161-
lines.push("define i64 @tscl_mod_any(i64 %a, i64 %b) {");
159+
// ot_mod_any - modulo two NaN-boxed numbers
160+
lines.push("; ot_mod_any - modulo two numbers");
161+
lines.push("define i64 @ot_mod_any(i64 %a, i64 %b) {");
162162
lines.push("entry:");
163163
lines.push(" %a_fp = bitcast i64 %a to double");
164164
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -168,9 +168,9 @@ function getRuntimeDefinitions(): string {
168168
lines.push("}");
169169
lines.push("");
170170

171-
// tscl_neg - negate a NaN-boxed number
172-
lines.push("; tscl_neg - negate a number");
173-
lines.push("define i64 @tscl_neg(i64 %a) {");
171+
// ot_neg - negate a NaN-boxed number
172+
lines.push("; ot_neg - negate a number");
173+
lines.push("define i64 @ot_neg(i64 %a) {");
174174
lines.push("entry:");
175175
lines.push(" %a_fp = bitcast i64 %a to double");
176176
lines.push(" %result_fp = fsub double 0.0, %a_fp");
@@ -179,9 +179,9 @@ function getRuntimeDefinitions(): string {
179179
lines.push("}");
180180
lines.push("");
181181

182-
// tscl_lt_any - less than comparison
183-
lines.push("; tscl_lt_any - less than comparison");
184-
lines.push("define i64 @tscl_lt_any(i64 %a, i64 %b) {");
182+
// ot_lt_any - less than comparison
183+
lines.push("; ot_lt_any - less than comparison");
184+
lines.push("define i64 @ot_lt_any(i64 %a, i64 %b) {");
185185
lines.push("entry:");
186186
lines.push(" %a_fp = bitcast i64 %a to double");
187187
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -192,9 +192,9 @@ function getRuntimeDefinitions(): string {
192192
lines.push("}");
193193
lines.push("");
194194

195-
// tscl_le_any - less than or equal comparison
196-
lines.push("; tscl_le_any - less than or equal comparison");
197-
lines.push("define i64 @tscl_le_any(i64 %a, i64 %b) {");
195+
// ot_le_any - less than or equal comparison
196+
lines.push("; ot_le_any - less than or equal comparison");
197+
lines.push("define i64 @ot_le_any(i64 %a, i64 %b) {");
198198
lines.push("entry:");
199199
lines.push(" %a_fp = bitcast i64 %a to double");
200200
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -205,9 +205,9 @@ function getRuntimeDefinitions(): string {
205205
lines.push("}");
206206
lines.push("");
207207

208-
// tscl_gt_any - greater than comparison
209-
lines.push("; tscl_gt_any - greater than comparison");
210-
lines.push("define i64 @tscl_gt_any(i64 %a, i64 %b) {");
208+
// ot_gt_any - greater than comparison
209+
lines.push("; ot_gt_any - greater than comparison");
210+
lines.push("define i64 @ot_gt_any(i64 %a, i64 %b) {");
211211
lines.push("entry:");
212212
lines.push(" %a_fp = bitcast i64 %a to double");
213213
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -218,9 +218,9 @@ function getRuntimeDefinitions(): string {
218218
lines.push("}");
219219
lines.push("");
220220

221-
// tscl_ge_any - greater than or equal comparison
222-
lines.push("; tscl_ge_any - greater than or equal comparison");
223-
lines.push("define i64 @tscl_ge_any(i64 %a, i64 %b) {");
221+
// ot_ge_any - greater than or equal comparison
222+
lines.push("; ot_ge_any - greater than or equal comparison");
223+
lines.push("define i64 @ot_ge_any(i64 %a, i64 %b) {");
224224
lines.push("entry:");
225225
lines.push(" %a_fp = bitcast i64 %a to double");
226226
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -231,9 +231,9 @@ function getRuntimeDefinitions(): string {
231231
lines.push("}");
232232
lines.push("");
233233

234-
// tscl_eq_any - equality comparison
235-
lines.push("; tscl_eq_any - equality comparison");
236-
lines.push("define i64 @tscl_eq_any(i64 %a, i64 %b) {");
234+
// ot_eq_any - equality comparison
235+
lines.push("; ot_eq_any - equality comparison");
236+
lines.push("define i64 @ot_eq_any(i64 %a, i64 %b) {");
237237
lines.push("entry:");
238238
lines.push(" %a_fp = bitcast i64 %a to double");
239239
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -244,9 +244,9 @@ function getRuntimeDefinitions(): string {
244244
lines.push("}");
245245
lines.push("");
246246

247-
// tscl_ne_any - not equal comparison
248-
lines.push("; tscl_ne_any - not equal comparison");
249-
lines.push("define i64 @tscl_ne_any(i64 %a, i64 %b) {");
247+
// ot_ne_any - not equal comparison
248+
lines.push("; ot_ne_any - not equal comparison");
249+
lines.push("define i64 @ot_ne_any(i64 %a, i64 %b) {");
250250
lines.push("entry:");
251251
lines.push(" %a_fp = bitcast i64 %a to double");
252252
lines.push(" %b_fp = bitcast i64 %b to double");
@@ -257,9 +257,9 @@ function getRuntimeDefinitions(): string {
257257
lines.push("}");
258258
lines.push("");
259259

260-
// tscl_is_truthy - check if value is truthy
261-
lines.push("; tscl_is_truthy - check if value is truthy");
262-
lines.push("define i1 @tscl_is_truthy(i64 %value) {");
260+
// ot_is_truthy - check if value is truthy
261+
lines.push("; ot_is_truthy - check if value is truthy");
262+
lines.push("define i1 @ot_is_truthy(i64 %value) {");
263263
lines.push("entry:");
264264
lines.push(" ; For numbers, check if non-zero");
265265
lines.push(" %masked = and i64 %value, 1");
@@ -270,32 +270,32 @@ function getRuntimeDefinitions(): string {
270270

271271
// Stub implementations for object/array operations (return undefined)
272272
lines.push("; Stub implementations");
273-
lines.push("define i64 @tscl_alloc_object() {");
273+
lines.push("define i64 @ot_alloc_object() {");
274274
lines.push(" ret i64 9221120237041090561");
275275
lines.push("}");
276276
lines.push("");
277277

278-
lines.push("define i64 @tscl_alloc_array(i64 %cap) {");
278+
lines.push("define i64 @ot_alloc_array(i64 %cap) {");
279279
lines.push(" ret i64 9221120237041090561");
280280
lines.push("}");
281281
lines.push("");
282282

283-
lines.push("define i64 @tscl_get_prop(i64 %obj, i64 %key) {");
283+
lines.push("define i64 @ot_get_prop(i64 %obj, i64 %key) {");
284284
lines.push(" ret i64 9221120237041090561");
285285
lines.push("}");
286286
lines.push("");
287287

288-
lines.push("define void @tscl_set_prop(i64 %obj, i64 %key, i64 %val) {");
288+
lines.push("define void @ot_set_prop(i64 %obj, i64 %key, i64 %val) {");
289289
lines.push(" ret void");
290290
lines.push("}");
291291
lines.push("");
292292

293-
lines.push("define i64 @tscl_get_element(i64 %arr, i64 %idx) {");
293+
lines.push("define i64 @ot_get_element(i64 %arr, i64 %idx) {");
294294
lines.push(" ret i64 9221120237041090561");
295295
lines.push("}");
296296
lines.push("");
297297

298-
lines.push("define void @tscl_set_element(i64 %arr, i64 %idx, i64 %val) {");
298+
lines.push("define void @ot_set_element(i64 %arr, i64 %idx, i64 %val) {");
299299
lines.push(" ret void");
300300
lines.push("}");
301301
lines.push("");

docs/blog/2026-01-27-self-hosting-journey.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub const ABI_VERSION: u32 = 1;
7878
```
7979

8080
The ABI defines:
81-
- Function signatures for runtime stubs (`tscl_add_any`, `tscl_alloc_object`, etc.)
81+
- Function signatures for runtime stubs (`ot_add_any`, `ot_alloc_object`, etc.)
8282
- NaN-boxed value encoding (64-bit words)
8383
- Heap object layouts
8484
- Calling conventions
@@ -151,24 +151,24 @@ The ABI consists of ~20 runtime stubs:
151151
```rust
152152
extern "C" {
153153
// Arithmetic
154-
fn tscl_add_any(a: u64, b: u64) -> u64;
155-
fn tscl_sub_any(a: u64, b: u64) -> u64;
156-
fn tscl_mul_any(a: u64, b: u64) -> u64;
154+
fn ot_add_any(a: u64, b: u64) -> u64;
155+
fn ot_sub_any(a: u64, b: u64) -> u64;
156+
fn ot_mul_any(a: u64, b: u64) -> u64;
157157

158158
// Allocation
159-
fn tscl_alloc_object() -> u64;
160-
fn tscl_alloc_array() -> u64;
161-
fn tscl_alloc_string(ptr: *const u8, len: usize) -> u64;
159+
fn ot_alloc_object() -> u64;
160+
fn ot_alloc_array() -> u64;
161+
fn ot_alloc_string(ptr: *const u8, len: usize) -> u64;
162162

163163
// Property access
164-
fn tscl_get_prop(obj: u64, key: u64) -> u64;
165-
fn tscl_set_prop(obj: u64, key: u64, val: u64) -> u64;
164+
fn ot_get_prop(obj: u64, key: u64) -> u64;
165+
fn ot_set_prop(obj: u64, key: u64, val: u64) -> u64;
166166

167167
// Function calls
168-
fn tscl_call(func: u64, args: u64, arg_count: u32) -> u64;
168+
fn ot_call(func: u64, args: u64, arg_count: u32) -> u64;
169169

170170
// Error handling
171-
fn tscl_abort(msg: *const u8, len: usize) -> !;
171+
fn ot_abort(msg: *const u8, len: usize) -> !;
172172
}
173173
```
174174

src/backend/aot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl AotCompiler {
251251
.duration_since(UNIX_EPOCH)
252252
.unwrap()
253253
.as_nanos();
254-
let temp_file = std::env::temp_dir().join(format!("tscl_{}.o", timestamp));
254+
let temp_file = std::env::temp_dir().join(format!("ot_{}.o", timestamp));
255255
super::llvm::compile_to_object_file(module, &self.config, &temp_file)?;
256256

257257
// Read object file bytes

0 commit comments

Comments
 (0)