Skip to content

Commit

Permalink
[cpclib-asm] Ensure some warnings are print as warning and not errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty/Benediction committed Jul 15, 2024
1 parent edfbdf3 commit b2990d4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 2 additions & 6 deletions cpclib-asm/src/assembler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3355,12 +3355,8 @@ pub fn visit_located_token(
let nb_additional_warnings = env.warnings.len() - nb_warnings;
for i in 0..nb_additional_warnings {
let warning = &mut env.warnings[i + nb_warnings];
if !warning.is_located() {
*warning = AssemblerError::RelocatedWarning {
warning: Box::new(warning.clone()),
span: span.clone()
};
}
*warning = warning.clone().locate_warning(span.clone());

// TODO check why it has been done this way
// maybe source code is not retrained and there are random crashes ?
// anyway I comment it now because it breaks warning merge
Expand Down
2 changes: 1 addition & 1 deletion cpclib-asm/src/assembler/processed_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ where
msg: format!("Header has been removed for {txt}")
};
let warning = if let Some(span) = possible_span {
warning.locate(span.clone())
warning.locate_warning(span.clone())
}
else {
warning
Expand Down
12 changes: 12 additions & 0 deletions cpclib-asm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,18 @@ impl AssemblerError {
}
}
}

pub fn locate_warning(self, span: Z80Span) -> Self {
if self.is_located() {
self
}
else {
AssemblerError::RelocatedWarning {
span,
warning: Box::new(self)
}
}
}
}

pub(crate) const LD_WRONG_SOURCE: &'static str = "LD: error in the source";
Expand Down
5 changes: 4 additions & 1 deletion cpclib-visual-bndbuild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ impl BndBuildApp {
ui.menu_button("Open Recent", |ui| {
for fname in self.recent_files.clone().iter().rev() {
if ui
.add(Button::new(fname.display().to_string()).wrap_mode(egui::TextWrapMode::Extend))
.add(
Button::new(fname.display().to_string())
.wrap_mode(egui::TextWrapMode::Extend)
)
.clicked()
{
self.load(fname);
Expand Down

0 comments on commit b2990d4

Please sign in to comment.