souffle  2.0.2-371-g6315b36
Data Structures | Public Member Functions | Private Member Functions | Private Attributes | Friends
souffle::ast::analysis::AlgebraicDataType Class Reference

Aggregates types using sums and products. More...

#include <TypeSystem.h>

Inheritance diagram for souffle::ast::analysis::AlgebraicDataType:
Inheritance graph
Collaboration diagram for souffle::ast::analysis::AlgebraicDataType:
Collaboration graph

Data Structures

struct  Branch
 

Public Member Functions

const std::vector< Branch > & getBranches () const
 Return the branches as a sorted vector. More...
 
const std::vector< const Type * > & getBranchTypes (const std::string &constructor) const
 
void print (std::ostream &out) const override
 
void setBranches (std::vector< Branch > bs)
 
- Public Member Functions inherited from souffle::ast::analysis::Type
const QualifiedNamegetName () const
 
const TypeEnvironmentgetTypeEnvironment () const
 
bool operator!= (const Type &other) const
 
bool operator< (const Type &other) const
 
bool operator== (const Type &other) const
 
 Type (const Type &other)=delete
 
virtual ~Type ()=default
 

Private Member Functions

 AlgebraicDataType (const TypeEnvironment &env, QualifiedName name)
 

Private Attributes

std::vector< Branchbranches
 

Friends

class TypeEnvironment
 

Additional Inherited Members

- Protected Member Functions inherited from souffle::ast::analysis::Type
 Type (const TypeEnvironment &environment, QualifiedName name)
 
- Protected Attributes inherited from souffle::ast::analysis::Type
const TypeEnvironmentenvironment
 A reference to the type environment this type is associated to. More...
 
QualifiedName name
 

Detailed Description

Aggregates types using sums and products.

Invariant: branches are in stored in lexicographical order.

Definition at line 199 of file TypeSystem.h.

Constructor & Destructor Documentation

◆ AlgebraicDataType()

souffle::ast::analysis::AlgebraicDataType::AlgebraicDataType ( const TypeEnvironment env,
QualifiedName  name 
)
inlineprivate

Definition at line 236 of file TypeSystem.h.

243 {

Member Function Documentation

◆ getBranches()

const std::vector<Branch>& souffle::ast::analysis::AlgebraicDataType::getBranches ( ) const
inline

Return the branches as a sorted vector.

Definition at line 231 of file TypeSystem.h.

◆ getBranchTypes()

const std::vector<const Type*>& souffle::ast::analysis::AlgebraicDataType::getBranchTypes ( const std::string &  constructor) const
inline

Definition at line 222 of file TypeSystem.h.

225  {
226  return branches;
227  }
228 

◆ print()

void souffle::ast::analysis::AlgebraicDataType::print ( std::ostream &  out) const
inlineoverridevirtual

Reimplemented from souffle::ast::analysis::Type.

Definition at line 211 of file TypeSystem.h.

213  { return left.name < right.name; });
214  }

◆ setBranches()

void souffle::ast::analysis::AlgebraicDataType::setBranches ( std::vector< Branch bs)
inline

Definition at line 216 of file TypeSystem.h.

216  {
217  for (auto& branch : branches) {
218  if (branch.name == constructor) return branch.types;
219  }
220  // Branch doesn't exist.

References branches.

Friends And Related Function Documentation

◆ TypeEnvironment

friend class TypeEnvironment
friend

Definition at line 238 of file TypeSystem.h.

Field Documentation

◆ branches

std::vector<Branch> souffle::ast::analysis::AlgebraicDataType::branches
private

The documentation for this class was generated from the following file:
souffle::ast::analysis::AlgebraicDataType::branches
std::vector< Branch > branches
Definition: TypeSystem.h:240