20 using visitor::VarUsageVisitor;
23 const std::shared_ptr<ast::Name>& volume_index_name,
24 std::shared_ptr<ast::Expression> volume_expr,
25 const std::shared_ptr<ast::Name>& rate_index_name,
26 std::shared_ptr<ast::Expression> rate_expr)
27 : volume_index_name(volume_index_name ? volume_index_name->get_node_name() : std::string{})
28 , volume_expr(std::
move(volume_expr))
29 , rate_index_name(rate_index_name ? rate_index_name->get_node_name() : std::string{})
30 , rate_expr(std::
move(rate_expr)) {}
33 const std::string& index_name)
const {
37 const std::string& index_name)
const {
49 const std::string& index_name,
50 const std::string& old_index_name,
51 const std::shared_ptr<ast::Expression>& old_expr)
const {
52 if (old_index_name ==
"") {
56 auto new_expr = old_expr->clone();
61 return std::shared_ptr<ast::Expression>(
dynamic_cast<ast::Expression*
>(new_expr));
66 return std::any_of(
ions.begin(),
ions.end(), [](
auto const& ion) {
67 return !ion.writes.empty();
74 return std::any_of(ions.begin(), ions.end(), [&
name](
auto const& ion) {
75 return std::any_of(ion.writes.begin(), ion.writes.end(), [&name](auto const& var) {
83 bool CodegenInfo::is_ion_read_variable(
const std::string&
name)
const noexcept {
84 return std::any_of(ions.begin(), ions.end(), [&
name](
auto const& ion) {
85 return std::any_of(ion.reads.begin(), ion.reads.end(), [&name](auto const& var) {
93 bool CodegenInfo::is_ion_variable(
const std::string&
name)
const noexcept {
94 return is_ion_read_variable(
name) || is_ion_write_variable(
name);
99 bool CodegenInfo::is_current(
const std::string&
name)
const noexcept {
107 bool CodegenInfo::is_ionic_current(
const std::string&
name)
const noexcept {
108 return std::any_of(ions.begin(), ions.end(), [&
name](
auto const& ion) {
109 return ion.is_ionic_current(name);
114 bool CodegenInfo::is_ionic_conc(
const std::string&
name)
const noexcept {
115 return std::any_of(ions.begin(), ions.end(), [&
name](
auto const& ion) {
116 return ion.is_ionic_conc(name);
120 bool CodegenInfo::function_uses_table(
const std::string&
name)
const noexcept {
121 return std::any_of(functions_with_table.begin(),
122 functions_with_table.end(),
123 [&
name](
auto const&
function) { return name == function->get_node_name(); });
131 bool CodegenInfo::nrn_state_has_eigen_solver_block()
const {
132 if (nrn_state_block ==
nullptr) {
135 return !
collect_nodes(*nrn_state_block, {ast::AstNodeType::EIGEN_NEWTON_SOLVER_BLOCK}).empty();
147 bool CodegenInfo::is_voltage_used_by_watch_statements()
const {
148 return std::any_of(watch_statements.begin(), watch_statements.end(), [](
auto const& statement) {
149 return VarUsageVisitor{}.variable_used(*statement,
"v");
Auto generated AST classes declaration.
Base class for all expressions in the NMODL.
std::shared_ptr< ast::Expression > volume(const std::string &index_name) const
Volume of this species.
std::shared_ptr< ast::Expression > substitute_index(const std::string &index_name, const std::string &old_index_name, const std::shared_ptr< ast::Expression > &old_expr) const
std::shared_ptr< ast::Expression > volume_expr
double dfcdc(const std::string &) const
The value of what NEURON calls dfcdc.
LongitudinalDiffusionInfo(const std::shared_ptr< ast::Name > &index_name, std::shared_ptr< ast::Expression > volume_expr, const std::shared_ptr< ast::Name > &rate_index_name, std::shared_ptr< ast::Expression > rate_expr)
std::shared_ptr< ast::Expression > diffusion_rate(const std::string &index_name) const
Difusion rate of this species.
std::string volume_index_name
std::string rate_index_name
std::shared_ptr< ast::Expression > rate_expr
Blindly rename given variable to new name
Various types to store code generation specific information.
double var(InputIterator begin, InputIterator end)
Auto generated AST classes declaration.
void move(Item *q1, Item *q2, Item *q3)
encapsulates code generation backend implementations
std::vector< std::shared_ptr< const ast::Ast > > collect_nodes(const ast::Ast &node, const std::vector< ast::AstNodeType > &types)
traverse node recursively and collect nodes of given types
Blindly rename given variable to new name
bool is_ion_write_variable(const std::string &name) const noexcept
if given variable is ion write variable
bool ion_has_write_variable() const noexcept
if any ion has write variable
std::vector< Ion > ions
ions used in the mod file
Check if variable is used in given block.
Utility functions for visitors implementation.