Skip to content

Commit

Permalink
SemanticAnalysisVisitor: detect if several solve blocks are given
Browse files Browse the repository at this point in the history
  • Loading branch information
alkino committed Nov 9, 2023
1 parent 36199d0 commit c00553b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/visitors/semantic_analysis_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,16 @@ void SemanticAnalysisVisitor::visit_mutex_unlock(const ast::MutexUnlock& /* node
/// -->
}

void SemanticAnalysisVisitor::visit_solve_block(const ast::SolveBlock& /* node */) {
/// <-- This code is for check 8
if (solve_block_found) {
logger->critical("It is not allowed to have several solve blocks");
check_fail = true;
} else {
solve_block_found = true;
}
/// -->
}

} // namespace visitor
} // namespace nmodl
6 changes: 6 additions & 0 deletions src/visitors/semantic_analysis_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* 5. Check if an independent variable is not 't'.
* 6. Check that mutex are not badly use
* 7. Check than function table got at least one argument.
* 8. Check that at most one solve block is present.
*/
#include "ast/ast.hpp"
#include "visitors/ast_visitor.hpp"
Expand All @@ -54,6 +55,8 @@ class SemanticAnalysisVisitor: public ConstAstVisitor {
bool is_point_process = false;
/// true if we are inside a mutex locked part
bool in_mutex = false;
/// true if we already found a solve block
bool solve_block_found = false;

/// Store if we are in a procedure and if the arity of this is 1
void visit_procedure_block(const ast::ProcedureBlock& node) override;
Expand Down Expand Up @@ -82,6 +85,9 @@ class SemanticAnalysisVisitor: public ConstAstVisitor {
/// Look if MUTEXUNLOCK is outside a locked block
void visit_mutex_unlock(const ast::MutexUnlock& node) override;

/// Check how many solve block we got
void visit_solve_block(const ast::SolveBlock& node) override;

public:
SemanticAnalysisVisitor(bool accel_backend = false)
: accel_backend(accel_backend) {}
Expand Down

0 comments on commit c00553b

Please sign in to comment.