Skip to content

Commit

Permalink
Merge pull request #8055 from ethereum/ewasm-rename
Browse files Browse the repository at this point in the history
Rename to consistent usage of Ewasm
  • Loading branch information
chriseth authored Dec 19, 2019
2 parents 8511012 + 9c27e98 commit d420fe3
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 97 deletions.
34 changes: 17 additions & 17 deletions libsolidity/interface/CompilerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1069,31 +1069,31 @@ 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
yul::AssemblyStack stack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, m_optimiserSettings);
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
Expand Down
22 changes: 11 additions & 11 deletions libsolidity/interface/CompilerStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ class CompilerStack: boost::noncopyable
/// 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.
Expand Down Expand Up @@ -251,11 +251,11 @@ class CompilerStack: boost::noncopyable
/// @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;
Expand Down Expand Up @@ -338,8 +338,8 @@ class CompilerStack: boost::noncopyable
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;
Expand Down Expand Up @@ -374,8 +374,8 @@ class CompilerStack: boost::noncopyable
/// 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.
Expand Down Expand Up @@ -436,7 +436,7 @@ class CompilerStack: boost::noncopyable
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"
Expand Down
14 changes: 7 additions & 7 deletions libsolidity/interface/StandardCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions libyul/AssemblyStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/


Expand Down Expand Up @@ -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, "");
Expand Down Expand Up @@ -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"
);

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions libyul/AssemblyStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion libyul/backends/wasm/BinaryTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libyul/backends/wasm/BinaryTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libyul/backends/wasm/TextTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libyul/backends/wasm/TextTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit d420fe3

Please sign in to comment.