forked from ldc-developers/ldc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathirdsymbol.h
100 lines (85 loc) · 2.43 KB
/
irdsymbol.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//===-- ir/irdsymbol.h - Codegen state for D symbols ------------*- C++ -*-===//
//
// LDC – the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
//
// Represents the status of a D symbol on its way though the codegen process.
//
//===----------------------------------------------------------------------===//
#ifndef LDC_IR_IRDSYMBOL_H
#define LDC_IR_IRDSYMBOL_H
#include <vector>
struct IrModule;
struct IrFunction;
struct IrAggr;
struct IrGlobal;
struct IrLocal;
struct IrParameter;
struct IrField;
struct IrVar;
class Dsymbol;
class AggregateDeclaration;
class FuncDeclaration;
class VarDeclaration;
class Module;
namespace llvm {
class Value;
}
struct IrDsymbol {
enum Type {
NotSet,
ModuleType,
AggrType,
FuncType,
GlobalType,
LocalType,
ParamterType,
FieldType
};
enum State { Initial, Resolved, Declared, Initialized, Defined };
static std::vector<IrDsymbol *> list;
static void resetAll();
// overload all of these to make sure
// the static list is up to date
IrDsymbol();
IrDsymbol(const IrDsymbol &s);
~IrDsymbol();
void reset();
Type type() const { return m_type; }
State state() const { return m_state; }
bool isResolved() const { return m_state >= Resolved; }
bool isDeclared() const { return m_state >= Declared; }
bool isInitialized() const { return m_state >= Initialized; }
bool isDefined() const { return m_state >= Defined; }
void setResolved();
void setDeclared();
void setInitialized();
void setDefined();
private:
friend IrModule *getIrModule(Module *m);
friend IrAggr *getIrAggr(AggregateDeclaration *decl, bool create);
friend IrFunction *getIrFunc(FuncDeclaration *decl, bool create);
friend IrVar *getIrVar(VarDeclaration *decl);
friend IrGlobal *getIrGlobal(VarDeclaration *decl, bool create);
friend IrLocal *getIrLocal(VarDeclaration *decl, bool create);
friend IrParameter *getIrParameter(VarDeclaration *decl, bool create);
friend IrField *getIrField(VarDeclaration *decl, bool create);
union {
void *irData;
IrModule *irModule;
IrAggr *irAggr;
IrFunction *irFunc;
IrVar *irVar;
IrGlobal *irGlobal;
IrLocal *irLocal;
IrParameter *irParam;
IrField *irField;
};
Type m_type = Type::NotSet;
State m_state = State::Initial;
};
#endif