pipeline_script/postprocessor/
function_printer.rs1use crate::ast::NodeTrait;
2use crate::postprocessor::{Stage, VisitResult, Visitor};
3
4pub struct FunctionPrinter {
5 name: String,
6}
7impl FunctionPrinter {
8 #[allow(unused)]
9 pub fn new(name: impl Into<String>) -> Self {
10 Self { name: name.into() }
11 }
12}
13impl Visitor for FunctionPrinter {
14 fn stage(&self) -> Stage {
15 Stage::AfterTypeInfer
16 }
17
18 fn match_id(&self, id: &str) -> bool {
19 id.starts_with("Function")
20 }
21
22 fn visit(&self, node: &mut (impl NodeTrait + ?Sized)) -> VisitResult {
23 let data = node.get_data("name").unwrap();
24 let name = data.as_str().unwrap();
25 if name.starts_with(self.name.as_str()) {
26 println!("{:#?}", node.get_id());
27 return VisitResult::Break;
28 }
29 VisitResult::Continue
30 }
31}