From 86d5f4ffd5734183b37487aac3ed3c1ab3e7b94a Mon Sep 17 00:00:00 2001 From: Romain Giot Date: Mon, 21 Aug 2023 11:45:26 +0200 Subject: [PATCH] [basm] More fix in the progress handing --- cpclib-asm/src/assembler/mod.rs | 30 ++++++++++++++++----- cpclib-asm/src/assembler/processed_token.rs | 5 ++-- cpclib-asm/src/assembler/stable_ticker.rs | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cpclib-asm/src/assembler/mod.rs b/cpclib-asm/src/assembler/mod.rs index 90e3b27e..46a0e9e0 100644 --- a/cpclib-asm/src/assembler/mod.rs +++ b/cpclib-asm/src/assembler/mod.rs @@ -674,10 +674,13 @@ impl Env { Ok(()) } }, - (false, AssemblingPass::ListingPass) => Err(AssemblerError::IncoherentCode{msg: format!( + (false, AssemblingPass::ListingPass) => { + panic!(); + Err(AssemblerError::IncoherentCode{msg: format!( "Label {} is not present in the symbol table in pass {}. There is an issue with some conditional code.", label, self.pass - )}), + )}) + }, (false, AssemblingPass::FirstPass) | (false, AssemblingPass::Uninitialized) => { self.symbols_mut() .set_symbol_to_value(label, value)?; @@ -872,8 +875,10 @@ impl Env { } self.symbols.new_pass(); - #[cfg(not(target_arch = "wasm32"))] - Progress::progress().new_pass(); + if self.options.show_progress() { + #[cfg(not(target_arch = "wasm32"))] + Progress::progress().new_pass(); + } } } @@ -1064,8 +1069,10 @@ impl Env { .map(|b| b.1.nb_files_to_save() as u64) .sum::() as u64; - Progress::progress().create_save_bar(nb_files_to_save); - + if self.options.show_progress() { + Progress::progress().create_save_bar(nb_files_to_save); + } + // save from snapshot for (activepage, page) in pages_mmr[0..self.pages_info_sna.len()].iter().enumerate() { // eprintln!("ACTIVEPAGE. {:x}", &activepage); @@ -3643,7 +3650,16 @@ pub fn visit_stableticker( StableTickerAction::Stop => { match env.stable_counters.release_last_counter() { None => Err(AssemblerError::NoActiveCounter), - Some((label, count)) => env.add_symbol_to_symbol_table(&label, count) + Some((label, count)) => { + if env.pass.is_listing_pass() { + // force the injection of the value + env.symbols_mut() + .set_symbol_to_value(label, count)?; + Ok(()) + } else { + env.add_symbol_to_symbol_table(&label, count) + } + } } } } diff --git a/cpclib-asm/src/assembler/processed_token.rs b/cpclib-asm/src/assembler/processed_token.rs index 08c3696b..bdd9cd62 100644 --- a/cpclib-asm/src/assembler/processed_token.rs +++ b/cpclib-asm/src/assembler/processed_token.rs @@ -475,7 +475,7 @@ where match parse_z80_with_context_builder(content, ctx_builder) { Ok(listing) => { // Filename has already been added - if token.include_is_standard_include() { + if token.include_is_standard_include() && options.show_progress { Progress::progress().remove_parse(progress::normalize(&fname)); } @@ -621,7 +621,7 @@ where .collect::>(); // inform the progress bar - if !include_fnames.is_empty() { + if !include_fnames.is_empty() && options.show_progress { // add all fnames in one time Progress::progress().add_parses(include_fnames.iter().map(|t| progress::normalize(t))); } @@ -661,6 +661,7 @@ where token.visited(env)?; visited += 1; } + Progress::progress().add_visited_to_pass(visited); } } diff --git a/cpclib-asm/src/assembler/stable_ticker.rs b/cpclib-asm/src/assembler/stable_ticker.rs index d5b26f1b..e46822cd 100644 --- a/cpclib-asm/src/assembler/stable_ticker.rs +++ b/cpclib-asm/src/assembler/stable_ticker.rs @@ -3,7 +3,7 @@ use std::borrow::Borrow; use crate::error::AssemblerError; /// Manage the stack of stable counters. -/// They are updated each time an opcode is visited +/// They are updated each time an opcode is visited as well #[derive(Default, Clone)] pub struct StableTickerCounters { counters: Vec<(String, usize)>