Merge compiler and emulator progress from last few months into main. #11
@@ -20,8 +20,6 @@ int greater(int a, int b) {
|
||||
}
|
||||
|
||||
int main() {
|
||||
printnum(greater(5, add_(5, 5)));
|
||||
|
||||
printnum(factorial(5));
|
||||
printnum(-5);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
use std::sync::LazyLock;
|
||||
use std::sync::atomic::AtomicU32;
|
||||
use std::time::SystemTime;
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use chrono::{DateTime, Local};
|
||||
|
||||
@@ -24,10 +24,7 @@ pub struct CodeGenerator {
|
||||
}
|
||||
|
||||
static GLOBAL_METHODS: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
|
||||
hash_map! {
|
||||
"print" => "print::print",
|
||||
"printnum" => "print::print_num"
|
||||
}
|
||||
HashMap::from([("print", "print::print"), ("printnum", "print::print_num")])
|
||||
});
|
||||
|
||||
fn import(name: &str, path: &str) -> String {
|
||||
@@ -183,7 +180,7 @@ impl CodeGenerator {
|
||||
for (i, param) in params.iter().enumerate() {
|
||||
let offset = 8 + (i as i32 * 4); // Parameters start at bpr+8
|
||||
// Track that this parameter is at a stack location
|
||||
let (reg, mut load_code) = self.allocator.alloc_var(¶m.name).unwrap();
|
||||
let (reg, load_code) = self.allocator.alloc_var(¶m.name).unwrap();
|
||||
code.extend(load_code);
|
||||
code.push(format!("\tldw bpr, {}, {}", reg, offset));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![feature(hash_map_macro)]
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use crate::{codegen::CodeGenerator, lexer::Lexer, parser::Parser};
|
||||
|
||||
Reference in New Issue
Block a user