adding sime ignores

This commit is contained in:
mlokr 2024-09-03 00:27:50 +02:00
parent 9500db8764
commit 7279ed88e9
No known key found for this signature in database
GPG key ID: DEA147DDEE644993
3 changed files with 98 additions and 44 deletions

1
.gitignore vendored
View file

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

View file

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

View file

@ -1,11 +1,11 @@
#![allow(dead_code)]
use {
crate::{
ident::{self, Ident},
instrs::{self, *},
lexer::{self, TokenKind},
ident::Ident,
instrs::{self},
lexer::{self},
log,
parser::{self, find_symbol, idfl, CtorField, Expr, ExprRef, FileId, Pos},
parser::{self, Expr, ExprRef, FileId, Pos},
HashMap,
},
std::{
@ -769,7 +769,7 @@ pub struct Codegen {
impl Codegen {
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();
}
@ -786,11 +786,11 @@ impl Codegen {
self.tys.structs.len() as u32 - 1
}
fn expr_ctx(&mut self, expr: &Expr, mut ctx: Ctx) -> Option<Nid> {
todo!()
fn expr_ctx(&mut self, expr: &Expr, ctx: Ctx) -> Option<Nid> {
self.report_unhandled_ast(expr, "bruh");
}
#[must_use]
//#[must_use]
fn complete_call_graph(&mut self) {
self.complete_call_graph_low();
}
@ -817,7 +817,7 @@ impl Codegen {
&mut self,
pos: Pos,
file: FileId,
name: Result<Ident, &str>,
name: Option<Ident>,
lit_name: &str,
) -> ty::Kind {
todo!()
@ -885,44 +885,97 @@ impl Codegen {
#[cfg(test)]
mod tests {
use {
super::parser,
crate::{codegen::LoggedMem, log, parser::FileId},
crate::parser::{self, FileId},
std::io,
};
const README: &str = include_str!("../README.md");
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:
arithmetic => README;
variables => README;
functions => README;
comments => README;
if_statements => README;
loops => README;
fb_driver => README;
pointers => README;
structs => README;
different_types => README;
struct_operators => README;
directives => README;
global_variables => README;
generic_types => README;
generic_functions => README;
c_strings => README;
struct_patterns => README;
arrays => README;
struct_return_from_module_function => README;
//comptime_pointers => README;
sort_something_viredly => README;
hex_octal_binary_literals => README;
comptime_min_reg_leak => README;
// structs_in_registers => README;
comptime_function_from_another_file => README;
inline => README;
inline_test => README;
//variables => README;
//functions => README;
//comments => README;
//if_statements => README;
//loops => README;
//fb_driver => README;
//pointers => README;
//structs => README;
//different_types => README;
//struct_operators => README;
//directives => README;
//global_variables => README;
//generic_types => README;
//generic_functions => README;
//c_strings => README;
//struct_patterns => README;
//arrays => README;
//struct_return_from_module_function => README;
////comptime_pointers => README;
//sort_something_viredly => README;
//hex_octal_binary_literals => README;
//comptime_min_reg_leak => README;
////structs_in_registers => README;
//comptime_function_from_another_file => README;
//inline => README;
//inline_test => README;
}
}