aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-01-23 23:37:06 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-01-29 04:46:16 +0800
commit5c7359aa09c46eb7fc27a70e328adde93d4844ab (patch)
treedf6c6146f6d3b417fdc7312faac11df2374487bc /Types.cpp
parent3cc04923015cc3f40ad285fba5ed71464bd9ff2a (diff)
downloaddexon-solidity-5c7359aa09c46eb7fc27a70e328adde93d4844ab.tar.gz
dexon-solidity-5c7359aa09c46eb7fc27a70e328adde93d4844ab.tar.zst
dexon-solidity-5c7359aa09c46eb7fc27a70e328adde93d4844ab.zip
State variable accessors code is now more organized
- FunctionDescription is the abstraction of what should describe a function. It can either be a VariableDeclaration of a FunctionDefinition. - ParamDescription is what FunctionDescription uses to describe its parameters for outside use purposes with a pair of (name, type) strings - Modified code around Solidity and especially interface handler to adapt to this change
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/Types.cpp b/Types.cpp
index d5b00163..c5f1a3ae 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -489,7 +489,7 @@ MemberList const& ContractType::getMembers() const
map<string, shared_ptr<Type const>> members(IntegerType::AddressMemberList.begin(),
IntegerType::AddressMemberList.end());
for (auto const& it: m_contract.getInterfaceFunctions())
- members[it.second.second->getName()] = make_shared<FunctionType>(*it.second.second, false);
+ members[it.second.getName()] = it.second.getFunctionTypeShared();
m_members.reset(new MemberList(members));
}
return *m_members;
@@ -511,9 +511,9 @@ shared_ptr<FunctionType const> const& ContractType::getConstructorType() const
u256 ContractType::getFunctionIdentifier(string const& _functionName) const
{
auto interfaceFunctions = m_contract.getInterfaceFunctions();
- for (auto it = interfaceFunctions.cbegin(); it != interfaceFunctions.cend(); ++it)
- if (it->second.second->getName() == _functionName)
- return FixedHash<4>::Arith(it->first);
+ for (auto const& it: m_contract.getInterfaceFunctions())
+ if (it.second.getName() == _functionName)
+ return FixedHash<4>::Arith(it.first);
return Invalid256;
}
@@ -582,28 +582,47 @@ FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal
m_location(_isInternal ? Location::INTERNAL : Location::EXTERNAL)
{
TypePointers params;
+ vector<string> paramNames;
TypePointers retParams;
+ vector<string> retParamNames;
params.reserve(_function.getParameters().size());
+ paramNames.reserve(_function.getParameters().size());
for (ASTPointer<VariableDeclaration> const& var: _function.getParameters())
+ {
+ paramNames.push_back(var->getName());
params.push_back(var->getType());
+ }
retParams.reserve(_function.getReturnParameters().size());
+ retParamNames.reserve(_function.getReturnParameters().size());
for (ASTPointer<VariableDeclaration> const& var: _function.getReturnParameters())
+ {
+ retParamNames.push_back(var->getName());
retParams.push_back(var->getType());
+ }
swap(params, m_parameterTypes);
+ swap(paramNames, m_parameterNames);
swap(retParams, m_returnParameterTypes);
+ swap(retParamNames, m_returnParameterNames);
}
FunctionType::FunctionType(VariableDeclaration const& _varDecl):
m_location(Location::INTERNAL)
{
TypePointers params;
+ vector<string> paramNames;
TypePointers retParams;
+ vector<string> retParamNames;
// for now, no input parameters LTODO: change for some things like mapping
params.reserve(0);
+ paramNames.reserve(0);
retParams.reserve(1);
+ retParamNames.reserve(1);
retParams.push_back(_varDecl.getType());
+ retParamNames.push_back(_varDecl.getName());
swap(params, m_parameterTypes);
+ swap(paramNames, m_parameterNames);
swap(retParams, m_returnParameterTypes);
+ swap(retParamNames, m_returnParameterNames);
}
bool FunctionType::operator==(Type const& _other) const