aboutsummaryrefslogtreecommitdiffstats
path: root/AST.h
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-10 01:08:56 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-14 06:16:14 +0800
commita295417f3476428c286f96433a42a96bfe29fee3 (patch)
treee5f9b374407dfcdc4f11943d91df69e4ec559b0a /AST.h
parent54ed8877aa673fd6765c1238bcef598331ae41ae (diff)
downloaddexon-solidity-a295417f3476428c286f96433a42a96bfe29fee3.tar.gz
dexon-solidity-a295417f3476428c286f96433a42a96bfe29fee3.tar.zst
dexon-solidity-a295417f3476428c286f96433a42a96bfe29fee3.zip
Parsing enums for Solidity - WIP
Diffstat (limited to 'AST.h')
-rw-r--r--AST.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/AST.h b/AST.h
index 4e79026e..d3a7853a 100644
--- a/AST.h
+++ b/AST.h
@@ -166,6 +166,18 @@ private:
};
/**
+ * Declaration of an Enum Value
+ */
+class EnumDeclaration : public Declaration
+{
+ EnumDeclaration(Location const& _location,
+ ASTPointer<ASTString> const& _name):
+ Declaration(_location, _name) {}
+
+ TypePointer getType(ContractDefinition const*) const;
+};
+
+/**
* Abstract class that is added to each AST node that can store local variables.
*/
class VariableScope
@@ -209,6 +221,7 @@ public:
ASTPointer<ASTString> const& _documentation,
std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts,
std::vector<ASTPointer<StructDefinition>> const& _definedStructs,
+ std::vector<ASTPointer<EnumDefinition>> const& _definedEnums,
std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables,
std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions,
std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers,
@@ -216,6 +229,7 @@ public:
Declaration(_location, _name), Documented(_documentation),
m_baseContracts(_baseContracts),
m_definedStructs(_definedStructs),
+ m_definedEnums(_definedEnums),
m_stateVariables(_stateVariables),
m_definedFunctions(_definedFunctions),
m_functionModifiers(_functionModifiers),
@@ -227,6 +241,7 @@ public:
std::vector<ASTPointer<InheritanceSpecifier>> const& getBaseContracts() const { return m_baseContracts; }
std::vector<ASTPointer<StructDefinition>> const& getDefinedStructs() const { return m_definedStructs; }
+ std::vector<ASTPointer<EnumDefinition>> const& getDefinedEnums() const { return m_definedEnums; }
std::vector<ASTPointer<VariableDeclaration>> const& getStateVariables() const { return m_stateVariables; }
std::vector<ASTPointer<ModifierDefinition>> const& getFunctionModifiers() const { return m_functionModifiers; }
std::vector<ASTPointer<FunctionDefinition>> const& getDefinedFunctions() const { return m_definedFunctions; }
@@ -260,6 +275,7 @@ private:
std::vector<ASTPointer<InheritanceSpecifier>> m_baseContracts;
std::vector<ASTPointer<StructDefinition>> m_definedStructs;
+ std::vector<ASTPointer<EnumDefinition>> m_definedEnums;
std::vector<ASTPointer<VariableDeclaration>> m_stateVariables;
std::vector<ASTPointer<FunctionDefinition>> m_definedFunctions;
std::vector<ASTPointer<ModifierDefinition>> m_functionModifiers;
@@ -315,6 +331,28 @@ private:
std::vector<ASTPointer<VariableDeclaration>> m_members;
};
+class EnumDefinition: public Declaration
+{
+public:
+ EnumDefinition(Location const& _location,
+ ASTPointer<ASTString> const& _name,
+ std::vector<ASTPointer<EnumDeclaration>> const& _members):
+ Declaration(_location, _name), m_members(_members) {}
+ virtual void accept(ASTVisitor& _visitor) override;
+ virtual void accept(ASTConstVisitor& _visitor) const override;
+
+ std::vector<ASTPointer<EnumDeclaration>> const& getMembers() const { return m_members; }
+
+ virtual TypePointer getType(ContractDefinition const*) const override;
+
+ /// Checks that the members do not include any duplicate names
+ void checkValidityOfMembers() const;
+
+private:
+
+ std::vector<ASTPointer<EnumDeclaration>> m_members;
+};
+
/**
* Parameter list, used as function parameter list and return list.
* None of the parameters is allowed to contain mappings (not even recursively