Fix gen-cu and gen-c commands after move to hvm ast

This commit is contained in:
Nicolas Abril 2024-05-27 12:49:34 +02:00
parent be9eaeb7cf
commit 2a1eefb8c2
3 changed files with 8 additions and 3 deletions

2
Cargo.lock generated
View File

@ -62,7 +62,7 @@ dependencies = [
[[package]]
name = "bend-lang"
version = "0.2.22"
version = "0.2.23"
dependencies = [
"TSPL",
"clap",

View File

@ -2,7 +2,7 @@
name = "bend-lang"
description = "A high-level, massively parallel programming language"
license = "Apache-2.0"
version = "0.2.22"
version = "0.2.23"
edition = "2021"
rust-version = "1.74"
exclude = ["tests/snapshots/"]

View File

@ -299,7 +299,8 @@ fn execute_cli_mode(mut cli: Cli) -> Result<(), Diagnostics> {
let compile_res = compile_book(&mut book, opts, diagnostics_cfg, None)?;
let out_path = ".out.hvm";
std::fs::write(out_path, compile_res.hvm_book.show()).map_err(|x| x.to_string())?;
std::fs::write(out_path, display_hvm_book(&compile_res.hvm_book).to_string())
.map_err(|x| x.to_string())?;
let gen_fn = |out_path: &str| {
let mut process = std::process::Command::new("hvm");
@ -312,6 +313,10 @@ fn execute_cli_mode(mut cli: Cli) -> Result<(), Diagnostics> {
let err = String::from_utf8_lossy(&stderr);
let status = if !status.success() { status.to_string() } else { String::new() };
if let Err(e) = std::fs::remove_file(out_path) {
eprintln!("Error removing HVM output file. {e}");
}
eprintln!("{err}");
println!("{out}");
println!("{status}");