aboutsummaryrefslogtreecommitdiffstats
path: root/AST.h
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 /AST.h
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 'AST.h')
-rwxr-xr-xAST.h54
1 files changed, 47 insertions, 7 deletions
diff --git a/AST.h b/AST.h
index 695e504a..89daf80f 100755
--- a/AST.h
+++ b/AST.h
@@ -158,18 +158,58 @@ private:
/**
+* Generic Parameter description used by @see FunctionDescription to return
+* a descripton of its parameters.
+*/
+struct ParamDescription
+{
+ ParamDescription(std::string const& _name, std::string const& _type):
+ m_description(_name, _type){}
+
+ bool operator!=(ParamDescription const& _other) const;
+ std::ostream& operator<<(std::ostream& os) const;
+
+ std::string getName() const;
+ std::string getType() const;
+
+ std::pair<std::string, std::string> m_description;
+};
+
+
+/**
* Generic function description able to describe both normal functions and
* functions that should be made as accessors to state variables
*/
struct FunctionDescription
{
- FunctionDescription(FunctionType const *_type, Declaration const* _decl):
+ FunctionDescription(std::shared_ptr<FunctionType const> _type, Declaration const* _decl):
m_description(_type, _decl){}
- ASTPointer<ASTString> getDocumentation();
- std::string getSignature();
+ FunctionDescription():
+ m_description(nullptr, nullptr){}
- std::pair<FunctionType const*, Declaration const*> m_description;
+ /// @returns the natspec documentation of the function if existing. Accessor (for now) don't have natspec doc
+ ASTPointer<ASTString> getDocumentation() const;
+ /// @returns the canonical signature of the function
+ std::string getSignature() const;
+ /// @returns the name of the function, basically that of the declaration
+ std::string getName() const;
+ /// @returns whether the function is constant. IF it's an accessor this is always true
+ bool isConstant() const;
+ /// @returns the argument parameters of the function
+ std::vector<ParamDescription> const getParameters() const;
+ /// @returns the return parameters of the function
+ std::vector<ParamDescription> const getReturnParameters() const;
+ /// @returns the Declaration AST Node pointer
+ Declaration const* getDeclaration() const;
+ /// @returns a created shared pointer with the type of the function
+ std::shared_ptr<FunctionType> makeFunctionType() const;
+ /// @returns a pointer to the function type
+ FunctionType const* getFunctionType() const;
+ /// @returns a shared pointer to the function type
+ std::shared_ptr<FunctionType const> getFunctionTypeShared() const;
+
+ std::pair<std::shared_ptr<FunctionType const>, Declaration const*> m_description;
};
@@ -219,7 +259,7 @@ public:
/// @returns a map of canonical function signatures to FunctionDefinitions
/// as intended for use by the ABI.
- std::map<FixedHash<4>, std::pair<FunctionType const*, Declaration const*>> getInterfaceFunctions() const;
+ std::map<FixedHash<4>, FunctionDescription> getInterfaceFunctions() const;
/// List of all (direct and indirect) base contracts in order from derived to base, including
/// the contract itself. Available after name resolution
@@ -232,7 +272,7 @@ public:
private:
void checkIllegalOverrides() const;
- std::vector<std::tuple<FixedHash<4>, FunctionType const*, Declaration const*>> const& getInterfaceFunctionList() const;
+ std::vector<std::tuple<FixedHash<4>, std::shared_ptr<FunctionType const>, Declaration const*>> const& getInterfaceFunctionList() const;
std::vector<ASTPointer<InheritanceSpecifier>> m_baseContracts;
std::vector<ASTPointer<StructDefinition>> m_definedStructs;
@@ -242,7 +282,7 @@ private:
ASTPointer<ASTString> m_documentation;
std::vector<ContractDefinition const*> m_linearizedBaseContracts;
- mutable std::unique_ptr<std::vector<std::tuple<FixedHash<4>, FunctionType const*, Declaration const*>>> m_interfaceFunctionList;
+ mutable std::unique_ptr<std::vector<std::tuple<FixedHash<4>, std::shared_ptr<FunctionType const>, Declaration const*>>> m_interfaceFunctionList;
};
class InheritanceSpecifier: public ASTNode