Skip to content

Commit

Permalink
more general fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas committed Nov 19, 2024
1 parent a4794e0 commit 0dfdb12
Show file tree
Hide file tree
Showing 5 changed files with 332 additions and 77 deletions.
6 changes: 0 additions & 6 deletions crates/steel-core/src/compiler/code_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,6 @@ impl<'a> VisitorMut for CodeGenerator<'a> {
// Just remove them otherwise
self.push(LabeledInstruction::builder(OpCode::EDEF));

// if let Some(elem) = self.instructions.get_mut(sidx) {
// (*elem).payload_size = defn_body_size;
// } else {
// stop!(Generic => "out of bounds closure len");
// }

// println!("binding global: {}", name);
self.push(LabeledInstruction::builder(OpCode::BIND).contents(name.syn.clone()));

Expand Down
10 changes: 9 additions & 1 deletion crates/steel-core/src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,14 @@ impl Compiler {
// println!("");
// steel_parser::ast::AstTools::pretty_print(&expanded_statements);

// log::info!(
// "{}",
// expanded_statements
// .iter()
// .map(|x| x.to_pretty(60))
// .join("\n\n")
// );

log::debug!(target: "expansion-phase", "Generating instructions");

let instructions = self.generate_instructions_for_executable(expanded_statements)?;
Expand All @@ -1046,7 +1054,7 @@ impl Compiler {
raw_program.apply_optimizations();

// Lets see everything that gets run!
// raw_program.debug_print();
// raw_program.debug_print_log();

Ok(raw_program)
}
Expand Down
6 changes: 6 additions & 0 deletions crates/steel-core/src/compiler/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,12 @@ impl RawProgramWithSymbols {
.for_each(|i| println!("{}\n\n", crate::core::instructions::disassemble(i)))
}

pub fn debug_print_log(&self) {
self.instructions
.iter()
.for_each(|i| log::info!("{}\n\n", crate::core::instructions::disassemble(i)))
}

/// Applies a peephole style optimization to the underlying instruction set
pub fn with_optimization<F: Fn(&mut [Instruction])>(&mut self, f: F) {
for instructions in &mut self.instructions {
Expand Down
Loading

0 comments on commit 0dfdb12

Please sign in to comment.