updated assembler logging
This commit is contained in:
@@ -14,8 +14,7 @@ pub fn codegen(nodes: Vec<Node>) -> Result<Vec<Instruction>, AssembleError> {
|
|||||||
instructions.push(build_instruction(&node)?);
|
instructions.push(build_instruction(&node)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("------------------------");
|
log("Assembly Successful ✅");
|
||||||
log("Compilation Success ✅");
|
|
||||||
|
|
||||||
Ok(instructions)
|
Ok(instructions)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ pub fn lexer(mut program: String, module: u64) -> Result<Vec<Token>, AssembleErr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:#?}", tokens);
|
// println!("{:#?}", tokens);
|
||||||
|
|
||||||
Ok(tokens)
|
Ok(tokens)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,9 @@ use std::{
|
|||||||
thread,
|
thread,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub use common::logging::log;
|
||||||
use common::prelude::Instruction;
|
use common::prelude::Instruction;
|
||||||
|
|
||||||
// TODO: Use an actual logging or tracing library for pretty (scoped) output.
|
|
||||||
fn log(message: &str) {
|
|
||||||
println!("\x1b[32mINFO:\x1b[0m {message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Module declarations
|
// Module declarations
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod macros;
|
pub mod macros;
|
||||||
@@ -138,12 +134,11 @@ fn assemble(src: &Path) -> Result<Vec<Instruction>, AssembleError> {
|
|||||||
create_sections(&mut nodes)?;
|
create_sections(&mut nodes)?;
|
||||||
resolve_symbols(&mut nodes)?;
|
resolve_symbols(&mut nodes)?;
|
||||||
|
|
||||||
println!("Generating assembly output...");
|
log("Generating assembly output...");
|
||||||
for n in &nodes {
|
|
||||||
println!("{n}");
|
|
||||||
}
|
|
||||||
|
|
||||||
let instructions = codegen(nodes)?;
|
let instructions = codegen(nodes)?;
|
||||||
|
|
||||||
|
log("Compilation Successful");
|
||||||
Ok(instructions)
|
Ok(instructions)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,10 +187,7 @@ fn prepare_dependency(
|
|||||||
|
|
||||||
let deps = Parser::get_dependencies(&nodes, path)?;
|
let deps = Parser::get_dependencies(&nodes, path)?;
|
||||||
|
|
||||||
log(&format!(
|
log(&format!("{:20} {:20}", "Expanding Pseudo-ops", filename));
|
||||||
"{:20} {:20}",
|
|
||||||
"Expanding PseudoInstructions", filename
|
|
||||||
));
|
|
||||||
|
|
||||||
// add a section instruction
|
// add a section instruction
|
||||||
nodes.insert(
|
nodes.insert(
|
||||||
@@ -203,9 +195,9 @@ fn prepare_dependency(
|
|||||||
node!(None, Opcode::Segment, Token::Immediate(file_hash as u32)),
|
node!(None, Opcode::Segment, Token::Immediate(file_hash as u32)),
|
||||||
);
|
);
|
||||||
|
|
||||||
for n in &nodes {
|
// for n in &nodes {
|
||||||
println!("{n}");
|
// println!("{n}");
|
||||||
}
|
// }
|
||||||
|
|
||||||
program.add_module(nodes);
|
program.add_module(nodes);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user