Get the varialbe name of the given stmt.
(&self)
| 86 | |
| 87 | /// Get the varialbe name of the given stmt. |
| 88 | fn get_var_name(&self) -> VarName { |
| 89 | let mut worklist = WorkList::new(); |
| 90 | worklist.push(self); |
| 91 | let mut names = vec![]; |
| 92 | let mut kinds = vec![]; |
| 93 | let mut ids = vec![]; |
| 94 | while !worklist.empty() { |
| 95 | let curr = worklist.pop(); |
| 96 | if let Clang::DeclRefExpr(dre) = &curr.kind { |
| 97 | if let clang_ast::Kind::EnumConstantDecl = dre.referenced_decl.kind { |
| 98 | continue; |
| 99 | } |
| 100 | names.push(dre.get_name_as_string()); |
| 101 | kinds.push(VarKind::Base); |
| 102 | ids.push(dre.referenced_decl.id); |
| 103 | } |
| 104 | if let Clang::ArraySubscriptExpr(ase) = &curr.kind { |
| 105 | names.push("i".to_owned()); |
| 106 | kinds.push(VarKind::Arrary); |
| 107 | ids.push(curr.id); |
| 108 | worklist.push(ase.get_lhs(curr)); |
| 109 | continue; |
| 110 | } |
| 111 | if let Clang::MemberExpr(me) = &curr.kind { |
| 112 | let name = me.get_name_as_string(); |
| 113 | names.push(name); |
| 114 | // Currently only retain the member relationship, ignore the "is_arrow" attribute. |
| 115 | kinds.push(VarKind::Member); |
| 116 | ids.push(curr.id); |
| 117 | } |
| 118 | for child in &curr.inner { |
| 119 | worklist.push(child); |
| 120 | } |
| 121 | } |
| 122 | VarName::from_vec(names, kinds, ids) |
| 123 | } |
| 124 | |
| 125 | fn is_call(&self) -> bool { |
| 126 | matches!(&self.ignore_cast().kind, Clang::CallExpr(_)) |
no test coverage detected