1 |
7
|
krennw
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
2
|
krennw
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
#pragma once
|
27 |
|
|
|
28 |
|
|
#include <cstdint>
|
29 |
|
|
#include <string>
|
30 |
|
|
|
31 |
|
|
#include <ast/AstElement.hpp>
|
32 |
|
|
#include <ast/IScope.hpp>
|
33 |
|
|
#include <base/TiresiasObject.hpp>
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
namespace Ast {
|
37 |
|
|
|
38 |
|
|
using namespace std;
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
enum class IdentifierKind : std::uint8_t
|
45 |
|
|
{
|
46 |
|
|
TypeIdentifier = 0,
|
47 |
|
|
EnumIdentifier = 1,
|
48 |
|
|
LandmarkIdentifier = 2,
|
49 |
|
|
AttributeIdentifier = 3,
|
50 |
|
|
LocalVariableIdentifier = 4,
|
51 |
|
|
ParameterIdentifier = 5,
|
52 |
|
|
ExpressionVariableIdentifier = 6,
|
53 |
|
|
MethodIdentifier = 7,
|
54 |
|
|
NamedActionIdentifier = 8,
|
55 |
|
|
Module = 9,
|
56 |
|
|
List_Normal = 10,
|
57 |
|
|
Constant = 11,
|
58 |
|
|
MainModule = 12,
|
59 |
|
|
List_Nondeterministic = 13,
|
60 |
|
|
List_Seqential = 14,
|
61 |
|
|
List_Prioritized = 15,
|
62 |
|
|
IDENTIFIERKIND_LAST_ITEM = List_Prioritized
|
63 |
|
|
};
|
64 |
|
|
|
65 |
|
|
#define IDENTIFIERKIND_NR_ITEMS ((std::uint8_t)IdentifierKind::IDENTIFIERKIND_LAST_ITEM + 1)
|
66 |
|
|
|
67 |
|
|
class Type;
|
68 |
|
|
|
69 |
|
|
class Identifier
|
70 |
|
|
: public AstElement
|
71 |
|
|
{
|
72 |
|
|
protected:
|
73 |
|
|
typedef Identifier* (*ConstrPtr)();
|
74 |
|
|
typedef Identifier* (*CopyConstrPtr)(const Identifier& toCopy);
|
75 |
|
|
|
76 |
|
|
IdentifierKind m_identifierKind;
|
77 |
|
|
int32_t m_line;
|
78 |
|
|
int32_t m_column;
|
79 |
|
|
IScope* m_definingScope;
|
80 |
|
|
Type* m_type;
|
81 |
|
|
string m_tokenText;
|
82 |
|
|
|
83 |
|
|
static Base::FuncPtr s_idVmt [2][IDENTIFIERKIND_NR_ITEMS];
|
84 |
|
|
static Identifier* createVirtual(IdentifierKind aType);
|
85 |
|
|
static Identifier* createVirtual(const Identifier& toCopy);
|
86 |
|
|
public:
|
87 |
|
|
friend class Ast;
|
88 |
|
|
Identifier(IdentifierKind identifierKind);
|
89 |
|
|
Identifier(const Identifier& toCopy);
|
90 |
|
|
~Identifier() override;
|
91 |
|
|
|
92 |
|
|
IdentifierKind kind() const { return m_identifierKind; };
|
93 |
|
|
Type* type() const { return m_type; };
|
94 |
|
|
int32_t line() const { return m_line; };
|
95 |
|
|
int32_t column() const { return m_column; };
|
96 |
|
|
IScope* definingScope() const { return m_definingScope; };
|
97 |
|
|
string tokenText() const { return m_tokenText; };
|
98 |
|
|
string toString() const { return tokenText(); };
|
99 |
|
|
string fullyQualifiedName() const;
|
100 |
|
|
|
101 |
|
|
void setType(Type* aType) { m_type = aType; };
|
102 |
|
|
void setTokenText(string aText) { m_tokenText = aText; };
|
103 |
|
|
|
104 |
|
|
void init(std::int32_t line, std::int32_t col, const char* text,
|
105 |
|
|
IScope* scopeRef, Type* typeRef)
|
106 |
|
|
{
|
107 |
|
|
m_line = line;
|
108 |
|
|
m_column = col;
|
109 |
|
|
m_tokenText = text;
|
110 |
|
|
m_definingScope = scopeRef;
|
111 |
|
|
m_type = typeRef;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
void accept(IAstVisitor& visitor);
|
116 |
|
|
virtual Identifier* clone() const;
|
117 |
|
|
};
|
118 |
|
|
}
|
119 |
|
|
#include <ast/types/Type.hpp> |