diff options
author | Christian <c@ethdev.com> | 2015-02-07 02:57:08 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-02-07 03:04:02 +0800 |
commit | 724ee769005095a123704962cd56b97765278871 (patch) | |
tree | 0f4ac0b8778823e9ed4c53e75ecd60871f0a669b /Types.cpp | |
parent | 82edc1ca6d694ad022c6b0e251da70393dfeb38a (diff) | |
download | dexon-solidity-724ee769005095a123704962cd56b97765278871.tar.gz dexon-solidity-724ee769005095a123704962cd56b97765278871.tar.zst dexon-solidity-724ee769005095a123704962cd56b97765278871.zip |
Accessors for structs.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
@@ -643,22 +643,31 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl): { TypePointers params; vector<string> paramNames; - TypePointers retParams; - vector<string> retParamNames; - TypePointer varDeclType = _varDecl.getType(); - auto mappingType = dynamic_cast<MappingType const*>(varDeclType.get()); - auto returnType = varDeclType; + auto returnType = _varDecl.getType(); - while (mappingType != nullptr) + while (auto mappingType = dynamic_cast<MappingType const*>(returnType.get())) { params.push_back(mappingType->getKeyType()); paramNames.push_back(""); returnType = mappingType->getValueType(); - mappingType = dynamic_cast<MappingType const*>(mappingType->getValueType().get()); } - retParams.push_back(returnType); - retParamNames.push_back(""); + TypePointers retParams; + vector<string> retParamNames; + if (auto structType = dynamic_cast<StructType const*>(returnType.get())) + { + for (pair<string, TypePointer> const& member: structType->getMembers()) + if (member.second->canLiveOutsideStorage()) + { + retParamNames.push_back(member.first); + retParams.push_back(member.second); + } + } + else + { + retParams.push_back(returnType); + retParamNames.push_back(""); + } swap(params, m_parameterTypes); swap(paramNames, m_parameterNames); |