mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
commit
baaefb4b42
@ -36,7 +36,7 @@ string IndentedWriter::format() const
|
|||||||
void IndentedWriter::newLine()
|
void IndentedWriter::newLine()
|
||||||
{
|
{
|
||||||
if (!m_lines.back().contents.empty())
|
if (!m_lines.back().contents.empty())
|
||||||
m_lines.push_back({ string(), m_lines.back().indentation });
|
m_lines.emplace_back(Line{string(), m_lines.back().indentation});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndentedWriter::indent()
|
void IndentedWriter::indent()
|
||||||
|
@ -91,7 +91,7 @@ string dev::quotedAlternativesList(vector<string> const& suggestions)
|
|||||||
vector<string> quotedSuggestions;
|
vector<string> quotedSuggestions;
|
||||||
|
|
||||||
for (auto& suggestion: suggestions)
|
for (auto& suggestion: suggestions)
|
||||||
quotedSuggestions.push_back("\"" + suggestion + "\"");
|
quotedSuggestions.emplace_back("\"" + suggestion + "\"");
|
||||||
|
|
||||||
return joinHumanReadable(quotedSuggestions, ", ", " or ");
|
return joinHumanReadable(quotedSuggestions, ", ", " or ");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ AssemblyItem const& Assembly::append(AssemblyItem const& _i)
|
|||||||
{
|
{
|
||||||
assertThrow(m_deposit >= 0, AssemblyException, "Stack underflow.");
|
assertThrow(m_deposit >= 0, AssemblyException, "Stack underflow.");
|
||||||
m_deposit += _i.deposit();
|
m_deposit += _i.deposit();
|
||||||
m_items.push_back(_i);
|
m_items.emplace_back(_i);
|
||||||
if (m_items.back().location().isEmpty() && !m_currentSourceLocation.isEmpty())
|
if (m_items.back().location().isEmpty() && !m_currentSourceLocation.isEmpty())
|
||||||
m_items.back().setLocation(m_currentSourceLocation);
|
m_items.back().setLocation(m_currentSourceLocation);
|
||||||
return back();
|
return back();
|
||||||
@ -353,14 +353,14 @@ AssemblyItem Assembly::namedTag(string const& _name)
|
|||||||
assertThrow(!_name.empty(), AssemblyException, "Empty named tag.");
|
assertThrow(!_name.empty(), AssemblyException, "Empty named tag.");
|
||||||
if (!m_namedTags.count(_name))
|
if (!m_namedTags.count(_name))
|
||||||
m_namedTags[_name] = size_t(newTag().data());
|
m_namedTags[_name] = size_t(newTag().data());
|
||||||
return AssemblyItem(Tag, m_namedTags.at(_name));
|
return AssemblyItem{Tag, m_namedTags.at(_name)};
|
||||||
}
|
}
|
||||||
|
|
||||||
AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier)
|
AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier)
|
||||||
{
|
{
|
||||||
h256 h(dev::keccak256(_identifier));
|
h256 h(dev::keccak256(_identifier));
|
||||||
m_libraries[h] = _identifier;
|
m_libraries[h] = _identifier;
|
||||||
return AssemblyItem(PushLibraryAddress, h);
|
return AssemblyItem{PushLibraryAddress, h};
|
||||||
}
|
}
|
||||||
|
|
||||||
Assembly& Assembly::optimise(bool _enable, EVMVersion _evmVersion, bool _isCreation, size_t _runs)
|
Assembly& Assembly::optimise(bool _enable, EVMVersion _evmVersion, bool _isCreation, size_t _runs)
|
||||||
@ -415,14 +415,14 @@ map<u256, u256> Assembly::optimiseInternal(
|
|||||||
|
|
||||||
if (_settings.runJumpdestRemover)
|
if (_settings.runJumpdestRemover)
|
||||||
{
|
{
|
||||||
JumpdestRemover jumpdestOpt(m_items);
|
JumpdestRemover jumpdestOpt{m_items};
|
||||||
if (jumpdestOpt.optimise(_tagsReferencedFromOutside))
|
if (jumpdestOpt.optimise(_tagsReferencedFromOutside))
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings.runPeephole)
|
if (_settings.runPeephole)
|
||||||
{
|
{
|
||||||
PeepholeOptimiser peepOpt(m_items);
|
PeepholeOptimiser peepOpt{m_items};
|
||||||
while (peepOpt.optimise())
|
while (peepOpt.optimise())
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
@ -433,7 +433,7 @@ map<u256, u256> Assembly::optimiseInternal(
|
|||||||
// This only modifies PushTags, we have to run again to actually remove code.
|
// This only modifies PushTags, we have to run again to actually remove code.
|
||||||
if (_settings.runDeduplicate)
|
if (_settings.runDeduplicate)
|
||||||
{
|
{
|
||||||
BlockDeduplicator dedup(m_items);
|
BlockDeduplicator dedup{m_items};
|
||||||
if (dedup.deduplicate())
|
if (dedup.deduplicate())
|
||||||
{
|
{
|
||||||
tagReplacements.insert(dedup.replacedTags().begin(), dedup.replacedTags().end());
|
tagReplacements.insert(dedup.replacedTags().begin(), dedup.replacedTags().end());
|
||||||
@ -448,13 +448,13 @@ map<u256, u256> Assembly::optimiseInternal(
|
|||||||
// function types that can be stored in storage.
|
// function types that can be stored in storage.
|
||||||
AssemblyItems optimisedItems;
|
AssemblyItems optimisedItems;
|
||||||
|
|
||||||
bool usesMSize = (find(m_items.begin(), m_items.end(), AssemblyItem(Instruction::MSIZE)) != m_items.end());
|
bool usesMSize = (find(m_items.begin(), m_items.end(), AssemblyItem{Instruction::MSIZE}) != m_items.end());
|
||||||
|
|
||||||
auto iter = m_items.begin();
|
auto iter = m_items.begin();
|
||||||
while (iter != m_items.end())
|
while (iter != m_items.end())
|
||||||
{
|
{
|
||||||
KnownState emptyState;
|
KnownState emptyState;
|
||||||
CommonSubexpressionEliminator eliminator(emptyState);
|
CommonSubexpressionEliminator eliminator{emptyState};
|
||||||
auto orig = iter;
|
auto orig = iter;
|
||||||
iter = eliminator.feedItems(iter, m_items.end(), usesMSize);
|
iter = eliminator.feedItems(iter, m_items.end(), usesMSize);
|
||||||
bool shouldReplace = false;
|
bool shouldReplace = false;
|
||||||
|
@ -41,7 +41,7 @@ bool BlockDeduplicator::deduplicate()
|
|||||||
|
|
||||||
// Virtual tag that signifies "the current block" and which is used to optimise loops.
|
// Virtual tag that signifies "the current block" and which is used to optimise loops.
|
||||||
// We abort if this virtual tag actually exists.
|
// We abort if this virtual tag actually exists.
|
||||||
AssemblyItem pushSelf(PushTag, u256(-4));
|
AssemblyItem pushSelf{PushTag, u256(-4)};
|
||||||
if (
|
if (
|
||||||
std::count(m_items.cbegin(), m_items.cend(), pushSelf.tag()) ||
|
std::count(m_items.cbegin(), m_items.cend(), pushSelf.tag()) ||
|
||||||
std::count(m_items.cbegin(), m_items.cend(), pushSelf.pushTag())
|
std::count(m_items.cbegin(), m_items.cend(), pushSelf.pushTag())
|
||||||
@ -55,17 +55,17 @@ bool BlockDeduplicator::deduplicate()
|
|||||||
|
|
||||||
// To compare recursive loops, we have to already unify PushTag opcodes of the
|
// To compare recursive loops, we have to already unify PushTag opcodes of the
|
||||||
// block's own tag.
|
// block's own tag.
|
||||||
AssemblyItem pushFirstTag(pushSelf);
|
AssemblyItem pushFirstTag{pushSelf};
|
||||||
AssemblyItem pushSecondTag(pushSelf);
|
AssemblyItem pushSecondTag{pushSelf};
|
||||||
|
|
||||||
if (_i < m_items.size() && m_items.at(_i).type() == Tag)
|
if (_i < m_items.size() && m_items.at(_i).type() == Tag)
|
||||||
pushFirstTag = m_items.at(_i).pushTag();
|
pushFirstTag = m_items.at(_i).pushTag();
|
||||||
if (_j < m_items.size() && m_items.at(_j).type() == Tag)
|
if (_j < m_items.size() && m_items.at(_j).type() == Tag)
|
||||||
pushSecondTag = m_items.at(_j).pushTag();
|
pushSecondTag = m_items.at(_j).pushTag();
|
||||||
|
|
||||||
BlockIterator first(m_items.begin() + _i, m_items.end(), &pushFirstTag, &pushSelf);
|
BlockIterator first{m_items.begin() + _i, m_items.end(), &pushFirstTag, &pushSelf};
|
||||||
BlockIterator second(m_items.begin() + _j, m_items.end(), &pushSecondTag, &pushSelf);
|
BlockIterator second{m_items.begin() + _j, m_items.end(), &pushSecondTag, &pushSelf};
|
||||||
BlockIterator end(m_items.end(), m_items.end());
|
BlockIterator end{m_items.end(), m_items.end()};
|
||||||
|
|
||||||
if (first != end && (*first).type() == Tag)
|
if (first != end && (*first).type() == Tag)
|
||||||
++first;
|
++first;
|
||||||
@ -126,7 +126,7 @@ BlockDeduplicator::BlockIterator& BlockDeduplicator::BlockIterator::operator++()
|
|||||||
{
|
{
|
||||||
if (it == end)
|
if (it == end)
|
||||||
return *this;
|
return *this;
|
||||||
if (SemanticInformation::altersControlFlow(*it) && *it != AssemblyItem(Instruction::JUMPI))
|
if (SemanticInformation::altersControlFlow(*it) && *it != AssemblyItem{Instruction::JUMPI})
|
||||||
it = end;
|
it = end;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ void ControlFlowGraph::splitBlocks()
|
|||||||
m_blocks[id].begin = index;
|
m_blocks[id].begin = index;
|
||||||
}
|
}
|
||||||
if (item.type() == PushTag)
|
if (item.type() == PushTag)
|
||||||
m_blocks[id].pushedTags.push_back(BlockId(item.data()));
|
m_blocks[id].pushedTags.emplace_back(item.data());
|
||||||
if (SemanticInformation::altersControlFlow(item))
|
if (SemanticInformation::altersControlFlow(item))
|
||||||
{
|
{
|
||||||
m_blocks[id].end = index + 1;
|
m_blocks[id].end = index + 1;
|
||||||
|
@ -209,7 +209,7 @@ ExpressionTemplate::ExpressionTemplate(Pattern const& _pattern, SourceLocation c
|
|||||||
item = _pattern.toAssemblyItem(_location);
|
item = _pattern.toAssemblyItem(_location);
|
||||||
}
|
}
|
||||||
for (auto const& arg: _pattern.arguments())
|
for (auto const& arg: _pattern.arguments())
|
||||||
arguments.push_back(ExpressionTemplate(arg, _location));
|
arguments.emplace_back(arg, _location);
|
||||||
}
|
}
|
||||||
|
|
||||||
string ExpressionTemplate::toString() const
|
string ExpressionTemplate::toString() const
|
||||||
|
@ -105,7 +105,7 @@ class SecondarySourceLocation
|
|||||||
public:
|
public:
|
||||||
SecondarySourceLocation& append(std::string const& _errMsg, SourceLocation const& _sourceLocation)
|
SecondarySourceLocation& append(std::string const& _errMsg, SourceLocation const& _sourceLocation)
|
||||||
{
|
{
|
||||||
infos.push_back(std::make_pair(_errMsg, _sourceLocation));
|
infos.emplace_back(_errMsg, _sourceLocation);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
|||||||
if (j.tag() || j.which() != sp::utree_type::symbol_type)
|
if (j.tag() || j.which() != sp::utree_type::symbol_type)
|
||||||
error<InvalidMacroArgs>();
|
error<InvalidMacroArgs>();
|
||||||
auto sr = j.get<sp::basic_string<boost::iterator_range<char const*>, sp::utree_type::symbol_type>>();
|
auto sr = j.get<sp::basic_string<boost::iterator_range<char const*>, sp::utree_type::symbol_type>>();
|
||||||
args.push_back(string(sr.begin(), sr.end()));
|
args.emplace_back(sr.begin(), sr.end());
|
||||||
}
|
}
|
||||||
else if (ii == 3)
|
else if (ii == 3)
|
||||||
{
|
{
|
||||||
@ -464,9 +464,9 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
|||||||
if (c++)
|
if (c++)
|
||||||
{
|
{
|
||||||
if (us == "LLL" && c == 1)
|
if (us == "LLL" && c == 1)
|
||||||
code.push_back(CodeFragment(i, ns, m_readFile));
|
code.emplace_back(i, ns, m_readFile);
|
||||||
else
|
else
|
||||||
code.push_back(CodeFragment(i, _s, m_readFile));
|
code.emplace_back(i, _s, m_readFile);
|
||||||
}
|
}
|
||||||
auto requireSize = [&](unsigned s) { if (code.size() != s) error<IncorrectParameterCount>(us); };
|
auto requireSize = [&](unsigned s) { if (code.size() != s) error<IncorrectParameterCount>(us); };
|
||||||
auto requireMinSize = [&](unsigned s) { if (code.size() < s) error<IncorrectParameterCount>(us); };
|
auto requireMinSize = [&](unsigned s) { if (code.size() < s) error<IncorrectParameterCount>(us); };
|
||||||
|
@ -46,22 +46,22 @@ bytes dev::lll::compileLLL(string const& _src, dev::solidity::EVMVersion _evmVer
|
|||||||
{
|
{
|
||||||
if (_errors)
|
if (_errors)
|
||||||
{
|
{
|
||||||
_errors->push_back("Parse error.");
|
_errors->emplace_back("Parse error.");
|
||||||
_errors->push_back(boost::diagnostic_information(_e));
|
_errors->emplace_back(boost::diagnostic_information(_e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const& _e)
|
catch (std::exception const& _e)
|
||||||
{
|
{
|
||||||
if (_errors)
|
if (_errors)
|
||||||
{
|
{
|
||||||
_errors->push_back("Parse exception.");
|
_errors->emplace_back("Parse exception.");
|
||||||
_errors->push_back(boost::diagnostic_information(_e));
|
_errors->emplace_back(boost::diagnostic_information(_e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
if (_errors)
|
if (_errors)
|
||||||
_errors->push_back("Internal compiler exception.");
|
_errors->emplace_back("Internal compiler exception.");
|
||||||
}
|
}
|
||||||
return bytes();
|
return bytes();
|
||||||
}
|
}
|
||||||
@ -84,22 +84,22 @@ std::string dev::lll::compileLLLToAsm(std::string const& _src, EVMVersion _evmVe
|
|||||||
{
|
{
|
||||||
if (_errors)
|
if (_errors)
|
||||||
{
|
{
|
||||||
_errors->push_back("Parse error.");
|
_errors->emplace_back("Parse error.");
|
||||||
_errors->push_back(boost::diagnostic_information(_e));
|
_errors->emplace_back(boost::diagnostic_information(_e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const& _e)
|
catch (std::exception const& _e)
|
||||||
{
|
{
|
||||||
if (_errors)
|
if (_errors)
|
||||||
{
|
{
|
||||||
_errors->push_back("Parse exception.");
|
_errors->emplace_back("Parse exception.");
|
||||||
_errors->push_back(boost::diagnostic_information(_e));
|
_errors->emplace_back(boost::diagnostic_information(_e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
if (_errors)
|
if (_errors)
|
||||||
_errors->push_back("Internal compiler exception.");
|
_errors->emplace_back("Internal compiler exception.");
|
||||||
}
|
}
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ void ContractLevelChecker::checkAbstractFunctions(ContractDefinition const& _con
|
|||||||
return _type->hasEqualParameterTypes(*_funAndFlag.first);
|
return _type->hasEqualParameterTypes(*_funAndFlag.first);
|
||||||
});
|
});
|
||||||
if (it == overloads.end())
|
if (it == overloads.end())
|
||||||
overloads.push_back(make_pair(_type, _implemented));
|
overloads.emplace_back(_type, _implemented);
|
||||||
else if (it->second)
|
else if (it->second)
|
||||||
{
|
{
|
||||||
if (!_implemented)
|
if (!_implemented)
|
||||||
@ -409,8 +409,8 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c
|
|||||||
auto functionType = make_shared<FunctionType>(*f);
|
auto functionType = make_shared<FunctionType>(*f);
|
||||||
// under non error circumstances this should be true
|
// under non error circumstances this should be true
|
||||||
if (functionType->interfaceFunctionType())
|
if (functionType->interfaceFunctionType())
|
||||||
externalDeclarations[functionType->externalSignature()].push_back(
|
externalDeclarations[functionType->externalSignature()].emplace_back(
|
||||||
make_pair(f, functionType->asCallableFunction(false))
|
f, functionType->asCallableFunction(false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (VariableDeclaration const* v: contract->stateVariables())
|
for (VariableDeclaration const* v: contract->stateVariables())
|
||||||
@ -419,8 +419,8 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c
|
|||||||
auto functionType = make_shared<FunctionType>(*v);
|
auto functionType = make_shared<FunctionType>(*v);
|
||||||
// under non error circumstances this should be true
|
// under non error circumstances this should be true
|
||||||
if (functionType->interfaceFunctionType())
|
if (functionType->interfaceFunctionType())
|
||||||
externalDeclarations[functionType->externalSignature()].push_back(
|
externalDeclarations[functionType->externalSignature()].emplace_back(
|
||||||
make_pair(v, functionType->asCallableFunction(false))
|
v, functionType->asCallableFunction(false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::inter
|
|||||||
{
|
{
|
||||||
signaturesSeen.insert(functionSignature);
|
signaturesSeen.insert(functionSignature);
|
||||||
FixedHash<4> hash(dev::keccak256(functionSignature));
|
FixedHash<4> hash(dev::keccak256(functionSignature));
|
||||||
m_interfaceFunctionList->push_back(make_pair(hash, fun));
|
m_interfaceFunctionList->emplace_back(hash, fun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ bool ASTJsonConverter::visit(ImportDirective const& _node)
|
|||||||
make_pair(m_legacy ? "SourceUnit" : "sourceUnit", nodeId(*_node.annotation().sourceUnit)),
|
make_pair(m_legacy ? "SourceUnit" : "sourceUnit", nodeId(*_node.annotation().sourceUnit)),
|
||||||
make_pair("scope", idOrNull(_node.scope()))
|
make_pair("scope", idOrNull(_node.scope()))
|
||||||
};
|
};
|
||||||
attributes.push_back(make_pair("unitAlias", _node.name()));
|
attributes.emplace_back("unitAlias", _node.name());
|
||||||
Json::Value symbolAliases(Json::arrayValue);
|
Json::Value symbolAliases(Json::arrayValue);
|
||||||
for (auto const& symbolAlias: _node.symbolAliases())
|
for (auto const& symbolAlias: _node.symbolAliases())
|
||||||
{
|
{
|
||||||
@ -244,7 +244,7 @@ bool ASTJsonConverter::visit(ImportDirective const& _node)
|
|||||||
tuple["local"] = symbolAlias.second ? Json::Value(*symbolAlias.second) : Json::nullValue;
|
tuple["local"] = symbolAlias.second ? Json::Value(*symbolAlias.second) : Json::nullValue;
|
||||||
symbolAliases.append(tuple);
|
symbolAliases.append(tuple);
|
||||||
}
|
}
|
||||||
attributes.push_back(make_pair("symbolAliases", std::move(symbolAliases)));
|
attributes.emplace_back("symbolAliases", std::move(symbolAliases));
|
||||||
setJsonNode(_node, "ImportDirective", std::move(attributes));
|
setJsonNode(_node, "ImportDirective", std::move(attributes));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ bool ASTJsonConverter::visit(VariableDeclaration const& _node)
|
|||||||
make_pair("typeDescriptions", typePointerToJson(_node.annotation().type, true))
|
make_pair("typeDescriptions", typePointerToJson(_node.annotation().type, true))
|
||||||
};
|
};
|
||||||
if (m_inEvent)
|
if (m_inEvent)
|
||||||
attributes.push_back(make_pair("indexed", _node.isIndexed()));
|
attributes.emplace_back("indexed", _node.isIndexed());
|
||||||
setJsonNode(_node, "VariableDeclaration", std::move(attributes));
|
setJsonNode(_node, "VariableDeclaration", std::move(attributes));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -647,11 +647,11 @@ bool ASTJsonConverter::visit(FunctionCall const& _node)
|
|||||||
};
|
};
|
||||||
if (m_legacy)
|
if (m_legacy)
|
||||||
{
|
{
|
||||||
attributes.push_back(make_pair("isStructConstructorCall", _node.annotation().kind == FunctionCallKind::StructConstructorCall));
|
attributes.emplace_back("isStructConstructorCall", _node.annotation().kind == FunctionCallKind::StructConstructorCall);
|
||||||
attributes.push_back(make_pair("type_conversion", _node.annotation().kind == FunctionCallKind::TypeConversion));
|
attributes.emplace_back("type_conversion", _node.annotation().kind == FunctionCallKind::TypeConversion);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
attributes.push_back(make_pair("kind", functionCallKind(_node.annotation().kind)));
|
attributes.emplace_back("kind", functionCallKind(_node.annotation().kind));
|
||||||
appendExpressionAttributes(attributes, _node.annotation());
|
appendExpressionAttributes(attributes, _node.annotation());
|
||||||
setJsonNode(_node, "FunctionCall", std::move(attributes));
|
setJsonNode(_node, "FunctionCall", std::move(attributes));
|
||||||
return false;
|
return false;
|
||||||
|
@ -462,7 +462,7 @@ MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition
|
|||||||
continue;
|
continue;
|
||||||
FunctionTypePointer fun = FunctionType(*function, false).asCallableFunction(true, true);
|
FunctionTypePointer fun = FunctionType(*function, false).asCallableFunction(true, true);
|
||||||
if (_type.isImplicitlyConvertibleTo(*fun->selfType()))
|
if (_type.isImplicitlyConvertibleTo(*fun->selfType()))
|
||||||
members.push_back(MemberList::Member(function->name(), fun, function));
|
members.emplace_back(function->name(), fun, function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
@ -1821,23 +1821,23 @@ MemberList::MemberMap ArrayType::nativeMembers(ContractDefinition const*) const
|
|||||||
MemberList::MemberMap members;
|
MemberList::MemberMap members;
|
||||||
if (!isString())
|
if (!isString())
|
||||||
{
|
{
|
||||||
members.push_back({"length", make_shared<IntegerType>(256)});
|
members.emplace_back("length", make_shared<IntegerType>(256));
|
||||||
if (isDynamicallySized() && location() == DataLocation::Storage)
|
if (isDynamicallySized() && location() == DataLocation::Storage)
|
||||||
{
|
{
|
||||||
members.push_back({"push", make_shared<FunctionType>(
|
members.emplace_back("push", make_shared<FunctionType>(
|
||||||
TypePointers{baseType()},
|
TypePointers{baseType()},
|
||||||
TypePointers{make_shared<IntegerType>(256)},
|
TypePointers{make_shared<IntegerType>(256)},
|
||||||
strings{string()},
|
strings{string()},
|
||||||
strings{string()},
|
strings{string()},
|
||||||
isByteArray() ? FunctionType::Kind::ByteArrayPush : FunctionType::Kind::ArrayPush
|
isByteArray() ? FunctionType::Kind::ByteArrayPush : FunctionType::Kind::ArrayPush
|
||||||
)});
|
));
|
||||||
members.push_back({"pop", make_shared<FunctionType>(
|
members.emplace_back("pop", make_shared<FunctionType>(
|
||||||
TypePointers{},
|
TypePointers{},
|
||||||
TypePointers{},
|
TypePointers{},
|
||||||
strings{string()},
|
strings{string()},
|
||||||
strings{string()},
|
strings{string()},
|
||||||
FunctionType::Kind::ArrayPop
|
FunctionType::Kind::ArrayPop
|
||||||
)});
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
@ -1966,21 +1966,17 @@ MemberList::MemberMap ContractType::nativeMembers(ContractDefinition const* _con
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!functionWithEqualArgumentsFound)
|
if (!functionWithEqualArgumentsFound)
|
||||||
members.push_back(MemberList::Member(
|
members.emplace_back(function->name(), functionType, function);
|
||||||
function->name(),
|
|
||||||
functionType,
|
|
||||||
function
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!m_contract.isLibrary())
|
else if (!m_contract.isLibrary())
|
||||||
{
|
{
|
||||||
for (auto const& it: m_contract.interfaceFunctions())
|
for (auto const& it: m_contract.interfaceFunctions())
|
||||||
members.push_back(MemberList::Member(
|
members.emplace_back(
|
||||||
it.second->declaration().name(),
|
it.second->declaration().name(),
|
||||||
it.second->asCallableFunction(m_contract.isLibrary()),
|
it.second->asCallableFunction(m_contract.isLibrary()),
|
||||||
&it.second->declaration()
|
&it.second->declaration()
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
@ -2008,7 +2004,7 @@ vector<tuple<VariableDeclaration const*, u256, unsigned>> ContractType::stateVar
|
|||||||
vector<tuple<VariableDeclaration const*, u256, unsigned>> variablesAndOffsets;
|
vector<tuple<VariableDeclaration const*, u256, unsigned>> variablesAndOffsets;
|
||||||
for (size_t index = 0; index < variables.size(); ++index)
|
for (size_t index = 0; index < variables.size(); ++index)
|
||||||
if (auto const* offset = offsets.offset(index))
|
if (auto const* offset = offsets.offset(index))
|
||||||
variablesAndOffsets.push_back(make_tuple(variables[index], offset->first, offset->second));
|
variablesAndOffsets.emplace_back(variables[index], offset->first, offset->second);
|
||||||
return variablesAndOffsets;
|
return variablesAndOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2098,10 +2094,10 @@ MemberList::MemberMap StructType::nativeMembers(ContractDefinition const*) const
|
|||||||
// Skip all mapping members if we are not in storage.
|
// Skip all mapping members if we are not in storage.
|
||||||
if (location() != DataLocation::Storage && !type->canLiveOutsideStorage())
|
if (location() != DataLocation::Storage && !type->canLiveOutsideStorage())
|
||||||
continue;
|
continue;
|
||||||
members.push_back(MemberList::Member(
|
members.emplace_back(
|
||||||
variable->name(),
|
variable->name(),
|
||||||
copyForLocationIfReference(type),
|
copyForLocationIfReference(type),
|
||||||
variable.get())
|
variable.get()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
@ -2438,7 +2434,7 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl):
|
|||||||
if (auto mappingType = dynamic_cast<MappingType const*>(returnType.get()))
|
if (auto mappingType = dynamic_cast<MappingType const*>(returnType.get()))
|
||||||
{
|
{
|
||||||
m_parameterTypes.push_back(mappingType->keyType());
|
m_parameterTypes.push_back(mappingType->keyType());
|
||||||
m_parameterNames.push_back("");
|
m_parameterNames.emplace_back("");
|
||||||
returnType = mappingType->valueType();
|
returnType = mappingType->valueType();
|
||||||
}
|
}
|
||||||
else if (auto arrayType = dynamic_cast<ArrayType const*>(returnType.get()))
|
else if (auto arrayType = dynamic_cast<ArrayType const*>(returnType.get()))
|
||||||
@ -2447,7 +2443,7 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl):
|
|||||||
// Return byte arrays as whole.
|
// Return byte arrays as whole.
|
||||||
break;
|
break;
|
||||||
returnType = arrayType->baseType();
|
returnType = arrayType->baseType();
|
||||||
m_parameterNames.push_back("");
|
m_parameterNames.emplace_back("");
|
||||||
m_parameterTypes.push_back(make_shared<IntegerType>(256));
|
m_parameterTypes.push_back(make_shared<IntegerType>(256));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2478,7 +2474,7 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl):
|
|||||||
DataLocation::Memory,
|
DataLocation::Memory,
|
||||||
returnType
|
returnType
|
||||||
));
|
));
|
||||||
m_returnParameterNames.push_back("");
|
m_returnParameterNames.emplace_back("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2847,14 +2843,11 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
|
|||||||
{
|
{
|
||||||
MemberList::MemberMap members;
|
MemberList::MemberMap members;
|
||||||
if (m_kind == Kind::External)
|
if (m_kind == Kind::External)
|
||||||
members.push_back(MemberList::Member(
|
members.emplace_back("selector", make_shared<FixedBytesType>(4));
|
||||||
"selector",
|
|
||||||
make_shared<FixedBytesType>(4)
|
|
||||||
));
|
|
||||||
if (m_kind != Kind::BareDelegateCall)
|
if (m_kind != Kind::BareDelegateCall)
|
||||||
{
|
{
|
||||||
if (isPayable())
|
if (isPayable())
|
||||||
members.push_back(MemberList::Member(
|
members.emplace_back(
|
||||||
"value",
|
"value",
|
||||||
make_shared<FunctionType>(
|
make_shared<FunctionType>(
|
||||||
parseElementaryTypeVector({"uint"}),
|
parseElementaryTypeVector({"uint"}),
|
||||||
@ -2868,10 +2861,10 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
|
|||||||
m_gasSet,
|
m_gasSet,
|
||||||
m_valueSet
|
m_valueSet
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
if (m_kind != Kind::Creation)
|
if (m_kind != Kind::Creation)
|
||||||
members.push_back(MemberList::Member(
|
members.emplace_back(
|
||||||
"gas",
|
"gas",
|
||||||
make_shared<FunctionType>(
|
make_shared<FunctionType>(
|
||||||
parseElementaryTypeVector({"uint"}),
|
parseElementaryTypeVector({"uint"}),
|
||||||
@ -2885,7 +2878,7 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
|
|||||||
m_gasSet,
|
m_gasSet,
|
||||||
m_valueSet
|
m_valueSet
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -3213,24 +3206,24 @@ MemberList::MemberMap TypeType::nativeMembers(ContractDefinition const* _current
|
|||||||
if (contract.isLibrary())
|
if (contract.isLibrary())
|
||||||
for (FunctionDefinition const* function: contract.definedFunctions())
|
for (FunctionDefinition const* function: contract.definedFunctions())
|
||||||
if (function->isVisibleAsLibraryMember())
|
if (function->isVisibleAsLibraryMember())
|
||||||
members.push_back(MemberList::Member(
|
members.emplace_back(
|
||||||
function->name(),
|
function->name(),
|
||||||
FunctionType(*function).asCallableFunction(true),
|
FunctionType(*function).asCallableFunction(true),
|
||||||
function
|
function
|
||||||
));
|
);
|
||||||
if (isBase)
|
if (isBase)
|
||||||
{
|
{
|
||||||
// We are accessing the type of a base contract, so add all public and protected
|
// We are accessing the type of a base contract, so add all public and protected
|
||||||
// members. Note that this does not add inherited functions on purpose.
|
// members. Note that this does not add inherited functions on purpose.
|
||||||
for (Declaration const* decl: contract.inheritableMembers())
|
for (Declaration const* decl: contract.inheritableMembers())
|
||||||
members.push_back(MemberList::Member(decl->name(), decl->type(), decl));
|
members.emplace_back(decl->name(), decl->type(), decl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (auto const& stru: contract.definedStructs())
|
for (auto const& stru: contract.definedStructs())
|
||||||
members.push_back(MemberList::Member(stru->name(), stru->type(), stru));
|
members.emplace_back(stru->name(), stru->type(), stru);
|
||||||
for (auto const& enu: contract.definedEnums())
|
for (auto const& enu: contract.definedEnums())
|
||||||
members.push_back(MemberList::Member(enu->name(), enu->type(), enu));
|
members.emplace_back(enu->name(), enu->type(), enu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_actualType->category() == Category::Enum)
|
else if (m_actualType->category() == Category::Enum)
|
||||||
@ -3238,7 +3231,7 @@ MemberList::MemberMap TypeType::nativeMembers(ContractDefinition const* _current
|
|||||||
EnumDefinition const& enumDef = dynamic_cast<EnumType const&>(*m_actualType).enumDefinition();
|
EnumDefinition const& enumDef = dynamic_cast<EnumType const&>(*m_actualType).enumDefinition();
|
||||||
auto enumType = make_shared<EnumType>(enumDef);
|
auto enumType = make_shared<EnumType>(enumDef);
|
||||||
for (ASTPointer<EnumValue> const& enumValue: enumDef.members())
|
for (ASTPointer<EnumValue> const& enumValue: enumDef.members())
|
||||||
members.push_back(MemberList::Member(enumValue->name(), enumType));
|
members.emplace_back(enumValue->name(), enumType);
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
@ -3303,7 +3296,7 @@ MemberList::MemberMap ModuleType::nativeMembers(ContractDefinition const*) const
|
|||||||
MemberList::MemberMap symbols;
|
MemberList::MemberMap symbols;
|
||||||
for (auto const& symbolName: m_sourceUnit.annotation().exportedSymbols)
|
for (auto const& symbolName: m_sourceUnit.annotation().exportedSymbols)
|
||||||
for (Declaration const* symbol: symbolName.second)
|
for (Declaration const* symbol: symbolName.second)
|
||||||
symbols.push_back(MemberList::Member(symbolName.first, symbol->type(), symbol));
|
symbols.emplace_back(symbolName.first, symbol->type(), symbol);
|
||||||
return symbols;
|
return symbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +141,8 @@ string ABIFunctions::tupleDecoder(TypePointers const& _types, bool _fromMemory)
|
|||||||
vector<string> valueNamesLocal;
|
vector<string> valueNamesLocal;
|
||||||
for (size_t j = 0; j < sizeOnStack; j++)
|
for (size_t j = 0; j < sizeOnStack; j++)
|
||||||
{
|
{
|
||||||
valueNamesLocal.push_back("value" + to_string(stackPos));
|
valueNamesLocal.emplace_back("value" + to_string(stackPos));
|
||||||
valueReturnParams.push_back("value" + to_string(stackPos));
|
valueReturnParams.emplace_back("value" + to_string(stackPos));
|
||||||
stackPos++;
|
stackPos++;
|
||||||
}
|
}
|
||||||
bool dynamic = decodingTypes[i]->isDynamicallyEncoded();
|
bool dynamic = decodingTypes[i]->isDynamicallyEncoded();
|
||||||
|
@ -721,14 +721,14 @@ bool ContractCompiler::visit(WhileStatement const& _whileStatement)
|
|||||||
|
|
||||||
eth::AssemblyItem loopStart = m_context.newTag();
|
eth::AssemblyItem loopStart = m_context.newTag();
|
||||||
eth::AssemblyItem loopEnd = m_context.newTag();
|
eth::AssemblyItem loopEnd = m_context.newTag();
|
||||||
m_breakTags.push_back({loopEnd, m_context.stackHeight()});
|
m_breakTags.emplace_back(loopEnd, m_context.stackHeight());
|
||||||
|
|
||||||
m_context << loopStart;
|
m_context << loopStart;
|
||||||
|
|
||||||
if (_whileStatement.isDoWhile())
|
if (_whileStatement.isDoWhile())
|
||||||
{
|
{
|
||||||
eth::AssemblyItem condition = m_context.newTag();
|
eth::AssemblyItem condition = m_context.newTag();
|
||||||
m_continueTags.push_back({condition, m_context.stackHeight()});
|
m_continueTags.emplace_back(condition, m_context.stackHeight());
|
||||||
|
|
||||||
_whileStatement.body().accept(*this);
|
_whileStatement.body().accept(*this);
|
||||||
|
|
||||||
@ -739,7 +739,7 @@ bool ContractCompiler::visit(WhileStatement const& _whileStatement)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_continueTags.push_back({loopStart, m_context.stackHeight()});
|
m_continueTags.emplace_back(loopStart, m_context.stackHeight());
|
||||||
compileExpression(_whileStatement.condition());
|
compileExpression(_whileStatement.condition());
|
||||||
m_context << Instruction::ISZERO;
|
m_context << Instruction::ISZERO;
|
||||||
m_context.appendConditionalJumpTo(loopEnd);
|
m_context.appendConditionalJumpTo(loopEnd);
|
||||||
@ -770,8 +770,8 @@ bool ContractCompiler::visit(ForStatement const& _forStatement)
|
|||||||
if (_forStatement.initializationExpression())
|
if (_forStatement.initializationExpression())
|
||||||
_forStatement.initializationExpression()->accept(*this);
|
_forStatement.initializationExpression()->accept(*this);
|
||||||
|
|
||||||
m_breakTags.push_back({loopEnd, m_context.stackHeight()});
|
m_breakTags.emplace_back(loopEnd, m_context.stackHeight());
|
||||||
m_continueTags.push_back({loopNext, m_context.stackHeight()});
|
m_continueTags.emplace_back(loopNext, m_context.stackHeight());
|
||||||
m_context << loopStart;
|
m_context << loopStart;
|
||||||
|
|
||||||
// if there is no terminating condition in for, default is to always be true
|
// if there is no terminating condition in for, default is to always be true
|
||||||
@ -997,7 +997,7 @@ void ContractCompiler::appendModifierOrFunctionCode()
|
|||||||
|
|
||||||
if (codeBlock)
|
if (codeBlock)
|
||||||
{
|
{
|
||||||
m_returnTags.push_back({m_context.newTag(), m_context.stackHeight()});
|
m_returnTags.emplace_back(m_context.newTag(), m_context.stackHeight());
|
||||||
codeBlock->accept(*this);
|
codeBlock->accept(*this);
|
||||||
|
|
||||||
solAssert(!m_returnTags.empty(), "");
|
solAssert(!m_returnTags.empty(), "");
|
||||||
|
@ -170,7 +170,7 @@ ASTPointer<ImportDirective> Parser::parseImportDirective()
|
|||||||
expectToken(Token::As);
|
expectToken(Token::As);
|
||||||
alias = expectIdentifierToken();
|
alias = expectIdentifierToken();
|
||||||
}
|
}
|
||||||
symbolAliases.push_back(make_pair(move(id), move(alias)));
|
symbolAliases.emplace_back(move(id), move(alias));
|
||||||
if (m_scanner->currentToken() != Token::Comma)
|
if (m_scanner->currentToken() != Token::Comma)
|
||||||
break;
|
break;
|
||||||
m_scanner->next();
|
m_scanner->next();
|
||||||
@ -1690,7 +1690,7 @@ Parser::IndexAccessedPath Parser::parseIndexAccessedPath()
|
|||||||
index = parseExpression();
|
index = parseExpression();
|
||||||
SourceLocation indexLocation = iap.path.front()->location();
|
SourceLocation indexLocation = iap.path.front()->location();
|
||||||
indexLocation.end = endPosition();
|
indexLocation.end = endPosition();
|
||||||
iap.indices.push_back(make_pair(index, indexLocation));
|
iap.indices.emplace_back(index, indexLocation);
|
||||||
expectToken(Token::RBrack);
|
expectToken(Token::RBrack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user