Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .trinity/seals/t27b_T27bMachO.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"built_by": "t27c-bootstrap@0.5.2+24a3abcad",
"closure": [],
"built_by": "t27c-bootstrap@0.5.2+9f9ea36a5",
"closure": [
{
"spec": "specs/tri/t27b/emit_kit; // put_bytes.t27",
"spec_hash": "missing"
}
],
"config": "gen=c,rust,verilog,zig;tests=zig",
"gen_hash_c": "sha256:687d06416991d436a2bdbd14863fdcd2074caa72681f4cdbfe5730de38a5d8db",
"gen_hash_rust": "sha256:201f73a426886b2eed375bdfccc341dfb227a0f939f069329c066c45dcbe48a4",
"gen_hash_verilog": "sha256:3e5fc2af695f31197eebc669cb8a951dbe1d795b5871782293fed906caad3d5b",
"gen_hash_zig": "sha256:7c8a6c6713a923c2436646c25f1a5290ee6a7f634436cad0c9799c2bfee7ff6e",
"gen_hash_c": "sha256:2bf5be8f37eae7e8ffd2f24c7aa4b75cccbe202e133bd1abca6db57c9e64acd8",
"gen_hash_rust": "sha256:ea241826f6b317d86cb97fbfb3684c88d1d82f8582ab58b978a18c2ce6e2d745",
"gen_hash_verilog": "sha256:b767f17d40040974b06a53493bf34c69abe9189c25a208a2beca2f1d27d15617",
"gen_hash_zig": "sha256:acce46dadf17cb2b62ef88d7b022f974785df05a0c004cfa695fc50fd553cf62",
"module": "T27bMachO",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-20T10:17:33Z",
"sealed_at": "2026-11-11T04:31:41Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:a3e7c9d8e03503cb525a543331394cafeb960bf865de04c07e7fd8b669f0b32c",
"spec_hash": "sha256:3796c43fbfc7164f28e980e5605ff8350603051efc9061711b21329270645d2d",
"spec_path": "specs/tri/t27b/macho.t27",
"tests": {
"failed": 0,
Expand All @@ -22,7 +27,7 @@
"vacuous": 0
},
"toolchain": {
"test_runner": "sha256:8512b80da533b79289110fca4a65f3336abd7a059ca4b72ea595d5e33ff8ad10",
"zig": "0.16.0"
"test_runner": "sha256:1a50286d6170ef41c779d26385a1be59823925d7131497c93d84194144ba93b3",
"zig": "0.17.1"
}
}
106 changes: 95 additions & 11 deletions gen/rust/tri/t27b/macho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,6 @@ pub fn group_size(lens: &[u8], from: usize, to: usize) -> usize {
return (blob_off(lens, from, (to - 1)) + blob_len(lens, (to - 1)));
}

pub fn put_bytes(out: &mut [u8], at: usize, src: &[u8]) -> usize {
let mut i: usize = 0;
while (i < src.len()) {
out[((at + i)) as usize] = src[(i) as usize];
i = (i + 1);
}
return (at + src.len());
}

