tipc
A TIP to LLVM compiler
Public Member Functions | List of all members
ConstraintCollector Class Reference

A constraint handler to collect constraints. More...

#include <ConstraintCollector.h>

Inheritance diagram for ConstraintCollector:
Inheritance graph
[legend]
Collaboration diagram for ConstraintCollector:
Collaboration graph
[legend]

Public Member Functions

void handle (std::shared_ptr< TipType > t1, std::shared_ptr< TipType > t2) override
 
std::vector< TypeConstraint > & getCollectedConstraints ()
 
- Public Member Functions inherited from ConstraintHandler
virtual ~ConstraintHandler ()=default
 

Detailed Description

A constraint handler to collect constraints.

While you can always unify and assert type safety as constraints are generated, you can also collect up all of the constraints and then unify that collection later. This ConstraintHandler implementation can be used for simply collecting the constraints. There are at least two reasons one might prefer collecting and then unifying. First, is to verify that constraints are being generated properly in unit tests. Second, is for learning purposes. That is, this implementation might help one better understand the typechecking algorithm.

Member Function Documentation

◆ getCollectedConstraints()

std::vector< TypeConstraint > & ConstraintCollector::getCollectedConstraints ( )

◆ handle()

void ConstraintCollector::handle ( std::shared_ptr< TipType t1,
std::shared_ptr< TipType t2 
)
overridevirtual

Implements ConstraintHandler.


The documentation for this class was generated from the following files: