mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #8055 from ethereum/ewasm-rename
Rename to consistent usage of Ewasm
This commit is contained in:
		
						commit
						d420fe3786
					
				| @ -77,7 +77,7 @@ CompilerStack::CompilerStack(ReadCallback::Callback const& _readFile): | ||||
| 	m_readFile{_readFile}, | ||||
| 	m_enabledSMTSolvers{smt::SMTSolverChoice::All()}, | ||||
| 	m_generateIR{false}, | ||||
| 	m_generateEWasm{false}, | ||||
| 	m_generateEwasm{false}, | ||||
| 	m_errorList{}, | ||||
| 	m_errorReporter{m_errorList} | ||||
| { | ||||
| @ -200,7 +200,7 @@ void CompilerStack::reset(bool _keepSettings) | ||||
| 		m_evmVersion = langutil::EVMVersion(); | ||||
| 		m_enabledSMTSolvers = smt::SMTSolverChoice::All(); | ||||
| 		m_generateIR = false; | ||||
| 		m_generateEWasm = false; | ||||
| 		m_generateEwasm = false; | ||||
| 		m_revertStrings = RevertStrings::Default; | ||||
| 		m_optimiserSettings = OptimiserSettings::minimal(); | ||||
| 		m_metadataLiteralSources = false; | ||||
| @ -463,10 +463,10 @@ bool CompilerStack::compile() | ||||
| 				if (isRequestedContract(*contract)) | ||||
| 				{ | ||||
| 					compileContract(*contract, otherCompilers); | ||||
| 					if (m_generateIR || m_generateEWasm) | ||||
| 					if (m_generateIR || m_generateEwasm) | ||||
| 						generateIR(*contract); | ||||
| 					if (m_generateEWasm) | ||||
| 						generateEWasm(*contract); | ||||
| 					if (m_generateEwasm) | ||||
| 						generateEwasm(*contract); | ||||
| 				} | ||||
| 	m_stackState = CompilationSuccessful; | ||||
| 	this->link(); | ||||
| @ -592,20 +592,20 @@ string const& CompilerStack::yulIROptimized(string const& _contractName) const | ||||
| 	return contract(_contractName).yulIROptimized; | ||||
| } | ||||
| 
 | ||||
| string const& CompilerStack::eWasm(string const& _contractName) const | ||||
| string const& CompilerStack::ewasm(string const& _contractName) const | ||||
| { | ||||
| 	if (m_stackState != CompilationSuccessful) | ||||
| 		BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); | ||||
| 
 | ||||
| 	return contract(_contractName).eWasm; | ||||
| 	return contract(_contractName).ewasm; | ||||
| } | ||||
| 
 | ||||
| eth::LinkerObject const& CompilerStack::eWasmObject(string const& _contractName) const | ||||
| eth::LinkerObject const& CompilerStack::ewasmObject(string const& _contractName) const | ||||
| { | ||||
| 	if (m_stackState != CompilationSuccessful) | ||||
| 		BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); | ||||
| 
 | ||||
| 	return contract(_contractName).eWasmObject; | ||||
| 	return contract(_contractName).ewasmObject; | ||||
| } | ||||
| 
 | ||||
| eth::LinkerObject const& CompilerStack::object(string const& _contractName) const | ||||
| @ -1069,15 +1069,15 @@ void CompilerStack::generateIR(ContractDefinition const& _contract) | ||||
| 	tie(compiledContract.yulIR, compiledContract.yulIROptimized) = generator.run(_contract); | ||||
| } | ||||
| 
 | ||||
| void CompilerStack::generateEWasm(ContractDefinition const& _contract) | ||||
| void CompilerStack::generateEwasm(ContractDefinition const& _contract) | ||||
| { | ||||
| 	solAssert(m_stackState >= AnalysisPerformed, ""); | ||||
| 	if (m_hasError) | ||||
| 		BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Called generateEWasm with errors.")); | ||||
| 		BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Called generateEwasm with errors.")); | ||||
| 
 | ||||
| 	Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName()); | ||||
| 	solAssert(!compiledContract.yulIROptimized.empty(), ""); | ||||
| 	if (!compiledContract.eWasm.empty()) | ||||
| 	if (!compiledContract.ewasm.empty()) | ||||
| 		return; | ||||
| 
 | ||||
| 	// Re-parse the Yul IR in EVM dialect
 | ||||
| @ -1085,15 +1085,15 @@ void CompilerStack::generateEWasm(ContractDefinition const& _contract) | ||||
| 	stack.parseAndAnalyze("", compiledContract.yulIROptimized); | ||||
| 
 | ||||
