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 #include <test/tools/yulInterpreter/Interpreter.h>
19 #include <libyul/backends/evm/EVMDialect.h>
20 
21 namespace solidity::yul::test::yul_fuzzer
22 {
23 
24 struct yulFuzzerUtil
25 {
26 	enum class TerminationReason
27 	{
28 		ExplicitlyTerminated,
29 		StepLimitReached,
30 		TraceLimitReached,
31 		ExpresionNestingLimitReached,
32 		None
33 	};
34 
35 	static TerminationReason interpret(
36 		std::ostream& _os,
37 		std::shared_ptr<yul::Block> _ast,
38 		Dialect const& _dialect,
39 		bool _outputStorageOnly = false,
40 		size_t _maxSteps = maxSteps,
41 		size_t _maxTraceSize = maxTraceSize,
42 		size_t _maxExprNesting = maxExprNesting
43 	);
44 
45 	/// @returns true if @param _reason for Yul interpreter terminating is
46 	/// resource exhaustion of some form e.g., exceeded maximum time-out
47 	/// threshold, number of nested expressions etc.
48 	static bool resourceLimitsExceeded(TerminationReason _reason);
49 	static size_t constexpr maxSteps = 100;
50 	static size_t constexpr maxTraceSize = 75;
51 	static size_t constexpr maxExprNesting = 64;
52 };
53 
54 }
55