pub fn put_group(out: &mut [u8], base: usize, blobs: &[u8], lens: &[u8], from: usize, to: usize) -> () {
let mut src: usize = 0;
let mut k: usize = 0;
Expand All @@ -351,7 +342,7 @@ pub fn put_group(out: &mut [u8], base: usize, blobs: &[u8], lens: &[u8], from: u
let mut at: usize = 0;
while (k < to) {
let n: usize = blob_len(lens, k);
put_bytes(out, (base + at), &blobs[(src) as usize..((src + n)) as usize]);
put_bytes(out, (base + at), blobs, src, (src + n));
src = (src + n);
at = align_up((at + n), 8);
k = (k + 1);
Expand Down Expand Up @@ -658,7 +649,7 @@ pub fn write_object(out: &mut [u8], text: &[u8], names: &[u8], fns: &[u8], refs:
put_commands_x(out, text_size, const_size, nreloc, nlocal, nextdef, nimp, macho_strsize(names, fns, refs, nblobs));
let toff: usize = text_off(const_size);
let ca: usize = const_addr(text_size);
put_bytes(out, toff, text);
put_bytes(out, toff, text, 0, text.len());
put_group(out, (toff + ca), blobs, lens, 0, nblobs);
let rel: usize = reloff(text_size, const_size);
let syo: usize = syms_at(text_size, const_size, nreloc);
Expand Down Expand Up @@ -756,3 +747,96 @@ pub fn put_row(t: &mut [u8], i: usize, a: usize, b: usize) -> () {
put_u64(t, ((ROW * i) + 8), (b as u64));
}

pub const B_DOT: u8 = 46;

pub const F_NAME: usize = 0;

pub const REC: usize = 72;

pub fn has_at(s: &[u8], lo: usize, hi: usize, w: &[u8]) -> bool {
if ((hi - lo) < w.len()) {
return false;
}
let mut k: usize = 0;
while (k < w.len()) {
if (s[((lo + k)) as usize] != w[(k) as usize]) {
return false;
}
k = (k + 1);
}
return true;
}

pub fn hi(nodes: &[u8], i: usize, f: usize) -> usize {
return u32_at(nodes, (((i * REC) + 12) + (f * 8)));
}

pub fn lo(nodes: &[u8], i: usize, f: usize) -> usize {
return u32_at(nodes, (((i * REC) + 8) + (f * 8)));
}

pub fn names(nodes: &[u8], text: &[u8], i: usize, name: &[u8]) -> bool {
let a: usize = lo(nodes, i, F_NAME);
let b: usize = hi(nodes, i, F_NAME);
if !(has_at(text, a, b, name)) {
return false;
}
return (((b - a) == name.len()) || (text[((a + name.len())) as usize] == B_DOT));
}

pub fn put32(nodes: &mut [u8], at: usize, v: usize) -> () {
nodes[(at) as usize] = ((v % 256) as _);
nodes[((at + 1)) as usize] = (((v / 256) % 256) as _);
nodes[((at + 2)) as usize] = (((v / 65536) % 256) as _);
nodes[((at + 3)) as usize] = ((v / 16777216) as _);
}

pub fn set(nodes: &mut [u8], i: usize, f: usize, a: usize, b: usize) -> () {
put32(nodes, (((i * REC) + 8) + (f * 8)), a);
put32(nodes, (((i * REC) + 12) + (f * 8)), b);
}

pub fn u32_at(nodes: &[u8], at: usize) -> usize {
let b0: usize = (nodes[(at) as usize] as usize);
let b1: usize = (nodes[((at + 1)) as usize] as usize);
let b2: usize = (nodes[((at + 2)) as usize] as usize);
let b3: usize = (nodes[((at + 3)) as usize] as usize);
return (((b0 + (b1 * 256)) + (b2 * 65536)) + (b3 * 16777216));
}

pub fn put_bytes(out: &mut [u8], at: usize, s: &[u8], a: usize, b: usize) -> usize {
let mut k: usize = a;
let mut q: usize = at;
while (k < b) {
out[(q) as usize] = s[(k) as usize];
q = (q + 1);
k = (k + 1);
}
return q;
}

pub fn digit(c: u8) -> bool {
return ((c >= 48) && (c <= 57));
}

pub fn same(s: &[u8], w: &'static str) -> bool {
if (s.len() != w.len()) {
return false;
}
let mut k: usize = 0;
while (k < w.len()) {
if (s[(k) as usize] != w.as_bytes()[(k) as usize]) {
return false;
}
k = (k + 1);
}
return true;
}

pub fn starts(s: &[u8], lo: usize, hi: usize, w: &'static str) -> bool {
if ((hi - lo) < w.len()) {
return false;
}
return same(&s[(lo) as usize..((lo + w.len())) as usize], w);
}

16 changes: 5 additions & 11 deletions specs/tri/t27b/macho.t27
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,9 @@ pub fn group_size(lens: []const u8, from: usize, to: usize) -> usize {
return blob_off(lens, from, to - 1) + blob_len(lens, to - 1);
}

/// Copies src to out at `at`; the position after it.
pub fn put_bytes(out: []u8, at: usize, src: []const u8) -> usize {
var i : usize = 0;
while (i < src.len) {
out[at + i] = src[i];
i = i + 1;
}
return at + src.len;
}
/// Copies src to out at `at`; the position after it. One definition lives in
/// emit_kit (`use` below); this file splices it rather than re-copying it.
use tri::t27b::emit_kit; // put_bytes

/// Copies the blob bytes of blobs from .. to into out, blob k at base + its offset in the group.
pub fn put_group(out: []u8, base: usize, blobs: []const u8, lens: []const u8, from: usize, to: usize) -> void {
Expand All @@ -393,7 +387,7 @@ pub fn put_group(out: []u8, base: usize, blobs: []const u8, lens: []const u8, fr
var at : usize = 0;
while (k < to) {
const n : usize = blob_len(lens, k);
put_bytes(out, base + at, blobs[src..src + n]);
put_bytes(out, base + at, blobs, src, src + n);
src = src + n;
at = align_up(at + n, 8);
k = k + 1;
Expand Down Expand Up @@ -701,7 +695,7 @@ pub fn write_object(out: []u8, text: []const u8, names: []const u8, fns: []const
put_commands_x(out, text_size, const_size, nreloc, nlocal, nextdef, nimp, macho_strsize(names, fns, refs, nblobs));
const toff : usize = text_off(const_size);
const ca : usize = const_addr(text_size);
put_bytes(out, toff, text);
put_bytes(out, toff, text, 0, text.len);
put_group(out, toff + ca, blobs, lens, 0, nblobs);
const rel : usize = reloff(text_size, const_size);
const syo : usize = syms_at(text_size, const_size, nreloc);
Expand Down
4 changes: 3 additions & 1 deletion tools/duplicate_bodies_baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pow2_frac 3
present 3
publish_result_to_string 3
put_all 3,3
put_dec 3
put_dec 3,2
skip_digits 3
skip_ws 3,2
starts_with_at 3
Expand Down Expand Up @@ -267,6 +267,7 @@ fd_push 2
feed 2
field_len 2
fin 2
find 2
find_byte 2
find_child 2
find_geom 2
Expand Down Expand Up @@ -494,6 +495,7 @@ push_fdri 2
push_utf8 2
put 2
put1 2
put_bytes 2
put_css_px 2
put_item 2
put_kid 2
Expand Down
Loading