blob: 88b208a9dcb29fb629115f7e967a5b1ef0ed4ed1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#ifndef PCC_TYPEIDENTIFIER_HH
#define PCC_TYPEIDENTIFIER_HH
#include <list>
#include "Context.hh"
#include "Type.hh"
#include "VariableList.hh"
namespace pcc {
// since TypeAlias returns std::shared_ptr<Type> instead of llvm::Value*, we
// won't use CodeGen() override.
class TypeIdentifier {
public:
TypeIdentifier(Context* context, std::shared_ptr<Type> type = nullptr);
virtual std::shared_ptr<Type> GetType() = 0;
protected:
Context* context_;
std::shared_ptr<Type> type_;
};
class TrivialTypeIdentifier : public TypeIdentifier {
public:
TrivialTypeIdentifier(Context* context, std::shared_ptr<Type> type);
virtual std::shared_ptr<Type> GetType() override;
};
class AliasTypeIdentifier : public TypeIdentifier {
public:
AliasTypeIdentifier(Context* context, std::string&& alias);
virtual std::shared_ptr<Type> GetType() override;
protected:
std::string alias_;
};
// for pointers and arrays, so that we can create pointers to other alias type
class PointerTypeIdentifier : public TypeIdentifier {
public:
PointerTypeIdentifier(Context* context,
std::shared_ptr<TypeIdentifier> ElementType);
virtual std::shared_ptr<Type> GetType() override;
protected:
std::shared_ptr<TypeIdentifier> ElementType_;
};
class ArrayTypeIdentifier : public TypeIdentifier {
public:
ArrayTypeIdentifier(Context* context,
std::shared_ptr<TypeIdentifier> ElementType,
std::shared_ptr<ExprNode> start,
std::shared_ptr<ExprNode> end);
virtual std::shared_ptr<Type> GetType() override;
protected:
std::shared_ptr<TypeIdentifier> ElementType_;
std::shared_ptr<ExprNode> start_;
std::shared_ptr<ExprNode> end_;
};
class RecordTypeIdentifier : public TypeIdentifier {
public:
RecordTypeIdentifier(Context* context, std::list<Declaration>&& members);
virtual std::shared_ptr<Type> GetType() override;
protected:
std::list<Declaration> members_;
};
} // namespace pcc
#endif // !PCC_TYPEIDENTIFIER_HH
|