diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2014-04-14 04:28:44 -0500 |
---|---|---|
committer | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2014-04-14 04:29:25 -0500 |
commit | b71bbbbc607b5ca0c2bec8b8cf6c7af596d21997 (patch) | |
tree | dde394456e2f9a60fc2335ce52c1bda80e326005 /src/util | |
parent | d8e31379256a8fc0c6d7993e42fc94a9dc35f4ce (diff) |
Add initial support for co-datatypes.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/datatype.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/util/datatype.h b/src/util/datatype.h index 02e0b6be8..a8f3b404a 100644 --- a/src/util/datatype.h +++ b/src/util/datatype.h @@ -448,6 +448,7 @@ public: private: std::string d_name; std::vector<Type> d_params; + bool d_isCo; std::vector<DatatypeConstructor> d_constructors; bool d_resolved; Type d_self; @@ -494,13 +495,13 @@ private: public: /** Create a new Datatype of the given name. */ - inline explicit Datatype(std::string name); + inline explicit Datatype(std::string name, bool isCo = false); /** * Create a new Datatype of the given name, with the given * parameterization. */ - inline Datatype(std::string name, const std::vector<Type>& params); + inline Datatype(std::string name, const std::vector<Type>& params, bool isCo = false); /** * Add a constructor to this Datatype. Constructor names need not @@ -526,6 +527,9 @@ public: /** Get parameters */ inline std::vector<Type> getParameters() const; + /** is this a co-datatype? */ + inline bool isCodatatype() const; + /** * Return the cardinality of this datatype (the sum of the * cardinalities of its constructors). The Datatype must be @@ -662,18 +666,20 @@ inline std::string DatatypeUnresolvedType::getName() const throw() { return d_name; } -inline Datatype::Datatype(std::string name) : +inline Datatype::Datatype(std::string name, bool isCo) : d_name(name), d_params(), + d_isCo(isCo), d_constructors(), d_resolved(false), d_self(), d_card(CardinalityUnknown()) { } -inline Datatype::Datatype(std::string name, const std::vector<Type>& params) : +inline Datatype::Datatype(std::string name, const std::vector<Type>& params, bool isCo) : d_name(name), d_params(params), + d_isCo(isCo), d_constructors(), d_resolved(false), d_self(), @@ -707,6 +713,10 @@ inline std::vector<Type> Datatype::getParameters() const { return d_params; } +inline bool Datatype::isCodatatype() const { + return d_isCo; +} + inline bool Datatype::operator!=(const Datatype& other) const throw() { return !(*this == other); } |