diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-30 00:28:14 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-01-30 01:21:51 +0800 |
commit | 04190798eba7a2996b28aee6d74b1c636f575a02 (patch) | |
tree | 2a5fb37440bed96c96ecfcfda494fd1b436b3118 | |
parent | dcd47be6ca8b408b384dca9737625873ad279464 (diff) | |
download | dexon-solidity-04190798eba7a2996b28aee6d74b1c636f575a02.tar dexon-solidity-04190798eba7a2996b28aee6d74b1c636f575a02.tar.gz dexon-solidity-04190798eba7a2996b28aee6d74b1c636f575a02.tar.bz2 dexon-solidity-04190798eba7a2996b28aee6d74b1c636f575a02.tar.lz dexon-solidity-04190798eba7a2996b28aee6d74b1c636f575a02.tar.xz dexon-solidity-04190798eba7a2996b28aee6d74b1c636f575a02.tar.zst dexon-solidity-04190798eba7a2996b28aee6d74b1c636f575a02.zip |
Minor fixes plus a rebase merge fix
-rw-r--r-- | AST.cpp | 5 | ||||
-rwxr-xr-x | AST.h | 31 | ||||
-rw-r--r-- | Compiler.cpp | 2 | ||||
-rw-r--r-- | InterfaceHandler.cpp | 1 | ||||
-rw-r--r-- | Types.cpp | 7 |
5 files changed, 40 insertions, 6 deletions
@@ -83,7 +83,6 @@ map<FixedHash<4>, FunctionTypePointer> ContractDefinition::getInterfaceFunctions map<FixedHash<4>, FunctionTypePointer> exportedFunctions; for (auto const& it: exportedFunctionList) - // exportedFunctions.insert(make_pair(std::get<0>(it), FunctionDescription(std::get<1>(it), std::get<2>(it)))); exportedFunctions.insert(it); solAssert(exportedFunctionList.size() == exportedFunctions.size(), @@ -139,12 +138,12 @@ void ContractDefinition::checkIllegalOverrides() const } } -vector<pair<FixedHash<4>, shared_ptr<FunctionType const>>> const& ContractDefinition::getInterfaceFunctionList() const +vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::getInterfaceFunctionList() const { if (!m_interfaceFunctionList) { set<string> functionsSeen; - m_interfaceFunctionList.reset(new vector<pair<FixedHash<4>, shared_ptr<FunctionType const>>>()); + m_interfaceFunctionList.reset(new vector<pair<FixedHash<4>, FunctionTypePointer>>()); for (ContractDefinition const* contract: getLinearizedBaseContracts()) { for (ASTPointer<FunctionDefinition> const& f: contract->getDefinedFunctions()) @@ -157,6 +157,37 @@ private: }; /** + * Abstract class that is added to each AST node that can store local variables. + */ +class VariableScope +{ +public: + void addLocalVariable(VariableDeclaration const& _localVariable) { m_localVariables.push_back(&_localVariable); } + std::vector<VariableDeclaration const*> const& getLocalVariables() const { return m_localVariables; } + +private: + std::vector<VariableDeclaration const*> m_localVariables; +}; + +/** + * Abstract class that is added to each AST node that can receive documentation. + */ +class Documented +{ +public: + explicit Documented(ASTPointer<ASTString> const& _documentation): m_documentation(_documentation) {} + + /// @return A shared pointer of an ASTString. + /// Can contain a nullptr in which case indicates absence of documentation + ASTPointer<ASTString> const& getDocumentation() const { return m_documentation; } + +protected: + ASTPointer<ASTString> m_documentation; +}; + +/// @} + +/** * Definition of a contract. This is the only AST nodes where child nodes are not visited in * document order. It first visits all struct declarations, then all variable declarations and * finally all function declarations. diff --git a/Compiler.cpp b/Compiler.cpp index 33a71bca..79672ca1 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -160,7 +160,7 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract) for (auto const& it: interfaceFunctions) { - FunctionTypePointer functionType = it.second; + FunctionTypePointer const& functionType = it.second; m_context << callDataUnpackerEntryPoints.at(it.first); eth::AssemblyItem returnTag = m_context.pushNewTag(); appendCalldataUnpacker(functionType->getParameterTypes()); diff --git a/InterfaceHandler.cpp b/InterfaceHandler.cpp index dd569946..4d3ec4d5 100644 --- a/InterfaceHandler.cpp +++ b/InterfaceHandler.cpp @@ -60,6 +60,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["constant"] = it.second->isConstant(); method["inputs"] = populateParameters(it.second->getParameterNames(), @@ -591,7 +591,7 @@ u256 StructType::getStorageOffsetOfMember(string const& _name) const FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal): m_location(_isInternal ? Location::INTERNAL : Location::EXTERNAL), m_isConstant(_function.isDeclaredConst()), - m_declaration(&_function) + m_declaration(&_function) { TypePointers params; vector<string> paramNames; @@ -641,6 +641,9 @@ bool FunctionType::operator==(Type const& _other) const if (m_location != other.m_location) return false; + if (m_isConstant != other.isConstant()) + return false; + if (m_parameterTypes.size() != other.m_parameterTypes.size() || m_returnParameterTypes.size() != other.m_returnParameterTypes.size()) return false; @@ -763,7 +766,7 @@ vector<string> const FunctionType::getReturnParameterTypeNames() const ASTPointer<ASTString> FunctionType::getDocumentation() const { - auto function = dynamic_cast<FunctionDefinition const*>(m_declaration); + auto function = dynamic_cast<Documented const*>(m_declaration); if (function) return function->getDocumentation(); |