diff options
-rw-r--r-- | Compiler.cpp | 2 | ||||
-rw-r--r-- | InterfaceHandler.cpp | 6 | ||||
-rw-r--r-- | Types.cpp | 4 | ||||
-rw-r--r-- | Types.h | 7 |
4 files changed, 11 insertions, 8 deletions
diff --git a/Compiler.cpp b/Compiler.cpp index 79672ca1..1fa31ce7 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -164,7 +164,7 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract) m_context << callDataUnpackerEntryPoints.at(it.first); eth::AssemblyItem returnTag = m_context.pushNewTag(); appendCalldataUnpacker(functionType->getParameterTypes()); - m_context.appendJumpTo(m_context.getFunctionEntryLabel(*it.second->getDeclaration())); + m_context.appendJumpTo(m_context.getFunctionEntryLabel(it.second->getDeclaration())); m_context << returnTag; appendReturnValuePacker(functionType->getReturnParameterTypes()); } diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp index 4d3ec4d5..92cd5156 100644 --- a/InterfaceHandler.cpp +++ b/InterfaceHandler.cpp @@ -59,9 +59,7 @@ std::unique_ptr<std::string> InterfaceHandler::getABIInterface(ContractDefinitio } return params; }; - - solAssert(it.second->getDeclaration(), "All function interface types should contain a declaration"); - method["name"] = it.second->getDeclaration()->getName(); + method["name"] = it.second->getDeclaration().getName(); method["constant"] = it.second->isConstant(); method["inputs"] = populateParameters(it.second->getParameterNames(), it.second->getParameterTypeNames()); @@ -86,7 +84,7 @@ unique_ptr<string> InterfaceHandler::getABISolidityInterface(ContractDefinition r += (r.size() ? "," : "(") + _paramTypes[i] + " " + _paramNames[i]; return r.size() ? r + ")" : "()"; }; - ret += "function " + it.second->getDeclaration()->getName() + + ret += "function " + it.second->getDeclaration().getName() + populateParameters(it.second->getParameterNames(), it.second->getParameterTypeNames()) + (it.second->isConstant() ? "constant " : ""); if (it.second->getReturnParameterTypes().size()) @@ -499,7 +499,7 @@ MemberList const& ContractType::getMembers() const } else for (auto const& it: m_contract.getInterfaceFunctions()) - members[it.second->getDeclaration()->getName()] = it.second; + members[it.second->getDeclaration().getName()] = it.second; m_members.reset(new MemberList(members)); } return *m_members; @@ -522,7 +522,7 @@ u256 ContractType::getFunctionIdentifier(string const& _functionName) const { auto interfaceFunctions = m_contract.getInterfaceFunctions(); for (auto const& it: m_contract.getInterfaceFunctions()) - if (it.second->getDeclaration()->getName() == _functionName) + if (it.second->getDeclaration().getName() == _functionName) return FixedHash<4>::Arith(it.first); return Invalid256; @@ -390,7 +390,12 @@ public: /// If @a _name is not provided (empty string) then the @c m_declaration member of the /// function type is used std::string getCanonicalSignature(std::string const& _name = "") const; - Declaration const* getDeclaration() const { return m_declaration; } + Declaration const& getDeclaration() const + { + solAssert(m_declaration, "Requested declaration from a FunctionType that has none"); + return *m_declaration; + } + bool hasDeclaration() const { return !!m_declaration; } bool isConstant() const { return m_isConstant; } /// @return A shared pointer of an ASTString. /// Can contain a nullptr in which case indicates absence of documentation |