From 76e05de64941b1af8062ae2d16edbfb28270b861 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Tue, 5 Nov 2024 11:43:54 +0100 Subject: [PATCH] Remove superfluous Codegen ctor. --- src/codegen/codegen_cpp_visitor.hpp | 28 ---------------------------- src/main.cpp | 8 +++++--- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/codegen/codegen_cpp_visitor.hpp b/src/codegen/codegen_cpp_visitor.hpp index 5fbe2fe4f..3e6e72044 100644 --- a/src/codegen/codegen_cpp_visitor.hpp +++ b/src/codegen/codegen_cpp_visitor.hpp @@ -236,34 +236,6 @@ using printer::CodePrinter; */ class CodegenCppVisitor: public visitor::ConstAstVisitor { public: - /** - * \brief Constructs the C++ code generator visitor - * - * This constructor instantiates an NMODL C++ code generator and allows writing generated code - * directly to a file in \c [output_dir]/[mod_filename].cpp. - * - * \note No code generation is performed at this stage. Since the code - * generator classes are all based on \c AstVisitor the AST must be visited using e.g. \c - * visit_program in order to generate the C++ code corresponding to the AST. - * - * \param mod_filename The name of the model for which code should be generated. - * It is used for constructing an output filename. - * \param output_dir The directory where target C++ file should be generated. - * \param float_type The float type to use in the generated code. The string will be used - * as-is in the target code. This defaults to \c double. - */ - CodegenCppVisitor(std::string mod_filename, - const std::string& output_dir, - std::string float_type, - const bool optimize_ionvar_copies, - std::unique_ptr blame) - : printer(std::make_unique(output_dir + "/" + mod_filename + ".cpp", - std::move(blame))) - , mod_filename(std::move(mod_filename)) - , float_type(std::move(float_type)) - , optimize_ionvar_copies(optimize_ionvar_copies) {} - - /** * \brief Constructs the C++ code generator visitor * diff --git a/src/main.cpp b/src/main.cpp index d38c6bef4..5f858ed0b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -600,12 +600,14 @@ int run_nmodl(int argc, const char* argv[]) { } { + auto output_stream = std::ofstream(std::filesystem::path(output_dir) / + (modfile + ".cpp")); auto blame_level = detailed_blame ? utils::BlameLevel::Detailed : utils::BlameLevel::Short; if (coreneuron_code && oacc_backend) { logger->info("Running OpenACC backend code generator for CoreNEURON"); CodegenAccVisitor visitor(modfile, - output_dir, + output_stream, data_type, optimize_ionvar_copies_codegen, utils::make_blame(blame_line, blame_level)); @@ -615,7 +617,7 @@ int run_nmodl(int argc, const char* argv[]) { else if (coreneuron_code && !neuron_code && cpp_backend) { logger->info("Running C++ backend code generator for CoreNEURON"); CodegenCoreneuronCppVisitor visitor(modfile, - output_dir, + output_stream, data_type, optimize_ionvar_copies_codegen, utils::make_blame(blame_line, blame_level)); @@ -625,7 +627,7 @@ int run_nmodl(int argc, const char* argv[]) { else if (neuron_code && cpp_backend) { logger->info("Running C++ backend code generator for NEURON"); CodegenNeuronCppVisitor visitor(modfile, - output_dir, + output_stream, data_type, optimize_ionvar_copies_codegen, utils::make_blame(blame_line, blame_level));