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
18 changes: 9 additions & 9 deletions .trinity/seals/t27o_T27oRust.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
"built_by": "t27c-bootstrap@0.5.2+b258b9007",
"closure": [],
"config": "gen=c,rust,verilog,zig;tests=zig",
"gen_hash_c": "sha256:eb5230aa674e89d821c62094685b31e15bb3f1e6e0fa14c0f99198d1fa248770",
"gen_hash_rust": "sha256:15fce2e7366e1bb135ae9fcf6d34e8b7b8177e4e22d09069112b06b584635a69",
"gen_hash_verilog": "sha256:ea35ca3d1c18655fac83f20b17c3c8a04c78e727da9e18ae074f95870c8cba1b",
"gen_hash_zig": "sha256:1f0284cf8883747e351d13a0e4e8d6de036c37b4633fa1d8fd6890c741d4aaf5",
"gen_hash_c": "sha256:b8e42e85b2ccd7e591ca3b485fee80244056e0cd01bebeea25b14aa73bd89e68",
"gen_hash_rust": "sha256:fdac1e1c4eeebc210cf0e4787f858970791f93b25b51672fb930e3a86668525e",
"gen_hash_verilog": "sha256:9019dde0e27c80177a221ab7e74eb64d0264c1b52d2d0116cde1bb0c55f5e75f",
"gen_hash_zig": "sha256:531c54a26c50418065283f6c78ea153d2f3b98bc4f2d6531e79cf2d3b5ab776c",
"module": "T27oRust",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-19T17:29:12Z",
"sealed_at": "2026-10-19T18:50:55Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:ad23e8ee46f5bda72c23c1a428b323660b5cf66da17ed942286834c0bc0b60e2",
"spec_hash": "sha256:455dc21c58322da101de1ade5ebc45e713e35b895861860b85709706297d345f",
"spec_path": "specs/tools/t27o/rust_convert.t27",
"tests": {
"failed": 0,
"failing": [],
"forced": false,
"passed": 353,
"total": 353,
"passed": 363,
"total": 363,
"vacuous": 0
},
"toolchain": {
"test_runner": "missing",
"test_runner": "sha256:8512b80da533b79289110fca4a65f3336abd7a059ca4b72ea595d5e33ff8ad10",
"zig": "0.16.0"
}
}
115 changes: 82 additions & 33 deletions gen/rust/tools/t27o/rust_convert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Generated from .t27 spec
// DO NOT EDIT — generated by t27c
// NOT LOWERED BY THIS BACKEND: 353 test(s), 0 invariant(s), 0 function(s) with no body.
// NOT LOWERED BY THIS BACKEND: 363 test(s), 0 invariant(s), 0 function(s) with no body.
// This backend emits declarations only. The spec's checks live in
// the Zig and Verilog outputs; do not read this file as verified.

Expand Down Expand Up @@ -108,6 +108,8 @@ pub const CCNT: usize = 50;

pub const DCAP: usize = 64;

pub const PAIR_N: usize = 3;

pub const LNPOS: usize = 51;

pub const LNNL: usize = 52;
Expand All @@ -126,7 +128,9 @@ pub const IXBN: usize = 57;

pub const IXTOP: usize = 58;

pub const NAMES: usize = 59;
pub const PAIRS: usize = 59;

pub const NAMES: usize = 60;

pub const NAME_SLOTS: usize = 5;

Expand Down Expand Up @@ -326,6 +330,8 @@ pub const R_VECOUT: usize = 44;

pub const R_VECCALL: usize = 45;

pub const R_STRCALL: usize = 46;

pub const R_FLOATLIT: usize = 43;

