LIBINT 2.9.0
codeblock.h
1/*
2 * Copyright (C) 2004-2024 Edward F. Valeev
3 *
4 * This file is part of Libint compiler.
5 *
6 * Libint compiler is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint compiler is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Libint compiler. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <entity.h>
22
23#include <string>
24
25#ifndef _libint2_src_bin_libint_codeblock_h_
26#define _libint2_src_bin_libint_codeblock_h_
27
28namespace libint2 {
29
30class CodeContext;
31
32class CodeBlock {
33 public:
34 CodeBlock(const std::shared_ptr<CodeContext>& context) : context_(context) {}
35 virtual ~CodeBlock() {}
36
37 std::shared_ptr<CodeContext> context() const { return context_; }
38
40 virtual std::string open() = 0;
42 virtual std::string close() = 0;
43
44 private:
45 std::shared_ptr<CodeContext> context_;
46};
47
48class ForLoop : public CodeBlock {
49 public:
50 ForLoop(const std::shared_ptr<CodeContext>& context, std::string& varname,
51 const std::shared_ptr<Entity>& less_than,
52 const std::shared_ptr<Entity>& start_at);
53 virtual ~ForLoop();
54
56 std::string open() override;
58 std::string close() override;
59
60 private:
61 std::string varname_;
62 std::shared_ptr<Entity> less_than_;
63 std::shared_ptr<Entity> start_at_;
64
65 // checks less_than_ and start_at_ and initializes
66 // lt_expr_, sa_expr_, and dummy_loop_
67 void init_();
68 // string representations of less_than_ and start_at_
69 std::string lt_expr_;
70 std::string sa_expr_;
71 // dummy_loop_ is true if the loop is guaranteed to iterate once
72 // i.e. can replace the loop with a constant variable definition
73 bool dummy_loop_;
74};
75
76}; // namespace libint2
77
78#endif
Definition codeblock.h:32
virtual std::string close()=0
Close a code block.
virtual std::string open()=0
Opens a code block.
Definition codeblock.h:48
std::string close() override
Implementation of CodeBlock::close()
Definition codeblock.cc:94
std::string open() override
Implementation of CodeBlock::open()
Definition codeblock.cc:77
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24