4141#include < liblangutil/EVMVersion.h>
4242#include < liblangutil/SourceLocation.h>
4343
44+ #include < libevmasm/AbstractAssemblyStack.h>
4445#include < libevmasm/LinkerObject.h>
4546
4647#include < libsolutil/Common.h>
@@ -91,7 +92,7 @@ class Analysis;
9192 * It holds state and can be used to either step through the compilation stages (and abort e.g.
9293 * before compilation to bytecode) or run the whole compilation in one call.
9394 */
94- class CompilerStack : public langutil ::CharStreamProvider
95+ class CompilerStack : public langutil ::CharStreamProvider, public evmasm::AbstractAssemblyStack
9596{
9697public:
9798 // / Noncopyable.
@@ -123,7 +124,7 @@ class CompilerStack: public langutil::CharStreamProvider
123124 // / Regular compilation from Solidity source files.
124125 Solidity,
125126 // / Compilation from an imported Solidity AST.
126- SolidityAST
127+ SolidityAST,
127128 };
128129
129130 // / Creates a new compiler stack.
@@ -139,6 +140,8 @@ class CompilerStack: public langutil::CharStreamProvider
139140 // / @returns the current state.
140141 State state () const { return m_stackState; }
141142
143+ virtual bool compilationSuccessful () const override { return m_stackState >= CompilationSuccessful; }
144+
142145 // / Resets the compiler to an empty state. Unless @a _keepSettings is set to true,
143146 // / all settings are reset as well.
144147 void reset (bool _keepSettings = false );
@@ -234,7 +237,7 @@ class CompilerStack: public langutil::CharStreamProvider
234237 bool compile (State _stopAfter = State::CompilationSuccessful);
235238
236239 // / @returns the list of sources (paths) used
237- std::vector<std::string> sourceNames () const ;
240+ virtual std::vector<std::string> sourceNames () const override ;
238241
239242 // / @returns a mapping assigning each source name its index inside the vector returned
240243 // / by sourceNames().
@@ -255,13 +258,13 @@ class CompilerStack: public langutil::CharStreamProvider
255258 std::vector<std::string> const & unhandledSMTLib2Queries () const { return m_unhandledSMTLib2Queries; }
256259
257260 // / @returns a list of the contract names in the sources.
258- std::vector<std::string> contractNames () const ;
261+ virtual std::vector<std::string> contractNames () const override ;
259262
260263 // / @returns the name of the last contract. If _sourceName is defined the last contract of that source will be returned.
261264 std::string const lastContractName (std::optional<std::string> const & _sourceName = std::nullopt ) const ;
262265
263266 // / @returns either the contract's name or a mixture of its name and source file, sanitized for filesystem use
264- std::string const filesystemFriendlyName (std::string const & _contractName) const ;
267+ virtual std::string const filesystemFriendlyName (std::string const & _contractName) const override ;
265268
266269 // / @returns the IR representation of a contract.
267270 std::string const & yulIR (std::string const & _contractName) const ;
@@ -276,10 +279,10 @@ class CompilerStack: public langutil::CharStreamProvider
276279 Json::Value const & yulIROptimizedAst (std::string const & _contractName) const ;
277280
278281 // / @returns the assembled object for a contract.
279- evmasm::LinkerObject const & object (std::string const & _contractName) const ;
282+ virtual evmasm::LinkerObject const & object (std::string const & _contractName) const override ;
280283
281284 // / @returns the runtime object for the contract.
282- evmasm::LinkerObject const & runtimeObject (std::string const & _contractName) const ;
285+ virtual evmasm::LinkerObject const & runtimeObject (std::string const & _contractName) const override ;
283286
284287 // / @returns normal contract assembly items
285288 evmasm::AssemblyItems const * assemblyItems (std::string const & _contractName) const ;
@@ -293,21 +296,21 @@ class CompilerStack: public langutil::CharStreamProvider
293296
294297 // / @returns the string that provides a mapping between bytecode and sourcecode or a nullptr
295298 // / if the contract does not (yet) have bytecode.
296- std::string const * sourceMapping (std::string const & _contractName) const ;
299+ virtual std::string const * sourceMapping (std::string const & _contractName) const override ;
297300
298301 // / @returns the string that provides a mapping between runtime bytecode and sourcecode.
299302 // / if the contract does not (yet) have bytecode.
300- std::string const * runtimeSourceMapping (std::string const & _contractName) const ;
303+ virtual std::string const * runtimeSourceMapping (std::string const & _contractName) const override ;
301304
302305 // / @return a verbose text representation of the assembly.
303306 // / @arg _sourceCodes is the map of input files to source code strings
304307 // / Prerequisite: Successful compilation.
305- std::string assemblyString (std::string const & _contractName, StringMap const & _sourceCodes = StringMap()) const ;
308+ virtual std::string assemblyString (std::string const & _contractName, StringMap const & _sourceCodes = StringMap()) const override ;
306309
307310 // / @returns a JSON representation of the assembly.
308311 // / @arg _sourceCodes is the map of input files to source code strings
309312 // / Prerequisite: Successful compilation.
310- Json::Value assemblyJSON (std::string const & _contractName) const ;
313+ virtual Json::Value assemblyJSON (std::string const & _contractName) const override ;
311314
312315 // / @returns a JSON representing the contract ABI.
313316 // / Prerequisite: Successful call to parse or compile.
0 commit comments