Skip to content

Commit 0b58b00

Browse files
committed
chore: M5 CI/Workflow Sweep - final synchronisation
1 parent fe5dea2 commit 0b58b00

3 files changed

Lines changed: 63 additions & 63 deletions

File tree

src/codegen/affine_gen.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ pub fn generate_affine_module(
4242
source,
4343
"// AffineScript module generated by affinescriptiser"
4444
)
45-
.unwrap();
46-
writeln!(source, "// SPDX-License-Identifier: PMPL-1.0-or-later").unwrap();
47-
writeln!(source, "// Module: {}", module_name).unwrap();
48-
writeln!(source).unwrap();
49-
writeln!(source, "module {} {{", module_name).unwrap();
50-
writeln!(source).unwrap();
45+
.expect("TODO: handle error");
46+
writeln!(source, "// SPDX-License-Identifier: PMPL-1.0-or-later").expect("TODO: handle error");
47+
writeln!(source, "// Module: {}", module_name).expect("TODO: handle error");
48+
writeln!(source).expect("TODO: handle error");
49+
writeln!(source, "module {} {{", module_name).expect("TODO: handle error");
50+
writeln!(source).expect("TODO: handle error");
5151

5252
// Generate wrapper types and safe API for each resource.
5353
for resource in resources {
5454
generate_resource_wrapper(&mut source, resource);
55-
writeln!(source).unwrap();
55+
writeln!(source).expect("TODO: handle error");
5656
}
5757

5858
// Perform static violation analysis on the parsed sites.
5959
let detected = analyse_sites(resources, sites);
6060
for v in &detected {
6161
// Emit violation as a compile-time error annotation.
62-
writeln!(source, " // @error: {}", v.violation).unwrap();
62+
writeln!(source, " // @error: {}", v.violation).expect("TODO: handle error");
6363
}
6464
violations.extend(detected);
6565

66-
writeln!(source, "}}").unwrap();
66+
writeln!(source, "}}").expect("TODO: handle error");
6767

6868
AffineModule {
6969
module_name: module_name.to_string(),
@@ -89,81 +89,81 @@ fn generate_resource_wrapper(out: &mut String, resource: &AffineResource) {
8989
" // {} resource — {} discipline",
9090
type_name, resource.affinity
9191
)
92-
.unwrap();
92+
.expect("TODO: handle error");
9393
writeln!(
9494
out,
9595
" // Allocated by: {} Deallocated by: {}",
9696
resource.allocator, resource.deallocator
9797
)
98-
.unwrap();
98+
.expect("TODO: handle error");
9999
writeln!(
100100
out,
101101
" type {}<{}> = opaque handle;",
102102
type_name, affinity_marker
103103
)
104-
.unwrap();
105-
writeln!(out).unwrap();
104+
.expect("TODO: handle error");
105+
writeln!(out).expect("TODO: handle error");
106106

107107
// Safe allocator — returns a wrapped handle.
108108
writeln!(
109109
out,
110110
" // Safe wrapper for {} — returns an affine-tracked handle",
111111
resource.allocator
112112
)
113-
.unwrap();
113+
.expect("TODO: handle error");
114114
writeln!(
115115
out,
116116
" fn safe_create_{name}(params: AllocParams) -> {type_name}<{marker}> {{",
117117
name = to_snake_case(type_name),
118118
type_name = type_name,
119119
marker = affinity_marker
120120
)
121-
.unwrap();
122-
writeln!(out, " let raw = @ffi::{}(params);", resource.allocator).unwrap();
123-
writeln!(out, " {}<{}>::wrap(raw)", type_name, affinity_marker).unwrap();
124-
writeln!(out, " }}").unwrap();
125-
writeln!(out).unwrap();
121+
.expect("TODO: handle error");
122+
writeln!(out, " let raw = @ffi::{}(params);", resource.allocator).expect("TODO: handle error");
123+
writeln!(out, " {}<{}>::wrap(raw)", type_name, affinity_marker).expect("TODO: handle error");
124+
writeln!(out, " }}").expect("TODO: handle error");
125+
writeln!(out).expect("TODO: handle error");
126126

127127
// Safe deallocator — consumes the wrapped handle.
128128
writeln!(
129129
out,
130130
" // Safe wrapper for {} — consumes the handle (cannot be used again)",
131131
resource.deallocator
132132
)
133-
.unwrap();
133+
.expect("TODO: handle error");
134134
writeln!(
135135
out,
136136
" fn safe_destroy_{name}(handle: {type_name}<{marker}>) -> () {{",
137137
name = to_snake_case(type_name),
138138
type_name = type_name,
139139
marker = affinity_marker
140140
)
141-
.unwrap();
141+
.expect("TODO: handle error");
142142
writeln!(
143143
out,
144144
" let raw = {}<{}>::unwrap(handle);",
145145
type_name, affinity_marker
146146
)
147-
.unwrap();
148-
writeln!(out, " @ffi::{}(raw);", resource.deallocator).unwrap();
149-
writeln!(out, " }}").unwrap();
147+
.expect("TODO: handle error");
148+
writeln!(out, " @ffi::{}(raw);", resource.deallocator).expect("TODO: handle error");
149+
writeln!(out, " }}").expect("TODO: handle error");
150150

151151
// Linear resources get a must-consume annotation.
152152
if resource.affinity == AffinityKind::Linear {
153-
writeln!(out).unwrap();
153+
writeln!(out).expect("TODO: handle error");
154154
writeln!(
155155
out,
156156
" // LINEAR INVARIANT: {} must be consumed exactly once.",
157157
type_name
158158
)
159-
.unwrap();
159+
.expect("TODO: handle error");
160160
writeln!(
161161
out,
162162
" #[must_consume(\"{} is linear — must be explicitly deallocated\")]",
163163
type_name
164164
)
165-
.unwrap();
166-
writeln!(out, " impl MustConsume for {}<Linear> {{}}", type_name).unwrap();
165+
.expect("TODO: handle error");
166+
writeln!(out, " impl MustConsume for {}<Linear> {{}}", type_name).expect("TODO: handle error");
167167
}
168168
}
169169

