From 2a1eefb8c2d050e1a0cbce45c47b7391d331bb45 Mon Sep 17 00:00:00 2001 From: Nicolas Abril Date: Mon, 27 May 2024 12:49:34 +0200 Subject: [PATCH] Fix gen-cu and gen-c commands after move to hvm ast --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 15383824..da20c41d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,7 +62,7 @@ dependencies = [ [[package]] name = "bend-lang" -version = "0.2.22" +version = "0.2.23" dependencies = [ "TSPL", "clap", diff --git a/Cargo.toml b/Cargo.toml index 0c806775..9fe0f30c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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/"] diff --git a/src/main.rs b/src/main.rs index f5ed2f9b..4f27c9f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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}");