41
41
#include < liblangutil/EVMVersion.h>
42
42
#include < liblangutil/SourceLocation.h>
43
43
44
+ #include < libevmasm/AbstractAssemblyStack.h>
44
45
#include < libevmasm/LinkerObject.h>
45
46
46
47
#include < libsolutil/Common.h>
@@ -91,7 +92,7 @@ class Analysis;
91
92
* It holds state and can be used to either step through the compilation stages (and abort e.g.
92
93
* before compilation to bytecode) or run the whole compilation in one call.
93
94
*/
94
- class CompilerStack : public langutil ::CharStreamProvider
95
+ class CompilerStack : public langutil ::CharStreamProvider, public evmasm::AbstractAssemblyStack
95
96
{
96
97
public:
97
98
// / Noncopyable.
@@ -123,7 +124,7 @@ class CompilerStack: public langutil::CharStreamProvider
123
124
// / Regular compilation from Solidity source files.
124
125
Solidity,
125
126
// / Compilation from an imported Solidity AST.
126
- SolidityAST
127
+ SolidityAST,
127
128
};
128
129
129
130
// / Creates a new compiler stack.
@@ -139,6 +140,8 @@ class CompilerStack: public langutil::CharStreamProvider
139
140
// / @returns the current state.
140
141
State state () const { return m_stackState; }
141
142
143
+ virtual bool compilationSuccessful () const override { return m_stackState >= CompilationSuccessful; }
144
+
142
145
// / Resets the compiler to an empty state. Unless @a _keepSettings is set to true,
143
146
// / all settings are reset as well.
144
147
void reset (bool _keepSettings = false );
@@ -234,7 +237,7 @@ class CompilerStack: public langutil::CharStreamProvider
234
237
bool compile (State _stopAfter = State::CompilationSuccessful);
235
238
236
239
// / @returns the list of sources (paths) used
237
- std::vector<std::string> sourceNames () const ;
240
+ virtual std::vector<std::string> sourceNames () const override ;
238
241
239
242
// / @returns a mapping assigning each source name its index inside the vector returned
240
243
// / by sourceNames().
@@ -255,13 +258,13 @@ class CompilerStack: public langutil::CharStreamProvider
255
258
std::vector<std::string> const & unhandledSMTLib2Queries () const { return m_unhandledSMTLib2Queries; }
256
259
257
260
// / @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 ;
259
262
260
263
// / @returns the name of the last contract. If _sourceName is defined the last contract of that source will be returned.
261
264
std::string const lastContractName (std::optional<std::string> const & _sourceName = std::nullopt) const ;
262
265
263
266
// / @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 ;
265
268
266
269
// / @returns the IR representation of a contract.
267
270
std::string const & yulIR (std::string const & _contractName) const ;
@@ -276,10 +279,10 @@ class CompilerStack: public langutil::CharStreamProvider
276
279
Json::Value const & yulIROptimizedAst (std::string const & _contractName) const ;
277
280
278
281
// / @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 ;
280
283
281
284
// / @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 ;
283
286
284
287
// / @returns normal contract assembly items
285
288
evmasm::AssemblyItems const * assemblyItems (std::string const & _contractName) const ;
@@ -293,21 +296,21 @@ class CompilerStack: public langutil::CharStreamProvider
293
296
294
297
// / @returns the string that provides a mapping between bytecode and sourcecode or a nullptr
295
298
// / 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 ;
297
300
298
301
// / @returns the string that provides a mapping between runtime bytecode and sourcecode.
299
302
// / 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 ;
301
304
302
305
// / @return a verbose text representation of the assembly.
303
306
// / @arg _sourceCodes is the map of input files to source code strings
304
307
// / 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 ;
306
309
307
310
// / @returns a JSON representation of the assembly.
308
311
// / @arg _sourceCodes is the map of input files to source code strings
309
312
// / Prerequisite: Successful compilation.
310
- Json::Value assemblyJSON (std::string const & _contractName) const ;
313
+ virtual Json::Value assemblyJSON (std::string const & _contractName) const override ;
311
314
312
315
// / @returns a JSON representing the contract ABI.
313
316
// / Prerequisite: Successful call to parse or compile.
0 commit comments