Browse Source

Define strings = vector<string>

cl-refactor
Christian 10 years ago
parent
commit
18f7839fd5
  1. 3
      libdevcore/Common.h
  2. 20
      libsolidity/GlobalContext.cpp
  3. 12
      libsolidity/Types.cpp
  4. 8
      libsolidity/Types.h

3
libdevcore/Common.h

@ -80,6 +80,9 @@ using StringMap = std::map<std::string, std::string>;
using u256Map = std::map<u256, u256>;
using HexMap = std::map<bytes, std::string>;
// String types.
using strings = std::vector<std::string>;
// Fixed-length string types.
using string32 = std::array<char, 32>;

20
libsolidity/GlobalContext.cpp

@ -38,25 +38,25 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{make_shared<
make_shared<MagicVariableDeclaration>("msg", make_shared<MagicType>(MagicType::Kind::MSG)),
make_shared<MagicVariableDeclaration>("tx", make_shared<MagicType>(MagicType::Kind::TX)),
make_shared<MagicVariableDeclaration>("suicide",
make_shared<FunctionType>(vector<string>{"address"}, vector<string>{}, FunctionType::Location::SUICIDE)),
make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Location::SUICIDE)),
make_shared<MagicVariableDeclaration>("sha3",
make_shared<FunctionType>(vector<string>{"hash"}, vector<string>{"hash"}, FunctionType::Location::SHA3)),
make_shared<FunctionType>(strings{"hash"}, strings{"hash"}, FunctionType::Location::SHA3)),
make_shared<MagicVariableDeclaration>("log0",
make_shared<FunctionType>(vector<string>{"hash"},vector<string>{}, FunctionType::Location::LOG0)),
make_shared<FunctionType>(strings{"hash"},strings{}, FunctionType::Location::LOG0)),
make_shared<MagicVariableDeclaration>("log1",
make_shared<FunctionType>(vector<string>{"hash", "hash"},vector<string>{}, FunctionType::Location::LOG1)),
make_shared<FunctionType>(strings{"hash", "hash"},strings{}, FunctionType::Location::LOG1)),
make_shared<MagicVariableDeclaration>("log2",
make_shared<FunctionType>(vector<string>{"hash", "hash", "hash"},vector<string>{}, FunctionType::Location::LOG2)),
make_shared<FunctionType>(strings{"hash", "hash", "hash"},strings{}, FunctionType::Location::LOG2)),
make_shared<MagicVariableDeclaration>("log3",
make_shared<FunctionType>(vector<string>{"hash", "hash", "hash", "hash"},vector<string>{}, FunctionType::Location::LOG3)),
make_shared<FunctionType>(strings{"hash", "hash", "hash", "hash"},strings{}, FunctionType::Location::LOG3)),
make_shared<MagicVariableDeclaration>("log4",
make_shared<FunctionType>(vector<string>{"hash", "hash", "hash", "hash", "hash"},vector<string>{}, FunctionType::Location::LOG4)),
make_shared<FunctionType>(strings{"hash", "hash", "hash", "hash", "hash"},strings{}, FunctionType::Location::LOG4)),
make_shared<MagicVariableDeclaration>("sha256",
make_shared<FunctionType>(vector<string>{"hash"}, vector<string>{"hash"}, FunctionType::Location::SHA256)),
make_shared<FunctionType>(strings{"hash"}, strings{"hash"}, FunctionType::Location::SHA256)),
make_shared<MagicVariableDeclaration>("ecrecover",
make_shared<FunctionType>(vector<string>{"hash", "hash8", "hash", "hash"}, vector<string>{"address"}, FunctionType::Location::ECRECOVER)),
make_shared<FunctionType>(strings{"hash", "hash8", "hash", "hash"}, strings{"address"}, FunctionType::Location::ECRECOVER)),
make_shared<MagicVariableDeclaration>("ripemd160",
make_shared<FunctionType>(vector<string>{"hash"}, vector<string>{"hash160"}, FunctionType::Location::RIPEMD160))})
make_shared<FunctionType>(strings{"hash"}, strings{"hash160"}, FunctionType::Location::RIPEMD160))})
{
}

12
libsolidity/Types.cpp

@ -205,11 +205,11 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe
const MemberList IntegerType::AddressMemberList =
MemberList({{"balance", make_shared<IntegerType >(256)},
{"callstring32", make_shared<FunctionType>(vector<string>{"string32"},
vector<string>{}, FunctionType::Location::BARE)},
{"callstring32string32", make_shared<FunctionType>(vector<string>{"string32", "string32"},
vector<string>{}, FunctionType::Location::BARE)},
{"send", make_shared<FunctionType>(vector<string>{"uint"}, vector<string>{}, FunctionType::Location::SEND)}});
{"callstring32", make_shared<FunctionType>(strings{"string32"}, strings{},
FunctionType::Location::BARE)},
{"callstring32string32", make_shared<FunctionType>(strings{"string32", "string32"},
strings{}, FunctionType::Location::BARE)},
{"send", make_shared<FunctionType>(strings{"uint"}, strings{}, FunctionType::Location::SEND)}});
shared_ptr<IntegerConstantType const> IntegerConstantType::fromLiteral(string const& _literal)
{
@ -619,7 +619,7 @@ string FunctionType::getCanonicalSignature() const
return ret + ")";
}
TypePointers FunctionType::parseElementaryTypeVector(vector<string> const& _types)
TypePointers FunctionType::parseElementaryTypeVector(strings const& _types)
{
TypePointers pointers;
pointers.reserve(_types.size());

8
libsolidity/Types.h

@ -352,10 +352,10 @@ public:
virtual Category getCategory() const override { return Category::FUNCTION; }
explicit FunctionType(FunctionDefinition const& _function, bool _isInternal = true);
FunctionType(std::vector<std::string> const& _parameterTypes,
std::vector<std::string> const& _returnParameterTypes,
FunctionType(strings const& _parameterTypes, strings const& _returnParameterTypes,
Location _location = Location::INTERNAL):
FunctionType(parseElementaryTypeVector(_parameterTypes), parseElementaryTypeVector(_returnParameterTypes), _location) {}
FunctionType(parseElementaryTypeVector(_parameterTypes), parseElementaryTypeVector(_returnParameterTypes),
_location) {}
FunctionType(TypePointers const& _parameterTypes, TypePointers const& _returnParameterTypes,
Location _location = Location::INTERNAL):
m_parameterTypes(_parameterTypes), m_returnParameterTypes(_returnParameterTypes),
@ -375,7 +375,7 @@ public:
std::string getCanonicalSignature() const;
private:
static TypePointers parseElementaryTypeVector(std::vector<std::string> const& _types);
static TypePointers parseElementaryTypeVector(strings const& _types);
TypePointers m_parameterTypes;
TypePointers m_returnParameterTypes;

Loading…
Cancel
Save