mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
Output file and line info.
This commit is contained in:
@@ -606,12 +606,22 @@ fn runtime() -> &'static str {
|
||||
fn process_statement(s: Statement) -> Vec<String> {
|
||||
match &s {
|
||||
Statement::Label(l) => vec![format!("{}::", escape_label(l))],
|
||||
Statement::Directive(directive, args) => match directive.as_str() {
|
||||
".loc" => {
|
||||
vec![]
|
||||
Statement::Directive(directive, args) => match (directive.as_str(), &args[..]) {
|
||||
(
|
||||
".loc",
|
||||
[Argument::Expression(Expression::Number(file)), Argument::Expression(Expression::Number(line)), Argument::Expression(Expression::Number(column)), ..],
|
||||
) => {
|
||||
vec![format!("debug loc {file}, {line}, {column};")]
|
||||
}
|
||||
".file" => {
|
||||
vec![]
|
||||
(
|
||||
".file",
|
||||
[Argument::Expression(Expression::Number(file_nr)), Argument::StringLiteral(directory), Argument::StringLiteral(file)],
|
||||
) => {
|
||||
vec![format!(
|
||||
"debug file {file_nr}, {}, {};",
|
||||
quote(std::str::from_utf8(directory).unwrap()),
|
||||
quote(std::str::from_utf8(file).unwrap())
|
||||
)]
|
||||
}
|
||||
_ if directive.starts_with(".cfi_") => vec![],
|
||||
_ => panic!(
|
||||
@@ -626,6 +636,11 @@ fn process_statement(s: Statement) -> Vec<String> {
|
||||
}
|
||||
}
|
||||
|
||||
fn quote(s: &str) -> String {
|
||||
// TODO more things to quote
|
||||
format!("\"{}\"", s.replace('\\', "\\\\").replace('\"', "\\\""))
|
||||
}
|
||||
|
||||
fn escape_label(l: &str) -> String {
|
||||
// TODO make this proper
|
||||
l.replace('.', "_dot_").replace('/', "_slash_")
|
||||
|
||||
Reference in New Issue
Block a user