NEURON
var_usage_visitor.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
9 
10 #include <utility>
11 
12 #include "ast/name.hpp"
13 
14 
15 namespace nmodl {
16 namespace visitor {
17 
18 /// rename matching variable
20  const auto& name = node.get_node_name();
21  if (name == var_name) {
22  used = true;
23  }
24 }
25 
27  used = false;
29  node.visit_children(*this);
30  return used;
31 }
32 
33 } // namespace visitor
34 } // namespace nmodl
Represents a name.
Definition: name.hpp:44
Base class for all AST node.
Definition: node.hpp:40
bool variable_used(const ast::Node &node, std::string name)
std::string var_name
variable to check usage
void visit_name(const ast::Name &node) override
rename matching variable
const char * name
Definition: init.cpp:16
void move(Item *q1, Item *q2, Item *q3)
Definition: list.cpp:200
Auto generated AST classes declaration.
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
static Node * node(Object *)
Definition: netcvode.cpp:291
Check if variable is used in given block.