mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Some move semantics improvements.
This commit is contained in:
@@ -256,7 +256,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
||||
string contents = m_readFile(fileName);
|
||||
if (contents.empty())
|
||||
error<InvalidName>(std::string("File not found (or empty): ") + fileName);
|
||||
m_asm.append(CodeFragment::compile(contents, _s, m_readFile).m_asm);
|
||||
m_asm.append(CodeFragment::compile(std::move(contents), _s, m_readFile).m_asm);
|
||||
}
|
||||
else if (us == "SET")
|
||||
{
|
||||
@@ -745,11 +745,11 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
||||
}
|
||||
}
|
||||
|
||||
CodeFragment CodeFragment::compile(string const& _src, CompilerState& _s, ReadCallback const& _readFile)
|
||||
CodeFragment CodeFragment::compile(string _src, CompilerState& _s, ReadCallback const& _readFile)
|
||||
{
|
||||
CodeFragment ret;
|
||||
sp::utree o;
|
||||
parseTreeLLL(_src, o);
|
||||
parseTreeLLL(std::move(_src), o);
|
||||
if (!o.empty())
|
||||
ret = CodeFragment(o, _s, _readFile);
|
||||
_s.treesToKill.push_back(o);
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
CodeFragment() = default;
|
||||
CodeFragment(sp::utree const& _t, CompilerState& _s, ReadCallback const& _readFile, bool _allowASM = false);
|
||||
|
||||
static CodeFragment compile(std::string const& _src, CompilerState& _s, ReadCallback const& _readFile);
|
||||
static CodeFragment compile(std::string _src, CompilerState& _s, ReadCallback const& _readFile);
|
||||
|
||||
/// Consolidates data and compiles code.
|
||||
eth::Assembly& assembly(CompilerState const& _cs) { finalise(_cs); return m_asm; }
|
||||
@@ -69,4 +69,3 @@ static CodeFragment const NullCodeFragment;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -28,13 +28,13 @@ using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::lll;
|
||||
|
||||
bytes dev::lll::compileLLL(string const& _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
||||
bytes dev::lll::compileLLL(string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
CompilerState cs;
|
||||
cs.populateStandard();
|
||||
auto assembly = CodeFragment::compile(_src, cs, _readFile).assembly(cs);
|
||||
auto assembly = CodeFragment::compile(std::move(_src), cs, _readFile).assembly(cs);
|
||||
if (_opt)
|
||||
assembly = assembly.optimise(true, _evmVersion, true, 200);
|
||||
bytes ret = assembly.assemble().bytecode;
|
||||
@@ -66,13 +66,13 @@ bytes dev::lll::compileLLL(string const& _src, langutil::EVMVersion _evmVersion,
|
||||
return bytes();
|
||||
}
|
||||
|
||||
std::string dev::lll::compileLLLToAsm(std::string const& _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
||||
std::string dev::lll::compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
CompilerState cs;
|
||||
cs.populateStandard();
|
||||
auto assembly = CodeFragment::compile(_src, cs, _readFile).assembly(cs);
|
||||
auto assembly = CodeFragment::compile(std::move(_src), cs, _readFile).assembly(cs);
|
||||
if (_opt)
|
||||
assembly = assembly.optimise(true, _evmVersion, true, 200);
|
||||
string ret = assembly.assemblyString();
|
||||
@@ -104,13 +104,13 @@ std::string dev::lll::compileLLLToAsm(std::string const& _src, langutil::EVMVers
|
||||
return string();
|
||||
}
|
||||
|
||||
string dev::lll::parseLLL(string const& _src)
|
||||
string dev::lll::parseLLL(string _src)
|
||||
{
|
||||
sp::utree o;
|
||||
|
||||
try
|
||||
{
|
||||
parseTreeLLL(_src, o);
|
||||
parseTreeLLL(std::move(_src), o);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
+3
-3
@@ -35,9 +35,9 @@ namespace lll
|
||||
|
||||
using ReadCallback = std::function<std::string(std::string const&)>;
|
||||
|
||||
std::string parseLLL(std::string const& _src);
|
||||
std::string compileLLLToAsm(std::string const& _src, langutil::EVMVersion _evmVersion, bool _opt = true, std::vector<std::string>* _errors = nullptr, ReadCallback const& _readFile = ReadCallback());
|
||||
bytes compileLLL(std::string const& _src, langutil::EVMVersion _evmVersion, bool _opt = true, std::vector<std::string>* _errors = nullptr, ReadCallback const& _readFile = ReadCallback());
|
||||
std::string parseLLL(std::string _src);
|
||||
std::string compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion, bool _opt = true, std::vector<std::string>* _errors = nullptr, ReadCallback const& _readFile = ReadCallback());
|
||||
bytes compileLLL(std::string _src, langutil::EVMVersion _evmVersion, bool _opt = true, std::vector<std::string>* _errors = nullptr, ReadCallback const& _readFile = ReadCallback());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user