mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
feat: more verbose-y log
This commit is contained in:
parent
7618eaa04a
commit
2416a77f61
|
@ -33,7 +33,7 @@ impl Display for Register {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Instr {
|
pub enum Instr {
|
||||||
// Load a literal value onto the stack.
|
// Load a literal value onto the stack.
|
||||||
Load { address: Register, label: usize },
|
// Load { address: Register, label: usize },
|
||||||
// Store a literal value into a register.
|
// Store a literal value into a register.
|
||||||
Store { address: Register, value: Type, label: usize },
|
Store { address: Register, value: Type, label: usize },
|
||||||
// Call intrinsic function.
|
// Call intrinsic function.
|
||||||
|
@ -53,7 +53,7 @@ pub enum Instr {
|
||||||
impl Display for Instr {
|
impl Display for Instr {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Instr::Load { address, label } => write!(f, "{}: LOAD {}", label, address),
|
// Instr::Load { address, label } => write!(f, "{}: LOAD {}", label, address),
|
||||||
Instr::Store { address, value , label} => write!(f, "{}: STORE {} {}", label, address, value),
|
Instr::Store { address, value , label} => write!(f, "{}: STORE {} {}", label, address, value),
|
||||||
Instr::Call { address, args, label } => write!(f, "{}: CALL {} {}", label, address, args),
|
Instr::Call { address, args, label } => write!(f, "{}: CALL {} {}", label, address, args),
|
||||||
Instr::IAdd { lhs, rhs, to, label } => write!(f, "{}: IADD {} {} {}", label, lhs, rhs, to),
|
Instr::IAdd { lhs, rhs, to, label } => write!(f, "{}: IADD {} {} {}", label, lhs, rhs, to),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{fs::{read_to_string, File}, path::Path, io::Write};
|
use std::{fs::{read_to_string, File}, path::Path, io::Write, time::Instant};
|
||||||
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ mod compiler;
|
||||||
use compiler::compile::Compiler;
|
use compiler::compile::Compiler;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let start = Instant::now();
|
||||||
let args = Args::from_args();
|
let args = Args::from_args();
|
||||||
|
|
||||||
let src = cover_paren(read_to_string(&args.file).unwrap());
|
let src = cover_paren(read_to_string(&args.file).unwrap());
|
||||||
|
@ -29,14 +30,45 @@ fn main() {
|
||||||
let mut file = File::create(format!("{}.bbb", file_name)).unwrap();
|
let mut file = File::create(format!("{}.bbb", file_name)).unwrap();
|
||||||
|
|
||||||
let mut compiler = Compiler::new();
|
let mut compiler = Compiler::new();
|
||||||
|
let before = Instant::now();
|
||||||
for instr in compiler.compile(result.unwrap(), 0).unwrap() {
|
for instr in compiler.compile(result.unwrap(), 0).unwrap() {
|
||||||
write!(file, "{}\n", instr).unwrap();
|
write!(file, "{}\n", instr).unwrap();
|
||||||
}
|
}
|
||||||
|
let spent = before.elapsed();
|
||||||
|
let total = start.elapsed();
|
||||||
|
|
||||||
|
println!("Compiled in {}.{}s, Total of {}.{}s", spent.as_secs(), spent.subsec_millis(), total.as_secs(), total.subsec_millis());
|
||||||
|
},
|
||||||
|
1 => {
|
||||||
|
println!("Parsed AST: {:#?}", result);
|
||||||
|
|
||||||
|
let mut file = File::create(format!("{}.bbb", file_name)).unwrap();
|
||||||
|
|
||||||
|
let mut compiler = Compiler::new();
|
||||||
|
let before = Instant::now();
|
||||||
|
for instr in compiler.compile(result.unwrap(), 0).unwrap() {
|
||||||
|
write!(file, "{}\n", instr).unwrap();
|
||||||
|
}
|
||||||
|
let spent = before.elapsed();
|
||||||
|
let total = start.elapsed();
|
||||||
|
|
||||||
|
println!("Compiled in {}.{}s, Total of {}.{}s", spent.as_secs(), spent.subsec_millis(), total.as_secs(), total.subsec_millis());
|
||||||
},
|
},
|
||||||
1 => println!("{:?}", result),
|
|
||||||
2 | _ => {
|
2 | _ => {
|
||||||
println!("Tokens: {:?}", tokens);
|
println!("Tokens: {:?}", tokens);
|
||||||
println!("Parsed: {:#?}", result);
|
println!("Parsed AST: {:#?}", result);
|
||||||
|
|
||||||
|
let mut file = File::create(format!("{}.bbb", file_name)).unwrap();
|
||||||
|
|
||||||
|
let mut compiler = Compiler::new();
|
||||||
|
let before = Instant::now();
|
||||||
|
for instr in compiler.compile(result.unwrap(), 0).unwrap() {
|
||||||
|
write!(file, "{}\n", instr).unwrap();
|
||||||
|
}
|
||||||
|
let spent = before.elapsed();
|
||||||
|
let total = start.elapsed();
|
||||||
|
|
||||||
|
println!("Compiled in {}.{}s, Total of {}.{}s", spent.as_secs(), spent.subsec_millis(), total.as_secs(), total.subsec_millis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue