|
| 1 | +/* |
| 2 | + This file is part of solidity. |
| 3 | +
|
| 4 | + solidity is free software: you can redistribute it and/or modify |
| 5 | + it under the terms of the GNU General Public License as published by |
| 6 | + the Free Software Foundation, either version 3 of the License, or |
| 7 | + (at your option) any later version. |
| 8 | +
|
| 9 | + solidity is distributed in the hope that it will be useful, |
| 10 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + GNU General Public License for more details. |
| 13 | +
|
| 14 | + You should have received a copy of the GNU General Public License |
| 15 | + along with solidity. If not, see <http://www.gnu.org/licenses/>. |
| 16 | +*/ |
| 17 | +// SPDX-License-Identifier: GPL-3.0 |
| 18 | + |
| 19 | +#pragma once |
| 20 | + |
| 21 | +#include <test/libsolidity/util/compiler/Compiler.h> |
| 22 | +#include <test/libsolidity/util/compiler/InternalCompiler.h> |
| 23 | + |
| 24 | +namespace solidity::frontend::test |
| 25 | +{ |
| 26 | + |
| 27 | +class CompilerHost |
| 28 | +{ |
| 29 | +public: |
| 30 | + /// Takes the current compiler input, requests the hosted compiler to compile |
| 31 | + /// and updates the output accordingly. |
| 32 | + CompilerOutput const& compile(CompilerInput _input); |
| 33 | + |
| 34 | + /// Resets the output generated by the previous compilation. |
| 35 | + void reset(); |
| 36 | + |
| 37 | + /// @returns the stored output generated by the previous compilation. |
| 38 | + CompilerOutput const& output() const; |
| 39 | + |
| 40 | +private: |
| 41 | + /// Instance of an invocable compiler. |
| 42 | + std::variant<InternalCompiler> m_compiler; |
| 43 | + /// Last generated output. Will be none before initial compilation |
| 44 | + /// and after reset. |
| 45 | + std::optional<CompilerOutput> m_output; |
| 46 | +}; |
| 47 | + |
| 48 | +} |
0 commit comments