|
User Guide
|
Go to the documentation of this file.
24 #include <string_view>
42 using printer::CodePrinter;
281 const std::string& concentration,
288 std::string
hoc_function_name(
const std::string& function_or_procedure_name)
const;
301 std::string
py_function_name(
const std::string& function_or_procedure_name)
const;
360 const std::string& name,
361 bool use_instance)
const override;
372 bool use_instance =
true)
const override;
383 std::string
get_variable_name(
const std::string& name,
bool use_instance =
true)
const override;
440 const std::string& function_name =
"")
override;
647 template <
typename T>
681 template <
typename T>
688 const auto& params = node.get_parameters();
689 for (
const auto& param: params) {
690 internal_params.emplace_back(
"", type,
"", param.get()->get_node_name());
694 const char* return_type =
"int";
695 if (node.is_function_block()) {
701 printer->fmt_text(
"inline {} {}({})",
const char * external_method_parameters(bool table=false) noexcept override
Parameters for functions in generated code that are called back from external code.
void print_nrn_destructor() override
Print nrn_destructor function definition.
void print_nrn_cur_non_conductance_kernel() override
Print the nrn_cur kernel without NMODL conductance keyword provisions.
std::string py_function_signature(const std::string &function_or_procedure_name) const
Get the signature of the npy <func_or_proc_name> function.
Helper to represent information about index/int variables.
void print_nrn_cur() override
Print nrn_cur / current update function definition.
void print_macro_definitions()
Print all NEURON macros.
void print_net_event_call(const ast::FunctionCall &node) override
Print call to net_event.
void print_neuron_includes()
Print includes from NEURON.
void print_nrn_init(bool skip_init_check=true)
Print the nrn_init function definition.
void print_hoc_py_wrapper_function_body(const ast::Block *function_or_procedure_block, InterpreterWrapper wrapper_type)
std::string internal_method_arguments() override
Arguments for functions that are defined and used internally.
std::shared_ptr< symtab::Symbol > SymbolType
void print_nrn_alloc() override
Print nrn_alloc function definition.
std::string register_mechanism_arguments() const override
Arguments for register_mech or point_register_mech function.
int position_of_int_var(const std::string &name) const override
Determine the position in the data array for a given int variable.
std::string nrn_current_arguments()
bool optimize_ion_variable_copies() const override
Check if ion variable copies should be avoided.
ParamVector internal_method_parameters() override
Parameters for internally defined functions.
std::string hoc_function_name(const std::string &function_or_procedure_name) const
All functions and procedures need a hoc <func_or_proc_name> to be available to the HOC interpreter.
encapsulates code generation backend implementations
@ index
index / int variables
std::string global_variable_name(const SymbolType &symbol, bool use_instance=true) const override
Determine the variable name for a global variable given its symbol.
std::string nrn_thread_internal_arguments() override
Arguments for "_threadargs_" macro in neuron implementation.
Implement classes for representing symbol table at block and file scope.
virtual std::string backend_name() const override
Name of the code generation backend.
std::string process_verbatim_text(std::string const &text) override
Process a verbatim block for possible variable renaming.
ParamVector nrn_current_parameters()
void print_g_unused() const override
Set g_unused (conductance) for NRN_PRCELLSTATE feature.
virtual void visit_watch_statement(const ast::WatchStatement &node) override
TODO: Edit for NEURON.
void print_net_send_call(const ast::FunctionCall &node) override
Print call to net_send.
void print_namespace_end() override
Print end of namespaces.
void print_net_move_call(const ast::FunctionCall &node) override
Print call to net_move.
void print_nrn_state() override
Print nrn_state / state update function definition.
const char * default_float_data_type() const noexcept
Default data type for floating point elements.
void print_initial_block(const ast::InitialBlock *node)
Print the initial block.
virtual void print_global_function_common_code(BlockType type, const std::string &function_name="") override
Print common code for global functions like nrn_init, nrn_cur and nrn_state.
std::string float_variable_name(const SymbolType &symbol, bool use_instance) const override
Determine the name of a float variable given its symbol.
void print_function(const ast::FunctionBlock &node) override
Print NMODL function in target backend code.
void print_hoc_py_wrapper_function_definitions()
void print_v_unused() const override
Set v_unused (voltage) for NRN_PRCELLSTATE feature.
Visitor for printing C++ code compatible with legacy api of CoreNEURON
Base class for all block scoped nodes.
Represents a INITIAL block in the NMODL.
void print_point_process_function_definitions()
Print POINT_PROCESS related functions Wrap external NEURON functions related to POINT_PROCESS mechani...
Represent WATCH statement in NMODL.
void print_function_declaration(const T &node, const std::string &name)
Print prototype declarations of functions or procedures.
Represents a BREAKPOINT block in NMODL.
void print_nrn_cur_conductance_kernel(const ast::BreakpointBlock &node) override
Print the nrn_cur kernel with NMODL conductance keyword provisions.
std::string int_variable_name(const IndexVariableInfo &symbol, const std::string &name, bool use_instance) const override
Determine the name of an int variable given its symbol.
InterpreterWrapper
Enum to switch between HOC and Python wrappers for functions and procedures defined in mechanisms.
void print_namespace_begin() override
Print start of namespaces.
void print_global_variables_for_hoc() override
Print byte arrays that register scalar and vector variables for hoc interface.
void print_standard_includes() override
Print standard C/C++ includes.
void print_mechanism_range_var_structure(bool print_initializers) override
Print the structure that wraps all range and int variables required for the NMODL.
virtual void print_procedure(const ast::ProcedureBlock &node) override
Print NMODL procedure in target backend code.
Helper class for printing C/C++ code.
std::string hoc_function_signature(const std::string &function_or_procedure_name) const
Get the signature of the hoc <func_or_proc_name> function.
void print_namespace_start() override
Prints the start of the neuron namespace.
void print_backend_info() override
Print top file header printed in generated code.
virtual void print_compute_functions() override
Print all compute functions for every backend.
void print_nrn_cur_kernel(const ast::BreakpointBlock &node) override
Print main body of nrn_cur function.
std::string conc_write_statement(const std::string &ion_name, const std::string &concentration, int index) override
Generate Function call statement for nrn_wrote_conc.
void print_mechanism_register() override
Print the mechanism registration function.
void print_nrn_jacob()
Print nrn_jacob function definition.
Various types to store code generation specific information.
virtual void print_fast_imem_calculation() override
Print fast membrane current calculation code.
void print_data_structures(bool print_initializers) override
Print all classes.
void print_sdlists_init(bool print_initializers) override
std::string py_function_name(const std::string &function_or_procedure_name) const
In non POINT_PROCESS mechanisms all functions and procedures need a py <func_or_proc_name> to be avai...
void print_node_data_structure(bool print_initializers)
Print the structure that wraps all node variables required for the NMODL.
static std::string get_parameter_str(const ParamVector ¶ms)
Generate the string representing the procedure parameter declaration.
void print_make_instance() const
Print make_*_instance.
virtual void print_atomic_reduction_pragma() override
Print atomic update pragma for reduction statements.
void print_namespace_stop() override
Prints the end of the neuron namespace.
void print_setdata_functions()
Print NEURON functions related to setting global variables of the mechanism.
void print_mechanism_variables_macros()
Print mechanism variables' related macros.
Visitor for printing C++ code compatible with legacy api of NEURON
CodegenCppVisitor(std::string mod_filename, const std::string &output_dir, std::string float_type, const bool optimize_ionvar_copies, size_t blame_line=0)
Constructs the C++ code generator visitor.
void print_nrn_constructor() override
Print nrn_constructor function definition.
Implement logger based on spdlog library.
bool enable_variable_name_lookup
Variable name should be converted to instance name (but not for function arguments)
BlockType
Helper to represent various block types.
void print_function_or_procedure(const ast::Block &node, const std::string &name) override
Print nmodl function or procedure (common code)
void print_headers_include() override
Print all includes.
void print_nrn_current(const ast::BreakpointBlock &node) override
Print the nrn_current kernel.
int position_of_float_var(const std::string &name) const override
Determine the position in the data array for a given float variable.
std::string get_variable_name(const std::string &name, bool use_instance=true) const override
Determine variable name in the structure of mechanism properties.
Visitor for printing C++ code compatible with legacy api of CoreNEURON
void print_make_node_data() const
Print make_*_node_data.
std::string simulator_name() override
Name of the simulator the code was generated for.
void print_function_procedure_helper(const ast::Block &node) override
Common helper function to help printing function or procedure blocks.
std::unique_ptr< CodePrinter > printer
Code printer object for target (C++)
const char * external_method_arguments() noexcept override
Arguments for external functions called from generated code.
std::string method_name(const std::string &name) const
Constructs the name of a function or procedure.
std::string nrn_thread_arguments() const override
Arguments for "_threadargs_" macro in neuron implementation.
void print_codegen_routines() override
Print entry point to code generation.
void print_function_prototypes() override
Print function and procedures prototype declaration.
void print_mechanism_global_var_structure(bool print_initializers) override
Print the structure that wraps all global variables used in the NMODL.
void print_global_macros()
Print NEURON global variable macros.
std::vector< std::tuple< std::string, std::string, std::string, std::string > > ParamVector
A vector of parameters represented by a 4-tuple of strings:
Concrete visitor for all AST classes.