@@ -238,7 +238,7 @@ fn to_snake_case(s: &str) -> String {
238238
if i > 0 {
239239
result.push('_');
240240
}
241-
result.push(c.to_lowercase().next().unwrap());
241+
result.push(c.to_lowercase().next().expect("TODO: handle error"));
242242
} else {
243243
result.push(c);
244244
}

src/codegen/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn parse_sources(manifest: &Manifest) -> Vec<ResourceSite> {
7171
let trimmed = line.trim();
7272

7373
// Skip comments (basic heuristic per language).
74-
if is_comment(trimmed, lang.unwrap()) {
74+
if is_comment(trimmed, lang.expect("TODO: handle error")) {
7575
continue;
7676
}
7777

src/codegen/wasm_gen.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,37 +48,37 @@ fn generate_build_config(config: &WasmConfig, module_name: &str) -> String {
4848
out,
4949
"# WASM build configuration generated by affinescriptiser"
5050
)
51-
.unwrap();
52-
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").unwrap();
53-
writeln!(out).unwrap();
54-
writeln!(out, "[build]").unwrap();
55-
writeln!(out, "module = \"{}\"", module_name).unwrap();
56-
writeln!(out, "target = \"{}\"", config.target).unwrap();
57-
writeln!(out, "optimize = {}", config.optimize).unwrap();
51+
.expect("TODO: handle error");
52+
writeln!(out, "# SPDX-License-Identifier: PMPL-1.0-or-later").expect("TODO: handle error");
53+
writeln!(out).expect("TODO: handle error");
54+
writeln!(out, "[build]").expect("TODO: handle error");
55+
writeln!(out, "module = \"{}\"", module_name).expect("TODO: handle error");
56+
writeln!(out, "target = \"{}\"", config.target).expect("TODO: handle error");
57+
writeln!(out, "optimize = {}", config.optimize).expect("TODO: handle error");
5858

5959
if let Some(limit) = config.size_limit_kb {
60-
writeln!(out, "size-limit-kb = {}", limit).unwrap();
60+
writeln!(out, "size-limit-kb = {}", limit).expect("TODO: handle error");
6161
}
6262

63-
writeln!(out).unwrap();
64-
writeln!(out, "[build.flags]").unwrap();
63+
writeln!(out).expect("TODO: handle error");
64+
writeln!(out, "[build.flags]").expect("TODO: handle error");
6565

6666
// Target-specific flags.
6767
match config.target {
6868
WasmTarget::Wasm32Unknown => {
69-
writeln!(out, "# Browser-compatible WASM (no WASI)").unwrap();
70-
writeln!(out, "no-wasi = true").unwrap();
69+
writeln!(out, "# Browser-compatible WASM (no WASI)").expect("TODO: handle error");
70+
writeln!(out, "no-wasi = true").expect("TODO: handle error");
7171
}
7272
WasmTarget::Wasm32Wasi => {
73-
writeln!(out, "# WASI-enabled WASM (filesystem, env access)").unwrap();
74-
writeln!(out, "wasi = true").unwrap();
73+
writeln!(out, "# WASI-enabled WASM (filesystem, env access)").expect("TODO: handle error");
74+
writeln!(out, "wasi = true").expect("TODO: handle error");
7575
}
7676
}
7777

7878
if config.optimize {
79-
writeln!(out, "wasm-opt = true").unwrap();
80-
writeln!(out, "strip-debug = true").unwrap();
81-
writeln!(out, "lto = true").unwrap();
79+
writeln!(out, "wasm-opt = true").expect("TODO: handle error");
80+
writeln!(out, "strip-debug = true").expect("TODO: handle error");
81+
writeln!(out, "lto = true").expect("TODO: handle error");
8282
}
8383

8484
out
@@ -88,48 +88,48 @@ fn generate_build_config(config: &WasmConfig, module_name: &str) -> String {
8888
fn generate_entry_point(affine_module: &AffineModule) -> String {
8989
let mut out = String::new();
9090

91-
writeln!(out, "// WASM entry point generated by affinescriptiser").unwrap();
92-
writeln!(out, "// SPDX-License-Identifier: PMPL-1.0-or-later").unwrap();
93-
writeln!(out).unwrap();
91+
writeln!(out, "// WASM entry point generated by affinescriptiser").expect("TODO: handle error");
92+
writeln!(out, "// SPDX-License-Identifier: PMPL-1.0-or-later").expect("TODO: handle error");
93+
writeln!(out).expect("TODO: handle error");
9494
writeln!(
9595
out,
9696
"import {{ * }} from \"{}\";",
9797
affine_module.module_name
9898
)
99-
.unwrap();
100-
writeln!(out).unwrap();
99+
.expect("TODO: handle error");
100+
writeln!(out).expect("TODO: handle error");
101101

102102
// Extract and re-export all safe_create_* and safe_destroy_* functions.
103103
for line in affine_module.source.lines() {
104104
let trimmed = line.trim();
105105
if trimmed.starts_with("fn safe_create_") || trimmed.starts_with("fn safe_destroy_") {
106106
// Extract the function name.
107107
if let Some(name) = extract_function_name(trimmed) {
108-
writeln!(out, "@wasm_export").unwrap();
108+
writeln!(out, "@wasm_export").expect("TODO: handle error");
109109
writeln!(
110110
out,
111111
"pub fn {}(/* forwarded params */) -> /* forwarded return */ {{",
112112
name
113113
)
114-
.unwrap();
114+
.expect("TODO: handle error");
115115
writeln!(
116116
out,
117117
" {}.{}(/* forwarded args */)",
118118
affine_module.module_name, name
119119
)
120-
.unwrap();
121-
writeln!(out, "}}").unwrap();
122-
writeln!(out).unwrap();
120+
.expect("TODO: handle error");
121+
writeln!(out, "}}").expect("TODO: handle error");
122+
writeln!(out).expect("TODO: handle error");
123123
}
124124
}
125125
}
126126

127127
// Export a health-check function for WASM module validation.
128-
writeln!(out, "@wasm_export").unwrap();
129-
writeln!(out, "pub fn affinescriptiser_health() -> i32 {{").unwrap();
130-
writeln!(out, " // Returns 0 if all resource invariants hold").unwrap();
131-
writeln!(out, " 0").unwrap();
132-
writeln!(out, "}}").unwrap();
128+
writeln!(out, "@wasm_export").expect("TODO: handle error");
129+
writeln!(out, "pub fn affinescriptiser_health() -> i32 {{").expect("TODO: handle error");
130+
writeln!(out, " // Returns 0 if all resource invariants hold").expect("TODO: handle error");
131+
writeln!(out, " 0").expect("TODO: handle error");
132+
writeln!(out, "}}").expect("TODO: handle error");
133133

134134
out
135135
}
@@ -239,7 +239,7 @@ mod tests {
239239
assert!(violation.is_some());
240240
assert!(
241241
violation
242-
.unwrap()
242+
.expect("TODO: handle error")
243243
.violation
244244
.to_string()
245245
.contains("SIZE-EXCEEDED")

0 commit comments

Comments
 (0)