Skip to content

Commit

Permalink
[basm] More fix in the progress handing
Browse files Browse the repository at this point in the history
  • Loading branch information
rgiot committed Aug 21, 2023
1 parent 8964b49 commit 86d5f4f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
30 changes: 23 additions & 7 deletions cpclib-asm/src/assembler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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();
}
}
}

Expand Down Expand Up @@ -1064,8 +1069,10 @@ impl Env {
.map(|b| b.1.nb_files_to_save() as u64)
.sum::<u64>() 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);
Expand Down Expand Up @@ -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)
}
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions cpclib-asm/src/assembler/processed_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -621,7 +621,7 @@ where
.collect::<Vec<_>>();

// 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)));
}
Expand Down Expand Up @@ -661,6 +661,7 @@ where
token.visited(env)?;
visited += 1;
}

Progress::progress().add_visited_to_pass(visited);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cpclib-asm/src/assembler/stable_ticker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>
Expand Down

0 comments on commit 86d5f4f

Please sign in to comment.