tipc
A TIP to LLVM compiler
TypeConstraintVisitor.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ASTVisitor.h"
4 #include "ConstraintHandler.h"
5 #include "SymbolTable.h"
6 #include "TipType.h"
7 #include <memory>
8 #include <set>
9 #include <stack>
10 #include <string>
11 #include <vector>
12 
23 public:
25 
39  std::shared_ptr<ConstraintHandler> handler);
40 
41  bool visit(ASTFunction *element) override;
42  void endVisit(ASTAccessExpr *element) override;
43  void endVisit(ASTAllocExpr *element) override;
44  void endVisit(ASTAssignStmt *element) override;
45  void endVisit(ASTBinaryExpr *element) override;
46  void endVisit(ASTDeRefExpr *element) override;
47  void endVisit(ASTErrorStmt *element) override;
48  void endVisit(ASTFunAppExpr *element) override;
49  void endVisit(ASTFunction *element) override;
50  void endVisit(ASTIfStmt *element) override;
51  void endVisit(ASTInputExpr *element) override;
52  void endVisit(ASTNullExpr *element) override;
53  void endVisit(ASTNumberExpr *element) override;
54  void endVisit(ASTOutputStmt *element) override;
55  void endVisit(ASTRecordExpr *element) override;
56  void endVisit(ASTRefExpr *element) override;
57  void endVisit(ASTWhileStmt *element) override;
58 
59 protected:
60  std::shared_ptr<ConstraintHandler> constraintHandler;
62  std::shared_ptr<TipType> astToVar(ASTNode *n);
63 
64 private:
65  std::stack<ASTDeclNode *> scope;
66 };
Class for a record field access.
Definition: ASTAccessExpr.h:7
Class for alloc expression.
Definition: ASTAllocExpr.h:7
Class for assignment.
Definition: ASTAssignStmt.h:8
Class for a binary operator.
Definition: ASTBinaryExpr.h:7
Class for dereferencing a pointer expression.
Definition: ASTDeRefExpr.h:7
Class for a error statement.
Definition: ASTErrorStmt.h:8
Class for function call expressions.
Definition: ASTFunAppExpr.h:7
Class for defining the signature, local declarations, and a body of a function.
Definition: ASTFunction.h:11
Class for if-then-else.
Definition: ASTIfStmt.h:8
Class for input expression.
Definition: ASTInputExpr.h:7
Abstract base class for all AST nodes.
Definition: ASTNode.h:34
Class for a null expression.
Definition: ASTNullExpr.h:7
Class for numeric literals.
Definition: ASTNumberExpr.h:7
Class for an output statement.
Definition: ASTOutputStmt.h:8
Class for defining a record.
Definition: ASTRecordExpr.h:8
Class for referencing the address of an expression.
Definition: ASTRefExpr.h:7
Base class for AST visitors.
Definition: ASTVisitor.h:23
Class for a while loop.
Definition: ASTWhileStmt.h:8
Performs symbol analysis and records results for subsequent phases.
Definition: SymbolTable.h:17
Visitor generates type constraints and processes them.
Definition: TypeConstraintVisitor.h:22
std::shared_ptr< TipType > astToVar(ASTNode *n)
Definition: TypeConstraintVisitor.cpp:22
TypeConstraintVisitor()=delete
std::shared_ptr< ConstraintHandler > constraintHandler
Definition: TypeConstraintVisitor.h:60
SymbolTable * symbolTable
Definition: TypeConstraintVisitor.h:61
bool visit(ASTFunction *element) override
Definition: TypeConstraintVisitor.cpp:35
void endVisit(ASTAccessExpr *element) override
Type constraints for field access.
Definition: TypeConstraintVisitor.cpp:272