pub const R_NOPRELUDE: usize = 40;
Expand Down Expand Up @@ -1454,7 +1460,7 @@ pub fn deps(src: &[u8], st: &mut [usize], lo: usize, hi: usize) -> () {
while ((sq < hi) && (st[(ERR) as usize] == 0)) {
let se: usize = tok_end(src, sq);
if word_is(src, sq, se, b"self") {
refuse(st, R_DEPENDS, sq, sq, se);
refuse(st, R_DEPENDS, sq, st[(ILO) as usize], st[(IHI) as usize]);
}
sq = skip_ws(src, se);
}
Expand Down Expand Up @@ -1489,13 +1495,14 @@ pub fn deps(src: &[u8], st: &mut [usize], lo: usize, hi: usize) -> () {
if ((kind == K_ITEM) || (kind == K_EXT)) {
hit = (((!(after_dot) && !(after_path)) && !(after_fn)) && !(tok_is(src, nx, b":")));
}
if ((kind == K_VECFN) && (st[((s + 2)) as usize] == st[((s + 3)) as usize])) {
let outfn: bool = ((kind == K_VECFN) || (kind == K_STRFN));
if (outfn && (st[((s + 2)) as usize] == st[((s + 3)) as usize])) {
hit = (((call && !(after_dot)) && !(after_path)) && !(after_fn));
}
if ((((kind == K_VECFN) && (st[((s + 2)) as usize] != st[((s + 3)) as usize])) && after_dot) && call) {
if (((outfn && (st[((s + 2)) as usize] != st[((s + 3)) as usize])) && after_dot) && call) {
hit = true;
}
if ((((kind == K_VECFN) && (st[((s + 2)) as usize] != st[((s + 3)) as usize])) && after_path) && (p1 < src.len())) {
if (((outfn && (st[((s + 2)) as usize] != st[((s + 3)) as usize])) && after_path) && (p1 < src.len())) {
hit = (same_text(src, st[((s + 2)) as usize], st[((s + 3)) as usize], p1, tok_end(src, p1)) || tok_is(src, p1, b"Self"));
}
if (hit && (kind == K_EXT)) {
Expand All @@ -1504,7 +1511,10 @@ pub fn deps(src: &[u8], st: &mut [usize], lo: usize, hi: usize) -> () {
if (hit && (kind == K_VECFN)) {
refuse(st, R_VECCALL, q, q, e);
}
if ((hit && (kind != K_EXT)) && (kind != K_VECFN)) {
if (hit && (kind == K_STRFN)) {
refuse(st, R_STRCALL, q, q, e);
}
if ((hit && (kind != K_EXT)) && !(outfn)) {
refuse(st, R_DEPENDS, q, q, e);
}
}
Expand All @@ -1515,7 +1525,7 @@ pub fn deps(src: &[u8], st: &mut [usize], lo: usize, hi: usize) -> () {
let c2: usize = skip_ws(src, tok_end(src, c1));
let self_call: bool = (((((tok_is(src, c1, b"::") && (c2 < src.len())) && is_alpha(src[(c2) as usize])) && !(is_upper(src[(c2) as usize]))) && tok_is(src, skip_ws(src, tok_end(src, c2)), b"(")) && declared_fn(src, st, c2, tok_end(src, c2)));
if !(self_call) {
refuse(st, R_DEPENDS, q, q, e);
refuse(st, R_DEPENDS, q, st[(ILO) as usize], st[(IHI) as usize]);
}
}
if ((((((((st[(ERR) as usize] == 0) && call) && !(after_dot)) && !(after_path)) && !(after_fn)) && !(is_upper(src[(q) as usize]))) && !(call_keyword(src, q, e))) && !(declared_fn(src, st, q, e))) {
Expand Down Expand Up @@ -7870,10 +7880,14 @@ pub fn put_reason(src: &[u8], st: &mut [usize], out: &mut [u8]) -> () {
if (c == R_VECCALL) {
puts(st, out, b"a call of a fn whose Vec result is the caller's out buffer (an unbounded list the caller would own)");
} else {
if (c == R_SPLICE) {
puts(st, out, b"a used module t27c cannot splice beside type_text (its own use stays unresolved, or its same clashes with type_text's, the gap specs/compiler/int_type_names.t27 records)");
if (c == R_STRCALL) {
puts(st, out, b"a call of a fn whose String result is the caller's out buffer (the caller would own a buffer of no stated length)");
} else {
puts(st, out, b"syntax");
if (c == R_SPLICE) {
puts(st, out, b"a used module t27c cannot splice beside type_text (its own use stays unresolved, or its same clashes with type_text's, the gap specs/compiler/int_type_names.t27 records)");
} else {
puts(st, out, b"syntax");
}
}
}
}
Expand Down Expand Up @@ -8681,17 +8695,60 @@ pub fn num_value(src: &[u8], q: usize, te: usize) -> usize {
return v;
}

pub fn is_text_kind(kind: usize) -> bool {
return ((((kind == V_STR) || (kind == V_BYTES)) || (kind == V_STRING)) || (kind == V_RSTRING));
}

pub fn text_count(k0: usize, k1: usize, k2: usize, k3: usize, k4: usize) -> usize {
let mut n: usize = 0;
if is_text_kind(k0) {
n = (n + 1);
}
if is_text_kind(k1) {
n = (n + 1);
}
if is_text_kind(k2) {
n = (n + 1);
}
if is_text_kind(k3) {
n = (n + 1);
}
if is_text_kind(k4) {
n = (n + 1);
}
return n;
}

pub fn put_pair_sample(st: &mut [usize], out: &mut [u8], k: usize) -> () {
if (k == 1) {
puts(st, out, b"abc");
} else {
puts(st, out, b"abcabc");
}
}

pub fn derived_at(src: &[u8], st: &mut [usize], kind: usize, tq: usize, d: usize) -> bool {
st[(DCSP) as usize] = 0;
st[(DNEG) as usize] = 0;
if (st[(FBLO) as usize] >= st[(FBHI) as usize]) {
return false;
}
let text: bool = ((((kind == V_STR) || (kind == V_BYTES)) || (kind == V_STRING)) || (kind == V_RSTRING));
let text: bool = is_text_kind(kind);
let ints: bool = ((kind == V_UNSIGNED) || (kind == V_SIGNED));
if (!(text) && !(ints)) {
return false;
}
let mut c: usize = 0;
let mut per: usize = 2;
if (text && (st[(PAIRS) as usize] >= 2)) {
if (d < PAIR_N) {
st[(DCSP) as usize] = 2;
st[(DVAL) as usize] = d;
return true;
}
c = PAIR_N;
per = 3;
}
let mut w: usize = 0;
let mut sg: bool = false;
if ints {
Expand All @@ -8701,7 +8758,6 @@ pub fn derived_at(src: &[u8], st: &mut [usize], kind: usize, tq: usize, d: usize
return false;
}
}
let mut c: usize = 0;
let mut q: usize = st[(FBLO) as usize];
let mut neg: bool = false;
while (q < st[(FBHI) as usize]) {
Expand All @@ -8715,41 +8771,27 @@ pub fn derived_at(src: &[u8], st: &mut [usize], kind: usize, tq: usize, d: usize
}
}
if ((text && (src[(q) as usize] == B_QUOTE)) && clean_text(src, (q + 1), (te - 1))) {
if (c == d) {
if ((d >= c) && (d < (c + per))) {
st[(DCLA) as usize] = (q + 1);
st[(DCLB) as usize] = (te - 1);
st[(DCSP) as usize] = 0;
st[(DCSP) as usize] = ((d - c) % 2);
return true;
}
c = (c + 1);
if (c == d) {
st[(DCLA) as usize] = (q + 1);
st[(DCLB) as usize] = (te - 1);
st[(DCSP) as usize] = 1;
return true;
}
c = (c + 1);
c = (c + per);
}
if (text && ((((src[(q) as usize] == B_LOWER_B) && ((q + 1) < st[(FBHI) as usize])) && (src[((q + 1)) as usize] == B_QUOTE)) || (((src[(q) as usize] == B_LOWER_R) && ((q + 1) < st[(FBHI) as usize])) && ((src[((q + 1)) as usize] == B_QUOTE) || (src[((q + 1)) as usize] == B_HASH))))) {
let mut h: usize = 0;
while (((src[(q) as usize] == B_LOWER_R) && (((q + 1) + h) < te)) && (src[(((q + 1) + h)) as usize] == B_HASH)) {
h = (h + 1);
}
if clean_text(src, ((q + 2) + h), ((te - 1) - h)) {
if (c == d) {
if ((d >= c) && (d < (c + per))) {
st[(DCLA) as usize] = ((q + 2) + h);
st[(DCLB) as usize] = ((te - 1) - h);
st[(DCSP) as usize] = 0;
st[(DCSP) as usize] = ((d - c) % 2);
return true;
}
c = (c + 1);
if (c == d) {
st[(DCLA) as usize] = ((q + 2) + h);
st[(DCLB) as usize] = ((te - 1) - h);
st[(DCSP) as usize] = 1;
return true;
}
c = (c + 1);
c = (c + per);
}
}
if ((((((text && (src[(q) as usize] == B_LOWER_B)) && ((q + 1) < st[(FBHI) as usize])) && (src[((q + 1)) as usize] == B_APOS)) && (te == (q + 4))) && (src[((q + 3)) as usize] == B_APOS)) && clean_text(src, (q + 2), (q + 3))) {
Expand Down Expand Up @@ -9057,6 +9099,11 @@ pub fn put_value(src: &[u8], st: &mut [usize], out: &mut [u8], kind: usize, tq:
}
put_quote(st, out, rust);
if ((k >= base) && derived_at(src, st, kind, tq, (k - base))) {
if (st[(DCSP) as usize] == 2) {
put_pair_sample(st, out, st[(DVAL) as usize]);
put_quote(st, out, rust);
return ();
}
if (st[(DCSP) as usize] == 1) {
puts(st, out, b" ");
}
Expand Down Expand Up @@ -9626,6 +9673,7 @@ pub fn vectors(src: &[u8], st: &mut [usize], out: &mut [u8], na: usize, nb: usiz
st[(FBHI) as usize] = (be - 1);
}
}
st[(PAIRS) as usize] = text_count(k0, k1, k2, k3, k4);
let mut nv: usize = 1;
if (n > 0) {
nv = slen(src, st, k0, t0);
Expand Down Expand Up @@ -9758,6 +9806,7 @@ pub fn vectors(src: &[u8], st: &mut [usize], out: &mut [u8], na: usize, nb: usiz
}
put_src(src, st, out, na, nb);
puts(st, out, b" {{\"); for l in &v { println!(\"{}\", l); } println!(\"}}\\n\"); }\n }\n");
st[(PAIRS) as usize] = 0;
}

pub fn ret_is_string(src: &[u8], pn: usize) -> bool {
Expand Down
Loading
Loading