1
0
Fork 0
forked from koniifer/ableos

adding sime ignores

This commit is contained in:
mlokr 2024-09-03 00:27:50 +02:00
parent 9d7ab01ea3
commit c760e9bcab
3 changed files with 98 additions and 44 deletions

1
.gitignore vendored
View file

@ -2,4 +2,5 @@
/hbbytecode/src/opcode.rs /hbbytecode/src/opcode.rs
/hbbytecode/src/ops.rs /hbbytecode/src/ops.rs
/hblang/src/instrs.rs /hblang/src/instrs.rs
/.rgignore
rust-ice-* rust-ice-*

View file

@ -1326,17 +1326,17 @@ impl ArenaChunk {
impl Drop for ArenaChunk { impl Drop for ArenaChunk {
fn drop(&mut self) { fn drop(&mut self) {
log::inf!( //log::inf!(
"dropping chunk of size: {}", // "dropping chunk of size: {}",
(Self::LAYOUT.size() - (self.end as usize - self.base as usize)) // (Self::LAYOUT.size() - (self.end as usize - self.base as usize))
* !self.end.is_null() as usize // * !self.end.is_null() as usize
); //);
let mut current = self.base; let mut current = self.base;
while !current.is_null() { while !current.is_null() {
let next = Self::next(current); let next = Self::next(current);
unsafe { std::alloc::dealloc(current, Self::LAYOUT) }; unsafe { std::alloc::dealloc(current, Self::LAYOUT) };
current = next; current = next;
log::dbg!("deallocating full chunk"); //log::dbg!("deallocating full chunk");
} }
} }
} }

View file

@ -1,11 +1,11 @@
#![allow(dead_code)] #![allow(dead_code)]
use { use {
crate::{ crate::{
ident::{self, Ident}, ident::Ident,
instrs::{self, *}, instrs::{self},
lexer::{self, TokenKind}, lexer::{self},
log, log,
parser::{self, find_symbol, idfl, CtorField, Expr, ExprRef, FileId, Pos}, parser::{self, Expr, ExprRef, FileId, Pos},
HashMap, HashMap,
}, },
std::{ std::{
@ -769,7 +769,7 @@ pub struct Codegen {
impl Codegen { impl Codegen {
pub fn generate(&mut self) { pub fn generate(&mut self) {
self.find_or_declare(0, 0, Err("main"), ""); self.find_or_declare(0, 0, None, "main");
self.complete_call_graph_low(); self.complete_call_graph_low();
} }
@ -786,11 +786,11 @@ impl Codegen {
self.tys.structs.len() as u32 - 1 self.tys.structs.len() as u32 - 1
} }
fn expr_ctx(&mut self, expr: &Expr, mut ctx: Ctx) -> Option<Nid> { fn expr_ctx(&mut self, expr: &Expr, ctx: Ctx) -> Option<Nid> {
todo!() self.report_unhandled_ast(expr, "bruh");
} }
#[must_use] //#[must_use]
fn complete_call_graph(&mut self) { fn complete_call_graph(&mut self) {
self.complete_call_graph_low(); self.complete_call_graph_low();
} }
@ -817,7 +817,7 @@ impl Codegen {
&mut self, &mut self,
pos: Pos, pos: Pos,
file: FileId, file: FileId,
name: Result<Ident, &str>, name: Option<Ident>,
lit_name: &str, lit_name: &str,
) -> ty::Kind { ) -> ty::Kind {
todo!() todo!()
@ -885,44 +885,97 @@ impl Codegen {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use {
super::parser, crate::parser::{self, FileId},
crate::{codegen::LoggedMem, log, parser::FileId},
std::io, std::io,
}; };
const README: &str = include_str!("../README.md"); const README: &str = include_str!("../README.md");
fn generate(ident: &'static str, input: &'static str, output: &mut String) { fn generate(ident: &'static str, input: &'static str, output: &mut String) {
todo!() fn find_block(mut input: &'static str, test_name: &'static str) -> &'static str {
const CASE_PREFIX: &str = "#### ";
const CASE_SUFFIX: &str = "\n```hb";
loop {
let Some(pos) = input.find(CASE_PREFIX) else {
unreachable!("test {test_name} not found");
};
input = unsafe { input.get_unchecked(pos + CASE_PREFIX.len()..) };
if !input.starts_with(test_name) {
continue;
}
input = unsafe { input.get_unchecked(test_name.len()..) };
if !input.starts_with(CASE_SUFFIX) {
continue;
}
input = unsafe { input.get_unchecked(CASE_SUFFIX.len()..) };
let end = input.find("```").unwrap_or(input.len());
break unsafe { input.get_unchecked(..end) };
}
}
let input = find_block(input, ident);
let mut module_map = Vec::new();
let mut last_start = 0;
let mut last_module_name = "test";
for (i, m) in input.match_indices("// in module: ") {
parser::test::format(ident, input[last_start..i].trim());
module_map.push((last_module_name, &input[last_start..i]));
let (module_name, _) = input[i + m.len()..].split_once('\n').unwrap();
last_module_name = module_name;
last_start = i + m.len() + module_name.len() + 1;
}
parser::test::format(ident, input[last_start..].trim());
module_map.push((last_module_name, input[last_start..].trim()));
let loader = |path: &str, _: &str| {
module_map
.iter()
.position(|&(name, _)| name == path)
.map(|i| i as FileId)
.ok_or(io::Error::from(io::ErrorKind::NotFound))
};
let mut codegen = super::Codegen {
files: module_map
.iter()
.map(|&(path, content)| parser::Ast::new(path, content.to_owned(), &loader))
.collect(),
..Default::default()
};
codegen.generate();
} }
crate::run_tests! { generate: crate::run_tests! { generate:
arithmetic => README; arithmetic => README;
variables => README; //variables => README;
functions => README; //functions => README;
comments => README; //comments => README;
if_statements => README; //if_statements => README;
loops => README; //loops => README;
fb_driver => README; //fb_driver => README;
pointers => README; //pointers => README;
structs => README; //structs => README;
different_types => README; //different_types => README;
struct_operators => README; //struct_operators => README;
directives => README; //directives => README;
global_variables => README; //global_variables => README;
generic_types => README; //generic_types => README;
generic_functions => README; //generic_functions => README;
c_strings => README; //c_strings => README;
struct_patterns => README; //struct_patterns => README;
arrays => README; //arrays => README;
struct_return_from_module_function => README; //struct_return_from_module_function => README;
//comptime_pointers => README; ////comptime_pointers => README;
sort_something_viredly => README; //sort_something_viredly => README;
hex_octal_binary_literals => README; //hex_octal_binary_literals => README;
comptime_min_reg_leak => README; //comptime_min_reg_leak => README;
// structs_in_registers => README; ////structs_in_registers => README;
comptime_function_from_another_file => README; //comptime_function_from_another_file => README;
inline => README; //inline => README;
inline_test => README; //inline_test => README;
} }
} }