| 	stack.optimize(); | ||||
| 	stack.translate(yul::AssemblyStack::Language::EWasm); | ||||
| 	stack.translate(yul::AssemblyStack::Language::Ewasm); | ||||
| 	stack.optimize(); | ||||
| 
 | ||||
| 	//cout << yul::AsmPrinter{}(*stack.parserResult()->code) << endl;
 | ||||
| 
 | ||||
| 	// Turn into eWasm text representation.
 | ||||
| 	auto result = stack.assemble(yul::AssemblyStack::Machine::eWasm); | ||||
| 	compiledContract.eWasm = std::move(result.assembly); | ||||
| 	compiledContract.eWasmObject = std::move(*result.bytecode); | ||||
| 	// Turn into Ewasm text representation.
 | ||||
| 	auto result = stack.assemble(yul::AssemblyStack::Machine::Ewasm); | ||||
| 	compiledContract.ewasm = std::move(result.assembly); | ||||
| 	compiledContract.ewasmObject = std::move(*result.bytecode); | ||||
| } | ||||
| 
 | ||||
| CompilerStack::Contract const& CompilerStack::contract(string const& _contractName) const | ||||
|  | ||||
| @ -178,8 +178,8 @@ public: | ||||
| 	/// Enable experimental generation of Yul IR code.
 | ||||
| 	void enableIRGeneration(bool _enable = true) { m_generateIR = _enable; } | ||||
| 
 | ||||
| 	/// Enable experimental generation of eWasm code. If enabled, IR is also generated.
 | ||||
| 	void enableEWasmGeneration(bool _enable = true) { m_generateEWasm = _enable; } | ||||
| 	/// Enable experimental generation of Ewasm code. If enabled, IR is also generated.
 | ||||
| 	void enableEwasmGeneration(bool _enable = true) { m_generateEwasm = _enable; } | ||||
| 
 | ||||
| 	/// @arg _metadataLiteralSources When true, store sources as literals in the contract metadata.
 | ||||
| 	/// Must be set before parsing.
 | ||||
| @ -251,11 +251,11 @@ public: | ||||
| 	/// @returns the optimized IR representation of a contract.
 | ||||
| 	std::string const& yulIROptimized(std::string const& _contractName) const; | ||||
| 
 | ||||
| 	/// @returns the eWasm text representation of a contract.
 | ||||
| 	std::string const& eWasm(std::string const& _contractName) const; | ||||
| 	/// @returns the Ewasm text representation of a contract.
 | ||||
| 	std::string const& ewasm(std::string const& _contractName) const; | ||||
| 
 | ||||
| 	/// @returns the eWasm representation of a contract.
 | ||||
| 	eth::LinkerObject const& eWasmObject(std::string const& _contractName) const; | ||||
| 	/// @returns the Ewasm representation of a contract.
 | ||||
| 	eth::LinkerObject const& ewasmObject(std::string const& _contractName) const; | ||||
| 
 | ||||
| 	/// @returns the assembled object for a contract.
 | ||||
| 	eth::LinkerObject const& object(std::string const& _contractName) const; | ||||
| @ -338,8 +338,8 @@ private: | ||||
| 		eth::LinkerObject runtimeObject; ///< Runtime object.
 | ||||
| 		std::string yulIR; ///< Experimental Yul IR code.
 | ||||
| 		std::string yulIROptimized; ///< Optimized experimental Yul IR code.
 | ||||
| 		std::string eWasm; ///< Experimental eWasm text representation
 | ||||
| 		eth::LinkerObject eWasmObject; ///< Experimental eWasm code
 | ||||
| 		std::string ewasm; ///< Experimental Ewasm text representation
 | ||||
| 		eth::LinkerObject ewasmObject; ///< Experimental Ewasm code
 | ||||
| 		mutable std::unique_ptr<std::string const> metadata; ///< The metadata json that will be hashed into the chain.
 | ||||
| 		mutable std::unique_ptr<Json::Value const> abi; | ||||
| 		mutable std::unique_ptr<Json::Value const> storageLayout; | ||||
| @ -374,8 +374,8 @@ private: | ||||
| 	/// The IR is stored but otherwise unused.
 | ||||
| 	void generateIR(ContractDefinition const& _contract); | ||||
| 
 | ||||
| 	/// Generate eWasm representation for a single contract.
 | ||||
| 	void generateEWasm(ContractDefinition const& _contract); | ||||
| 	/// Generate Ewasm representation for a single contract.
 | ||||
| 	void generateEwasm(ContractDefinition const& _contract); | ||||
| 
 | ||||
| 	/// Links all the known library addresses in the available objects. Any unknown
 | ||||
| 	/// library will still be kept as an unlinked placeholder in the objects.
 | ||||
