systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
FindTemplateTypes.h
Go to the documentation of this file.
1#ifndef _FIND_TEMPLATE_TYPES_H_
2#define _FIND_TEMPLATE_TYPES_H_
3
4#include <string>
5#include <vector>
6#include <stack>
7
8#include "clang/AST/RecursiveASTVisitor.h"
9
10#include "Tree.h"
11
12#undef DEBUG_TYPE
13#define DEBUG_TYPE "Templates"
14
15namespace clang {
16class Type;
17}
18
19namespace systemc_clang {
20// using namespace clang;
21
22// Forward declarations
23//
24
25// This class holds the name of the type, and a pointer to the
26// type object.
28 public:
29 // Default constructor.
31
32 // Overloaded constructor
33 TemplateType(std::string, const clang::Type *);
34 virtual ~TemplateType();
36
37 std::string getTypeName() const;
38 std::string toString() const;
39
40 const clang::Type *getTypePtr() const;
41 void dump();
42
43 private:
44 std::string type_name_;
45 const clang::Type *type_ptr_;
46};
47
48// This class is going to find the arguments from templates
49class FindTemplateTypes : public clang::RecursiveASTVisitor<FindTemplateTypes> {
50 public:
53 typedef std::vector<TemplateTypePtr> type_vector_t;
54 typedef std::vector<TemplateTypePtr> argVectorType;
55
56 // typedef tree< TemplateType > template_arguments_type;
57 // Constructor
59
63
64 // This allows for template instantiations to be visited using RAV.
66
67 bool VisitEnumType(clang::EnumType *e);
68 bool VisitIntegerLiteral(clang::IntegerLiteral *l);
70 clang::TemplateSpecializationType *special_type);
71 bool VisitTypedefType(clang::TypedefType *typedef_type);
72 bool VisitCXXRecordDecl(clang::CXXRecordDecl *cxx_type);
73 bool VisitRecordType(clang::RecordType *rt);
74 bool VisitBuiltinType(clang::BuiltinType *bi_type);
75bool VisitDependentNameType(clang::DependentNameType *type);
76
77 bool VisitDeclRefExpr(clang::DeclRefExpr *dre);
78
79 virtual ~FindTemplateTypes();
80 void Enumerate(const clang::Type *type);
81 // type_vector_t getTemplateArgumentsType();
82 // std::vector<std::string> getTemplateArguments();
84 // size_t size();
85
86 void printTemplateArguments(llvm::raw_ostream &os);
87
89 std::string asString();
90
91 private:
92 // (std::string, Type*)
93 // Classes such as sc_port and sc_in can have nested types within it.
94 // For example: sc_in< sc_int<16> >
95 // The general way to handle this would be to have a vector starting from the
96 // outside type to the inside type.
97
98 // type_vector_t template_types_;
99
102 std::stack<Tree<TemplateType>::TreeNodePtr> stack_current_node_;
103};
104} // namespace systemc_clang
105#endif
bool VisitDeclRefExpr(clang::DeclRefExpr *dre)
bool VisitBuiltinType(clang::BuiltinType *bi_type)
Tree< TemplateType >::TreeNodePtr current_type_node_
bool VisitEnumType(clang::EnumType *e)
void printTemplateArguments(llvm::raw_ostream &os)
bool VisitIntegerLiteral(clang::IntegerLiteral *l)
std::stack< Tree< TemplateType >::TreeNodePtr > stack_current_node_
TemplateType TemplateTypePtr
Typedefs.
std::vector< TemplateTypePtr > argVectorType
Tree< TemplateType > * getTemplateArgTreePtr()
bool VisitTemplateSpecializationType(clang::TemplateSpecializationType *special_type)
std::vector< TemplateTypePtr > type_vector_t
bool VisitDependentNameType(clang::DependentNameType *type)
bool VisitTypedefType(clang::TypedefType *typedef_type)
bool VisitCXXRecordDecl(clang::CXXRecordDecl *cxx_type)
std::string asString()
Returns the TemplateType data as a std::string.
bool VisitRecordType(clang::RecordType *rt)
void Enumerate(const clang::Type *type)
TemplateType(std::string, const clang::Type *)
const clang::Type * getTypePtr() const
const clang::Type * type_ptr_
class TreeNode<T>
Definition Tree.h:18
Clang forward declarations.
Definition FindArgument.h:6