From 7c0c756504ff3428cc92315e42d67e6c19ff8f33 Mon Sep 17 00:00:00 2001 From: rzvxa Date: Mon, 24 Jun 2024 20:48:45 +0330 Subject: [PATCH] rem: count_unvisited. --- .../src/generators/count_unvisited.rs | 62 ------------------- tasks/ast_codegen/src/generators/mod.rs | 2 - tasks/ast_codegen/src/main.rs | 4 +- 3 files changed, 1 insertion(+), 67 deletions(-) delete mode 100644 tasks/ast_codegen/src/generators/count_unvisited.rs diff --git a/tasks/ast_codegen/src/generators/count_unvisited.rs b/tasks/ast_codegen/src/generators/count_unvisited.rs deleted file mode 100644 index 3787e0219e1136..00000000000000 --- a/tasks/ast_codegen/src/generators/count_unvisited.rs +++ /dev/null @@ -1,62 +0,0 @@ -use syn::Fields; - -use crate::{schema::RType, CodegenCtx, Generator, GeneratorOutput}; - -pub struct CountUnvisited; - -impl Generator for CountUnvisited { - fn name(&self) -> &'static str { - "CountUnvisited" - } - - fn generate(&mut self, ctx: &CodegenCtx) -> GeneratorOutput { - let total = ctx.ty_table.len(); - let (ast, visitable, unvisited_ids) = - ctx.ty_table.iter().fold((0, 0, Vec::new()), |(mut ast, mut vis, mut ids), it| { - let it = &*it.borrow(); - let typ = match it { - RType::Enum(e) => { - if e.item.variants.iter().any(|it| matches!(it.fields, Fields::Named(_))) { - Some("enum with named fields") - } else if e - .item - .variants - .iter() - .any(|it| matches!(it.fields, Fields::Unnamed(_))) - { - Some("enum with unnamed fields") - } else { - Some("enum") - } - } - RType::Struct(_) => Some("struct"), - _ => None, - }; - - if let Some(typ) = typ { - ast += 1; - if it.visitable() { - vis += 1; - } else { - ids.push(format!("{} {}", typ, it.ident().cloned().unwrap())); - } - } - ids.sort(); - (ast, vis, ids) - }); - - let unvisited = ast - visitable; - - let info = format!( - "\ - Total Items(contains macros, use, etc): {total}\n\ - Ast Items(enums and structs): {ast}\n\ - Visitable Items: {visitable}\n\ - Rest: {unvisited}\n\ - Unvisited Item names: {unvisited_ids:#?}\n\ - " - ); - - GeneratorOutput::Info(info) - } -} diff --git a/tasks/ast_codegen/src/generators/mod.rs b/tasks/ast_codegen/src/generators/mod.rs index a10ee0e605afee..0e32617f6f6b06 100644 --- a/tasks/ast_codegen/src/generators/mod.rs +++ b/tasks/ast_codegen/src/generators/mod.rs @@ -1,6 +1,5 @@ mod ast; mod ast_kind; -mod count_unvisited; mod impl_get_span; /// Inserts a newline in the `TokenStream`. @@ -41,5 +40,4 @@ pub(crate) use insert; pub use ast::AstGenerator; pub use ast_kind::AstKindGenerator; -pub use count_unvisited::CountUnvisited; pub use impl_get_span::ImplGetSpanGenerator; diff --git a/tasks/ast_codegen/src/main.rs b/tasks/ast_codegen/src/main.rs index 7529f1a9e03bb8..5782992ea4b32f 100644 --- a/tasks/ast_codegen/src/main.rs +++ b/tasks/ast_codegen/src/main.rs @@ -22,7 +22,7 @@ use proc_macro2::TokenStream; use syn::parse_file; use defs::TypeDef; -use generators::{AstGenerator, AstKindGenerator, CountUnvisited}; +use generators::{AstGenerator, AstKindGenerator}; use linker::{linker, Linker}; use schema::{Inherit, Module, REnum, RStruct, RType, Schema}; @@ -191,7 +191,6 @@ fn main() -> std::result::Result<(), Box> { .with(AstGenerator) .with(AstKindGenerator) .with(ImplGetSpanGenerator) - // .with(CountUnvisited) .generate()?; let output_dir = output_dir()?; @@ -206,7 +205,6 @@ fn main() -> std::result::Result<(), Box> { span_file.write_all(span_content.as_bytes())?; } - // println!("{}", outputs[CountUnvisited.name()].clone().as_info()); // NOTE: Print AstKind // println!(