| @ -436,7 +436,7 @@ private: | ||||
| 	smt::SMTSolverChoice m_enabledSMTSolvers; | ||||
| 	std::map<std::string, std::set<std::string>> m_requestedContractNames; | ||||
| 	bool m_generateIR; | ||||
| 	bool m_generateEWasm; | ||||
| 	bool m_generateEwasm; | ||||
| 	std::map<std::string, h160> m_libraries; | ||||
| 	/// list of path prefix remappings, e.g. mylibrary: github.com/ethereum = /usr/local/ethereum
 | ||||
| 	/// "context:prefix=target"
 | ||||
|  | ||||
| @ -247,9 +247,9 @@ bool isBinaryRequested(Json::Value const& _outputSelection) | ||||
| 	return false; | ||||
| } | ||||
| 
 | ||||
| /// @returns true if any eWasm code was requested. Note that as an exception, '*' does not
 | ||||
| /// @returns true if any Ewasm code was requested. Note that as an exception, '*' does not
 | ||||
| /// yet match "ewasm.wast" or "ewasm"
 | ||||
| bool isEWasmRequested(Json::Value const& _outputSelection) | ||||
| bool isEwasmRequested(Json::Value const& _outputSelection) | ||||
| { | ||||
| 	if (!_outputSelection.isObject()) | ||||
| 		return false; | ||||
| @ -267,7 +267,7 @@ bool isEWasmRequested(Json::Value const& _outputSelection) | ||||
| /// yet match "ir" or "irOptimized"
 | ||||
| bool isIRRequested(Json::Value const& _outputSelection) | ||||
| { | ||||
| 	if (isEWasmRequested(_outputSelection)) | ||||
| 	if (isEwasmRequested(_outputSelection)) | ||||
| 		return true; | ||||
| 
 | ||||
| 	if (!_outputSelection.isObject()) | ||||
| @ -780,7 +780,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting | ||||
| 
 | ||||
| 	compilerStack.enableIRGeneration(isIRRequested(_inputsAndSettings.outputSelection)); | ||||
| 
 | ||||
| 	compilerStack.enableEWasmGeneration(isEWasmRequested(_inputsAndSettings.outputSelection)); | ||||
| 	compilerStack.enableEwasmGeneration(isEwasmRequested(_inputsAndSettings.outputSelection)); | ||||
| 
 | ||||
| 	Json::Value errors = std::move(_inputsAndSettings.errors); | ||||
| 
 | ||||
| @ -956,11 +956,11 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting | ||||
| 		if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "irOptimized", wildcardMatchesExperimental)) | ||||
| 			contractData["irOptimized"] = compilerStack.yulIROptimized(contractName); | ||||
| 
 | ||||
| 		// eWasm
 | ||||
| 		// Ewasm
 | ||||
| 		if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "ewasm.wast", wildcardMatchesExperimental)) | ||||
| 			contractData["ewasm"]["wast"] = compilerStack.eWasm(contractName); | ||||
| 			contractData["ewasm"]["wast"] = compilerStack.ewasm(contractName); | ||||
| 		if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "ewasm.wasm", wildcardMatchesExperimental)) | ||||
| 			contractData["ewasm"]["wasm"] = compilerStack.eWasmObject(contractName).toHex(); | ||||
| 			contractData["ewasm"]["wasm"] = compilerStack.ewasmObject(contractName).toHex(); | ||||
| 
 | ||||
| 		// EVM
 | ||||
| 		Json::Value evmData(Json::objectValue); | ||||
|  | ||||
| @ -16,7 +16,7 @@ | ||||
| */ | ||||
| /**
 | ||||
|  * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and | ||||
|  * eWasm as output. | ||||
|  * Ewasm as output. | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| @ -59,7 +59,7 @@ Dialect const& languageToDialect(AssemblyStack::Language _language, EVMVersion _ | ||||
| 		return EVMDialect::strictAssemblyForEVMObjects(_version); | ||||
| 	case AssemblyStack::Language::Yul: | ||||
| 		return Dialect::yul(); | ||||
| 	case AssemblyStack::Language::EWasm: | ||||
| 	case AssemblyStack::Language::Ewasm: | ||||
| 		return WasmDialect::instance(); | ||||
| 	} | ||||
| 	yulAssert(false, ""); | ||||
| @ -108,7 +108,7 @@ void AssemblyStack::translate(AssemblyStack::Language _targetLanguage) | ||||
| 		return; | ||||
| 
 | ||||
| 	solAssert( | ||||
| 		m_language == Language::StrictAssembly && _targetLanguage == Language::EWasm, | ||||
| 		m_language == Language::StrictAssembly && _targetLanguage == Language::Ewasm, | ||||
| 		"Invalid language combination" | ||||
| 	); | ||||
| 
 | ||||
| @ -214,9 +214,9 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const | ||||
| 		/// TODO: fill out text representation
 | ||||
| 		return object; | ||||
| 	} | ||||
| 	case Machine::eWasm: | ||||
| 	case Machine::Ewasm: | ||||
| 	{ | ||||
| 		yulAssert(m_language == Language::EWasm, ""); | ||||
| 		yulAssert(m_language == Language::Ewasm, ""); | ||||
| 		Dialect const& dialect = languageToDialect(m_language, EVMVersion{}); | ||||
| 
 | ||||
| 		MachineAssemblyObject object; | ||||
|  | ||||
| @ -16,7 +16,7 @@ | ||||
| */ | ||||
| /**
 | ||||
|  * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and | ||||
|  * eWasm as output. | ||||
|  * Ewasm as output. | ||||
|  */ | ||||
| 
 | ||||
| #pragma once | ||||
| @ -52,13 +52,13 @@ struct MachineAssemblyObject | ||||
| 
 | ||||
| /*
 | ||||
|  * Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and | ||||
|  * eWasm as output. | ||||
|  * Ewasm as output. | ||||
|  */ | ||||
| class AssemblyStack | ||||
| { | ||||
| public: | ||||
| 	enum class Language { Yul, Assembly, StrictAssembly, EWasm }; | ||||
| 	enum class Machine { EVM, EVM15, eWasm }; | ||||
| 	enum class Language { Yul, Assembly, StrictAssembly, Ewasm }; | ||||
| 	enum class Machine { EVM, EVM15, Ewasm }; | ||||
| 
 | ||||
| 	AssemblyStack(): | ||||
| 		AssemblyStack(langutil::EVMVersion{}, Language::Assembly, dev::solidity::OptimiserSettings::none()) | ||||
|  | ||||
| @ -15,7 +15,7 @@ | ||||
| 	along with solidity.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| */ | ||||
| /**
 | ||||
|  * EWasm to binary encoder. | ||||
|  * Component that transforms internal Wasm representation to binary. | ||||
|  */ | ||||
| 
 | ||||
| #include <libyul/backends/wasm/BinaryTransform.h> | ||||
|  | ||||
| @ -15,7 +15,7 @@ | ||||
| 	along with solidity.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| */ | ||||
| /**
 | ||||
|  * EWasm to binary encoder. | ||||
|  * Component that transforms internal Wasm representation to binary. | ||||
|  */ | ||||
| 
 | ||||
| #pragma once | ||||
|  | ||||
| @ -15,7 +15,7 @@ | ||||
| 	along with solidity.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| */ | ||||
| /**
 | ||||
|  * Component that transforms interval Wasm representation to text. | ||||
|  * Component that transforms internal Wasm representation to text. | ||||
|  */ | ||||
| 
 | ||||
| #include <libyul/backends/wasm/TextTransform.h> | ||||
|  | ||||
| @ -15,7 +15,7 @@ | ||||
| 	along with solidity.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| */ | ||||
| /**
 | ||||
|  * Component that transforms interval Wasm representation to text. | ||||
|  * Component that transforms internal Wasm representation to text. | ||||
|  */ | ||||
| 
 | ||||
| #pragma once | ||||
|  | ||||
| @ -116,7 +116,7 @@ static string const g_strErrorRecovery = "error-recovery"; | ||||
| static string const g_strEVM = "evm"; | ||||
| static string const g_strEVM15 = "evm15"; | ||||
| static string const g_strEVMVersion = "evm-version"; | ||||
| static string const g_streWasm = "ewasm"; | ||||
| static string const g_strEwasm = "ewasm"; | ||||
| static string const g_strGas = "gas"; | ||||
| static string const g_strHelp = "help"; | ||||
| static string const g_strInputFile = "input-file"; | ||||
| @ -125,7 +125,6 @@ static string const g_strYul = "yul"; | ||||
| static string const g_strYulDialect = "yul-dialect"; | ||||
| static string const g_strIR = "ir"; | ||||
| static string const g_strIPFS = "ipfs"; | ||||
| static string const g_strEWasm = "ewasm"; | ||||
| static string const g_strLicense = "license"; | ||||
| static string const g_strLibraries = "libraries"; | ||||
| static string const g_strLink = "link"; | ||||
| @ -187,7 +186,7 @@ static string const g_argHelp = g_strHelp; | ||||
| static string const g_argInputFile = g_strInputFile; | ||||
| static string const g_argYul = g_strYul; | ||||
| static string const g_argIR = g_strIR; | ||||
| static string const g_argEWasm = g_strEWasm; | ||||
| static string const g_argEwasm = g_strEwasm; | ||||
| static string const g_argLibraries = g_strLibraries; | ||||
| static string const g_argLink = g_strLink; | ||||
| static string const g_argMachine = g_strMachine; | ||||
| @ -234,14 +233,14 @@ static set<string> const g_machineArgs | ||||
| { | ||||
| 	g_strEVM, | ||||
| 	g_strEVM15, | ||||
| 	g_streWasm | ||||
| 	g_strEwasm | ||||
| }; | ||||
| 
 | ||||
| /// Possible arguments to for --yul-dialect
 | ||||
| static set<string> const g_yulDialectArgs | ||||
| { | ||||
| 	g_strEVM, | ||||
| 	g_streWasm | ||||
| 	g_strEwasm | ||||
| }; | ||||
| 
 | ||||
| /// Possible arguments to for --metadata-hash
 | ||||
| @ -345,23 +344,23 @@ void CommandLineInterface::handleIR(string const& _contractName) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void CommandLineInterface::handleEWasm(string const& _contractName) | ||||
| void CommandLineInterface::handleEwasm(string const& _contractName) | ||||
| { | ||||
| 	if (m_args.count(g_argEWasm)) | ||||
| 	if (m_args.count(g_argEwasm)) | ||||
| 	{ | ||||
| 		if (m_args.count(g_argOutputDir)) | ||||
| 		{ | ||||
| 			createFile(m_compiler->filesystemFriendlyName(_contractName) + ".wast", m_compiler->eWasm(_contractName)); | ||||
| 			createFile(m_compiler->filesystemFriendlyName(_contractName) + ".wast", m_compiler->ewasm(_contractName)); | ||||
| 			createFile( | ||||
| 				m_compiler->filesystemFriendlyName(_contractName) + ".wasm", | ||||
| 				asString(m_compiler->eWasmObject(_contractName).bytecode) | ||||
| 				asString(m_compiler->ewasmObject(_contractName).bytecode) | ||||
| 			); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			sout() << "EWasm text:" << endl; | ||||
| 			sout() << m_compiler->eWasm(_contractName) << endl; | ||||
| 			sout() << "EWasm binary (hex): " << m_compiler->eWasmObject(_contractName).toHex() << endl; | ||||
| 			sout() << "Ewasm text:" << endl; | ||||
| 			sout() << m_compiler->ewasm(_contractName) << endl; | ||||
| 			sout() << "Ewasm binary (hex): " << m_compiler->ewasmObject(_contractName).toHex() << endl; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @ -776,7 +775,7 @@ Allowed options)", | ||||
| 		(g_argBinaryRuntime.c_str(), "Binary of the runtime part of the contracts in hex.") | ||||
| 		(g_argAbi.c_str(), "ABI specification of the contracts.") | ||||
| 		(g_argIR.c_str(), "Intermediate Representation (IR) of all contracts (EXPERIMENTAL).") | ||||
| 		(g_argEWasm.c_str(), "EWasm text representation of all contracts (EXPERIMENTAL).") | ||||
| 		(g_argEwasm.c_str(), "Ewasm text representation of all contracts (EXPERIMENTAL).") | ||||
| 		(g_argSignatureHashes.c_str(), "Function signature hashes of the contracts.") | ||||
| 		(g_argNatspecUser.c_str(), "Natspec user documentation of all contracts.") | ||||
| 		(g_argNatspecDev.c_str(), "Natspec developer documentation of all contracts.") | ||||
| @ -981,27 +980,27 @@ bool CommandLineInterface::processInput() | ||||
| 				targetMachine = Machine::EVM; | ||||
| 			else if (machine == g_strEVM15) | ||||
| 				targetMachine = Machine::EVM15; | ||||
| 			else if (machine == g_streWasm) | ||||
| 				targetMachine = Machine::eWasm; | ||||
| 			else if (machine == g_strEwasm) | ||||
| 				targetMachine = Machine::Ewasm; | ||||
| 			else | ||||
| 			{ | ||||
| 				serr() << "Invalid option for --machine: " << machine << endl; | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
| 		if (targetMachine == Machine::eWasm && inputLanguage == Input::StrictAssembly) | ||||
| 			inputLanguage = Input::EWasm; | ||||
| 		if (targetMachine == Machine::Ewasm && inputLanguage == Input::StrictAssembly) | ||||
| 			inputLanguage = Input::Ewasm; | ||||
| 		if (m_args.count(g_strYulDialect)) | ||||
| 		{ | ||||
| 			string dialect = m_args[g_strYulDialect].as<string>(); | ||||
| 			if (dialect == g_strEVM) | ||||
| 				inputLanguage = Input::StrictAssembly; | ||||
| 			else if (dialect == g_streWasm) | ||||
| 			else if (dialect == g_strEwasm) | ||||
| 			{ | ||||
| 				inputLanguage = Input::EWasm; | ||||
| 				if (targetMachine != Machine::eWasm) | ||||
| 				inputLanguage = Input::Ewasm; | ||||
| 				if (targetMachine != Machine::Ewasm) | ||||
| 				{ | ||||
| 					serr() << "If you select eWasm as --yul-dialect, --machine has to be eWasm as well." << endl; | ||||
| 					serr() << "If you select Ewasm as --yul-dialect, --machine has to be Ewasm as well." << endl; | ||||
| 					return false; | ||||
| 				} | ||||
| 			} | ||||
| @ -1011,7 +1010,7 @@ bool CommandLineInterface::processInput() | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
| 		if (optimize && (inputLanguage != Input::StrictAssembly && inputLanguage != Input::EWasm)) | ||||
| 		if (optimize && (inputLanguage != Input::StrictAssembly && inputLanguage != Input::Ewasm)) | ||||
| 		{ | ||||
| 			serr() << | ||||
| 				"Optimizer can only be used for strict assembly. Use --" << | ||||
| @ -1074,7 +1073,7 @@ bool CommandLineInterface::processInput() | ||||
| 		// TODO: Perhaps we should not compile unless requested
 | ||||
| 
 | ||||
| 		m_compiler->enableIRGeneration(m_args.count(g_argIR)); | ||||
| 		m_compiler->enableEWasmGeneration(m_args.count(g_argEWasm)); | ||||
| 		m_compiler->enableEwasmGeneration(m_args.count(g_argEwasm)); | ||||
| 
 | ||||
| 		OptimiserSettings settings = m_args.count(g_argOptimize) ? OptimiserSettings::standard() : OptimiserSettings::minimal(); | ||||
| 		settings.expectedExecutionsPerDeployment = m_args[g_argOptimizeRuns].as<unsigned>(); | ||||
| @ -1453,7 +1452,7 @@ bool CommandLineInterface::assemble( | ||||
| 		string machine = | ||||
| 			_targetMachine == yul::AssemblyStack::Machine::EVM ? "EVM" : | ||||
| 			_targetMachine == yul::AssemblyStack::Machine::EVM15 ? "EVM 1.5" : | ||||
| 			"eWasm"; | ||||
| 			"Ewasm"; | ||||
| 		sout() << endl << "======= " << src.first << " (" << machine << ") =======" << endl; | ||||
| 
 | ||||
| 		yul::AssemblyStack& stack = assemblyStacks[src.first]; | ||||
| @ -1461,9 +1460,9 @@ bool CommandLineInterface::assemble( | ||||
| 		sout() << endl << "Pretty printed source:" << endl; | ||||
| 		sout() << stack.print() << endl; | ||||
| 
 | ||||
| 		if (_language != yul::AssemblyStack::Language::EWasm && _targetMachine == yul::AssemblyStack::Machine::eWasm) | ||||
| 		if (_language != yul::AssemblyStack::Language::Ewasm && _targetMachine == yul::AssemblyStack::Machine::Ewasm) | ||||
| 		{ | ||||
| 			stack.translate(yul::AssemblyStack::Language::EWasm); | ||||
| 			stack.translate(yul::AssemblyStack::Language::Ewasm); | ||||
| 			stack.optimize(); | ||||
| 
 | ||||
| 			sout() << endl << "==========================" << endl; | ||||
| @ -1554,7 +1553,7 @@ void CommandLineInterface::outputCompilationResults() | ||||
| 
 | ||||
| 		handleBytecode(contract); | ||||
| 		handleIR(contract); | ||||
| 		handleEWasm(contract); | ||||
| 		handleEwasm(contract); | ||||
| 		handleSignatureHashes(contract); | ||||
| 		handleMetadata(contract); | ||||
| 		handleABI(contract); | ||||
|  | ||||
| @ -67,7 +67,7 @@ private: | ||||
| 	void handleBinary(std::string const& _contract); | ||||
| 	void handleOpcode(std::string const& _contract); | ||||
| 	void handleIR(std::string const& _contract); | ||||
| 	void handleEWasm(std::string const& _contract); | ||||
| 	void handleEwasm(std::string const& _contract); | ||||
| 	void handleBytecode(std::string const& _contract); | ||||
| 	void handleSignatureHashes(std::string const& _contract); | ||||
| 	void handleMetadata(std::string const& _contract); | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| 
 | ||||
| ======= evm_to_wasm/input.sol (eWasm) ======= | ||||
| ======= evm_to_wasm/input.sol (Ewasm) ======= | ||||
| 
 | ||||
| Pretty printed source: | ||||
| object "object" { | ||||
|  | ||||
| @ -1,8 +1,8 @@ | ||||
| set(sources | ||||
| 	EVMInstructionInterpreter.h | ||||
| 	EVMInstructionInterpreter.cpp | ||||
| 	EWasmBuiltinInterpreter.h | ||||
| 	EWasmBuiltinInterpreter.cpp | ||||
| 	EwasmBuiltinInterpreter.h | ||||
| 	EwasmBuiltinInterpreter.cpp | ||||
| 	Interpreter.h | ||||
| 	Interpreter.cpp | ||||
| ) | ||||
|  | ||||
| @ -15,10 +15,10 @@ | ||||
| 	along with solidity.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| */ | ||||
| /**
 | ||||
|  * Yul interpreter module that evaluates EWasm builtins. | ||||
|  * Yul interpreter module that evaluates Ewasm builtins. | ||||
|  */ | ||||
| 
 | ||||
| #include <test/tools/yulInterpreter/EWasmBuiltinInterpreter.h> | ||||
| #include <test/tools/yulInterpreter/EwasmBuiltinInterpreter.h> | ||||
| 
 | ||||
| #include <test/tools/yulInterpreter/Interpreter.h> | ||||
| 
 | ||||
| @ -68,7 +68,7 @@ uint64_t clz(uint64_t _v) | ||||
| 
 | ||||
| using u512 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<512, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>; | ||||
| 
 | ||||
| u256 EWasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector<u256> const& _arguments) | ||||
| u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector<u256> const& _arguments) | ||||
| { | ||||
| 	vector<uint64_t> arg; | ||||
| 	for (u256 const& a: _arguments) | ||||
| @ -355,7 +355,7 @@ u256 EWasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector<u256> const& _a | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| bool EWasmBuiltinInterpreter::accessMemory(u256 const& _offset, u256 const& _size) | ||||
| bool EwasmBuiltinInterpreter::accessMemory(u256 const& _offset, u256 const& _size) | ||||
| { | ||||
| 	if (((_offset + _size) >= _offset) && ((_offset + _size + 0x1f) >= (_offset + _size))) | ||||
| 	{ | ||||
| @ -369,7 +369,7 @@ bool EWasmBuiltinInterpreter::accessMemory(u256 const& _offset, u256 const& _siz | ||||
| 	return false; | ||||
| } | ||||
| 
 | ||||
| bytes EWasmBuiltinInterpreter::readMemory(uint64_t _offset, uint64_t _size) | ||||
| bytes EwasmBuiltinInterpreter::readMemory(uint64_t _offset, uint64_t _size) | ||||
| { | ||||
| 	yulAssert(_size <= 0xffff, "Too large read."); | ||||
| 	bytes data(size_t(_size), uint8_t(0)); | ||||
| @ -378,7 +378,7 @@ bytes EWasmBuiltinInterpreter::readMemory(uint64_t _offset, uint64_t _size) | ||||
| 	return data; | ||||
| } | ||||
| 
 | ||||
| uint64_t EWasmBuiltinInterpreter::readMemoryWord(uint64_t _offset) | ||||
| uint64_t EwasmBuiltinInterpreter::readMemoryWord(uint64_t _offset) | ||||
| { | ||||
| 	uint64_t r = 0; | ||||
| 	for (size_t i = 0; i < 8; i++) | ||||
| @ -386,18 +386,18 @@ uint64_t EWasmBuiltinInterpreter::readMemoryWord(uint64_t _offset) | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| void EWasmBuiltinInterpreter::writeMemoryWord(uint64_t _offset, uint64_t _value) | ||||
| void EwasmBuiltinInterpreter::writeMemoryWord(uint64_t _offset, uint64_t _value) | ||||
| { | ||||
| 	for (size_t i = 0; i < 8; i++) | ||||
| 		m_state.memory[_offset + i] = uint8_t((_value >> (i * 8)) & 0xff); | ||||
| } | ||||
| 
 | ||||
| void EWasmBuiltinInterpreter::writeMemoryByte(uint64_t _offset, uint8_t _value) | ||||
| void EwasmBuiltinInterpreter::writeMemoryByte(uint64_t _offset, uint8_t _value) | ||||
| { | ||||
| 	m_state.memory[_offset] = _value; | ||||
| } | ||||
| 
 | ||||
| void EWasmBuiltinInterpreter::writeU256(uint64_t _offset, u256 _value, size_t _croppedTo) | ||||
| void EwasmBuiltinInterpreter::writeU256(uint64_t _offset, u256 _value, size_t _croppedTo) | ||||
| { | ||||
| 	accessMemory(_offset, _croppedTo); | ||||
| 	for (size_t i = 0; i < _croppedTo; i++) | ||||
| @ -407,7 +407,7 @@ void EWasmBuiltinInterpreter::writeU256(uint64_t _offset, u256 _value, size_t _c | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| u256 EWasmBuiltinInterpreter::readU256(uint64_t _offset, size_t _croppedTo) | ||||
| u256 EwasmBuiltinInterpreter::readU256(uint64_t _offset, size_t _croppedTo) | ||||
| { | ||||
| 	accessMemory(_offset, _croppedTo); | ||||
| 	u256 value; | ||||
| @ -417,12 +417,12 @@ u256 EWasmBuiltinInterpreter::readU256(uint64_t _offset, size_t _croppedTo) | ||||
| 	return value; | ||||
| } | ||||
| 
 | ||||
| void EWasmBuiltinInterpreter::logTrace(dev::eth::Instruction _instruction, std::vector<u256> const& _arguments, bytes const& _data) | ||||
| void EwasmBuiltinInterpreter::logTrace(dev::eth::Instruction _instruction, std::vector<u256> const& _arguments, bytes const& _data) | ||||
| { | ||||
| 	logTrace(dev::eth::instructionInfo(_instruction).name, _arguments, _data); | ||||
| } | ||||
| 
 | ||||
| void EWasmBuiltinInterpreter::logTrace(std::string const& _pseudoInstruction, std::vector<u256> const& _arguments, bytes const& _data) | ||||
| void EwasmBuiltinInterpreter::logTrace(std::string const& _pseudoInstruction, std::vector<u256> const& _arguments, bytes const& _data) | ||||
| { | ||||
| 	string message = _pseudoInstruction + "("; | ||||
| 	for (size_t i = 0; i < _arguments.size(); ++i) | ||||
| @ -15,7 +15,7 @@ | ||||
| 	along with solidity.  If not, see <http://www.gnu.org/licenses/>.
 | ||||
| */ | ||||
| /**
 | ||||
|  * Yul interpreter module that evaluates EWasm builtins. | ||||
|  * Yul interpreter module that evaluates Ewasm builtins. | ||||
|  */ | ||||
| 
 | ||||
| #pragma once | ||||
| @ -45,7 +45,7 @@ namespace test | ||||
| struct InterpreterState; | ||||
| 
 | ||||
| /**
 | ||||
|  * Interprets EWasm builtins based on the current state and logs instructions with | ||||
|  * Interprets Ewasm builtins based on the current state and logs instructions with | ||||
|  * side-effects. | ||||
|  * | ||||
|  * Since this is mainly meant to be used for differential fuzz testing, it is focused | ||||
| @ -63,10 +63,10 @@ struct InterpreterState; | ||||
|  * The main focus is that the generated execution trace is the same for equivalent executions | ||||
|  * and likely to be different for non-equivalent executions. | ||||
|  */ | ||||
| class EWasmBuiltinInterpreter | ||||
| class EwasmBuiltinInterpreter | ||||
| { | ||||
| public: | ||||
| 	explicit EWasmBuiltinInterpreter(InterpreterState& _state): | ||||
| 	explicit EwasmBuiltinInterpreter(InterpreterState& _state): | ||||
| 		m_state(_state) | ||||
| 	{} | ||||
| 	/// Evaluate builtin function
 | ||||
| @ -21,7 +21,7 @@ | ||||
| #include <test/tools/yulInterpreter/Interpreter.h> | ||||
| 
 | ||||
| #include <test/tools/yulInterpreter/EVMInstructionInterpreter.h> | ||||
| #include <test/tools/yulInterpreter/EWasmBuiltinInterpreter.h> | ||||
| #include <test/tools/yulInterpreter/EwasmBuiltinInterpreter.h> | ||||
| 
 | ||||
| #include <libyul/AsmData.h> | ||||
| #include <libyul/Dialect.h> | ||||
| @ -246,7 +246,7 @@ void ExpressionEvaluator::operator()(FunctionCall const& _funCall) | ||||
| 	else if (WasmDialect const* dialect = dynamic_cast<WasmDialect const*>(&m_dialect)) | ||||
| 		if (dialect->builtin(_funCall.functionName.name)) | ||||
| 		{ | ||||
| 			EWasmBuiltinInterpreter interpreter(m_state); | ||||
| 			EwasmBuiltinInterpreter interpreter(m_state); | ||||
| 			setValue(interpreter.evalBuiltin(_funCall.functionName.name, values())); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user