]>
Commit | Line | Data |
---|---|---|
b4c522fa IB |
1 | |
2 | /* Compiler implementation of the D programming language | |
f3ed896c | 3 | * Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved |
b4c522fa IB |
4 | * written by Walter Bright |
5 | * http://www.digitalmars.com | |
6 | * Distributed under the Boost Software License, Version 1.0. | |
7 | * http://www.boost.org/LICENSE_1_0.txt | |
8 | * https://github.com/dlang/dmd/blob/master/src/dmd/attrib.h | |
9 | */ | |
10 | ||
11 | #pragma once | |
12 | ||
13 | #include "dsymbol.h" | |
14 | ||
15 | class Expression; | |
16 | class Statement; | |
17 | class LabelDsymbol; | |
18 | class Initializer; | |
19 | class Module; | |
20 | class Condition; | |
21 | class StaticForeach; | |
22 | ||
23 | /**************************************************************/ | |
24 | ||
25 | class AttribDeclaration : public Dsymbol | |
26 | { | |
27 | public: | |
28 | Dsymbols *decl; // array of Dsymbol's | |
29 | ||
30 | AttribDeclaration(Dsymbols *decl); | |
31 | virtual Dsymbols *include(Scope *sc, ScopeDsymbol *sds); | |
32 | int apply(Dsymbol_apply_ft_t fp, void *param); | |
33 | static Scope *createNewScope(Scope *sc, | |
34 | StorageClass newstc, LINK linkage, CPPMANGLE cppmangle, Prot protection, | |
35 | int explicitProtection, AlignDeclaration *aligndecl, PINLINE inlining); | |
36 | virtual Scope *newScope(Scope *sc); | |
37 | void addMember(Scope *sc, ScopeDsymbol *sds); | |
38 | void setScope(Scope *sc); | |
39 | void importAll(Scope *sc); | |
40 | void semantic(Scope *sc); | |
41 | void semantic2(Scope *sc); | |
42 | void semantic3(Scope *sc); | |
43 | void addComment(const utf8_t *comment); | |
44 | const char *kind() const; | |
45 | bool oneMember(Dsymbol **ps, Identifier *ident); | |
46 | void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool isunion); | |
47 | bool hasPointers(); | |
48 | bool hasStaticCtorOrDtor(); | |
49 | void checkCtorConstInit(); | |
50 | void addLocalClass(ClassDeclarations *); | |
51 | AttribDeclaration *isAttribDeclaration() { return this; } | |
52 | ||
53 | void accept(Visitor *v) { v->visit(this); } | |
54 | }; | |
55 | ||
56 | class StorageClassDeclaration : public AttribDeclaration | |
57 | { | |
58 | public: | |
59 | StorageClass stc; | |
60 | ||
61 | StorageClassDeclaration(StorageClass stc, Dsymbols *decl); | |
62 | Dsymbol *syntaxCopy(Dsymbol *s); | |
63 | Scope *newScope(Scope *sc); | |
64 | bool oneMember(Dsymbol **ps, Identifier *ident); | |
65 | void addMember(Scope *sc, ScopeDsymbol *sds); | |
66 | StorageClassDeclaration *isStorageClassDeclaration() { return this; } | |
67 | ||
68 | void accept(Visitor *v) { v->visit(this); } | |
69 | }; | |
70 | ||
71 | class DeprecatedDeclaration : public StorageClassDeclaration | |
72 | { | |
73 | public: | |
74 | Expression *msg; | |
75 | const char *msgstr; | |
76 | ||
77 | DeprecatedDeclaration(Expression *msg, Dsymbols *decl); | |
78 | Dsymbol *syntaxCopy(Dsymbol *s); | |
79 | Scope *newScope(Scope *sc); | |
80 | void setScope(Scope *sc); | |
81 | void semantic2(Scope *sc); | |
82 | const char *getMessage(); | |
83 | void accept(Visitor *v) { v->visit(this); } | |
84 | }; | |
85 | ||
86 | class LinkDeclaration : public AttribDeclaration | |
87 | { | |
88 | public: | |
89 | LINK linkage; | |
90 | ||
91 | LinkDeclaration(LINK p, Dsymbols *decl); | |
92 | static LinkDeclaration *create(LINK p, Dsymbols *decl); | |
93 | Dsymbol *syntaxCopy(Dsymbol *s); | |
94 | Scope *newScope(Scope *sc); | |
95 | const char *toChars(); | |
96 | void accept(Visitor *v) { v->visit(this); } | |
97 | }; | |
98 | ||
99 | class CPPMangleDeclaration : public AttribDeclaration | |
100 | { | |
101 | public: | |
102 | CPPMANGLE cppmangle; | |
103 | ||
104 | CPPMangleDeclaration(CPPMANGLE p, Dsymbols *decl); | |
105 | Dsymbol *syntaxCopy(Dsymbol *s); | |
106 | Scope *newScope(Scope *sc); | |
107 | const char *toChars(); | |
108 | void accept(Visitor *v) { v->visit(this); } | |
109 | }; | |
110 | ||
111 | class ProtDeclaration : public AttribDeclaration | |
112 | { | |
113 | public: | |
114 | Prot protection; | |
115 | Identifiers* pkg_identifiers; | |
116 | ||
117 | ProtDeclaration(Loc loc, Prot p, Dsymbols *decl); | |
118 | ProtDeclaration(Loc loc, Identifiers* pkg_identifiers, Dsymbols *decl); | |
119 | ||
120 | Dsymbol *syntaxCopy(Dsymbol *s); | |
121 | Scope *newScope(Scope *sc); | |
122 | void addMember(Scope *sc, ScopeDsymbol *sds); | |
123 | const char *kind() const; | |
124 | const char *toPrettyChars(bool unused); | |
125 | void accept(Visitor *v) { v->visit(this); } | |
126 | }; | |
127 | ||
128 | class AlignDeclaration : public AttribDeclaration | |
129 | { | |
130 | public: | |
131 | Expression *ealign; | |
132 | structalign_t salign; | |
133 | ||
134 | AlignDeclaration(Loc loc, Expression *ealign, Dsymbols *decl); | |
135 | Dsymbol *syntaxCopy(Dsymbol *s); | |
136 | Scope *newScope(Scope *sc); | |
137 | void semantic2(Scope *sc); | |
138 | structalign_t getAlignment(Scope *sc); | |
139 | void accept(Visitor *v) { v->visit(this); } | |
140 | }; | |
141 | ||
142 | class AnonDeclaration : public AttribDeclaration | |
143 | { | |
144 | public: | |
145 | bool isunion; | |
146 | int sem; // 1 if successful semantic() | |
147 | unsigned anonoffset; // offset of anonymous struct | |
148 | unsigned anonstructsize; // size of anonymous struct | |
149 | unsigned anonalignsize; // size of anonymous struct for alignment purposes | |
150 | ||
151 | AnonDeclaration(Loc loc, bool isunion, Dsymbols *decl); | |
152 | Dsymbol *syntaxCopy(Dsymbol *s); | |
153 | void setScope(Scope *sc); | |
154 | void semantic(Scope *sc); | |
155 | void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool isunion); | |
156 | const char *kind() const; | |
157 | AnonDeclaration *isAnonDeclaration() { return this; } | |
158 | void accept(Visitor *v) { v->visit(this); } | |
159 | }; | |
160 | ||
161 | class PragmaDeclaration : public AttribDeclaration | |
162 | { | |
163 | public: | |
164 | Expressions *args; // array of Expression's | |
165 | ||
166 | PragmaDeclaration(Loc loc, Identifier *ident, Expressions *args, Dsymbols *decl); | |
167 | Dsymbol *syntaxCopy(Dsymbol *s); | |
168 | Scope *newScope(Scope *sc); | |
169 | void semantic(Scope *sc); | |
170 | const char *kind() const; | |
171 | void accept(Visitor *v) { v->visit(this); } | |
172 | }; | |
173 | ||
174 | class ConditionalDeclaration : public AttribDeclaration | |
175 | { | |
176 | public: | |
177 | Condition *condition; | |
178 | Dsymbols *elsedecl; // array of Dsymbol's for else block | |
179 | ||
180 | ConditionalDeclaration(Condition *condition, Dsymbols *decl, Dsymbols *elsedecl); | |
181 | Dsymbol *syntaxCopy(Dsymbol *s); | |
182 | bool oneMember(Dsymbol **ps, Identifier *ident); | |
183 | Dsymbols *include(Scope *sc, ScopeDsymbol *sds); | |
184 | void addComment(const utf8_t *comment); | |
185 | void setScope(Scope *sc); | |
186 | void accept(Visitor *v) { v->visit(this); } | |
187 | }; | |
188 | ||
189 | class StaticIfDeclaration : public ConditionalDeclaration | |
190 | { | |
191 | public: | |
192 | ScopeDsymbol *scopesym; | |
193 | bool addisdone; | |
194 | ||
195 | StaticIfDeclaration(Condition *condition, Dsymbols *decl, Dsymbols *elsedecl); | |
196 | Dsymbol *syntaxCopy(Dsymbol *s); | |
197 | Dsymbols *include(Scope *sc, ScopeDsymbol *sds); | |
198 | void addMember(Scope *sc, ScopeDsymbol *sds); | |
199 | void setScope(Scope *sc); | |
200 | void importAll(Scope *sc); | |
201 | void semantic(Scope *sc); | |
202 | const char *kind() const; | |
203 | void accept(Visitor *v) { v->visit(this); } | |
204 | }; | |
205 | ||
206 | class StaticForeachDeclaration : public ConditionalDeclaration | |
207 | { | |
208 | public: | |
209 | StaticForeach *sfe; | |
210 | ScopeDsymbol *scopesym; | |
211 | bool cached; | |
212 | Dsymbols *cache; | |
213 | ||
214 | Dsymbol *syntaxCopy(Dsymbol *s); | |
f9ab59ff | 215 | bool oneMember(Dsymbol **ps, Identifier *ident); |
b4c522fa IB |
216 | Dsymbols *include(Scope *sc, ScopeDsymbol *sds); |
217 | void addMember(Scope *sc, ScopeDsymbol *sds); | |
f9ab59ff | 218 | void addComment(const utf8_t *comment); |
b4c522fa IB |
219 | void setScope(Scope *sc); |
220 | void importAll(Scope *sc); | |
221 | void semantic(Scope *sc); | |
222 | const char *kind() const; | |
223 | void accept(Visitor *v) { v->visit(this); } | |
224 | }; | |
225 | ||
226 | class ForwardingAttribDeclaration : AttribDeclaration | |
227 | { | |
228 | public: | |
229 | ForwardingScopeDsymbol *sym; | |
230 | ||
231 | Scope *newScope(Scope *sc); | |
232 | void addMember(Scope *sc, ScopeDsymbol *sds); | |
233 | ForwardingAttribDeclaration *isForwardingAttribDeclaration() { return this; } | |
234 | }; | |
235 | ||
236 | // Mixin declarations | |
237 | ||
238 | class CompileDeclaration : public AttribDeclaration | |
239 | { | |
240 | public: | |
241 | Expression *exp; | |
242 | ||
243 | ScopeDsymbol *scopesym; | |
244 | bool compiled; | |
245 | ||
246 | CompileDeclaration(Loc loc, Expression *exp); | |
247 | Dsymbol *syntaxCopy(Dsymbol *s); | |
248 | void addMember(Scope *sc, ScopeDsymbol *sds); | |
249 | void setScope(Scope *sc); | |
250 | void compileIt(Scope *sc); | |
251 | void semantic(Scope *sc); | |
252 | const char *kind() const; | |
253 | void accept(Visitor *v) { v->visit(this); } | |
254 | }; | |
255 | ||
256 | /** | |
257 | * User defined attributes look like: | |
258 | * @(args, ...) | |
259 | */ | |
260 | class UserAttributeDeclaration : public AttribDeclaration | |
261 | { | |
262 | public: | |
263 | Expressions *atts; | |
264 | ||
265 | UserAttributeDeclaration(Expressions *atts, Dsymbols *decl); | |
266 | Dsymbol *syntaxCopy(Dsymbol *s); | |
267 | Scope *newScope(Scope *sc); | |
268 | void setScope(Scope *sc); | |
269 | void semantic(Scope *sc); | |
270 | void semantic2(Scope *sc); | |
271 | static Expressions *concat(Expressions *udas1, Expressions *udas2); | |
272 | Expressions *getAttributes(); | |
273 | const char *kind() const; | |
274 | void accept(Visitor *v) { v->visit(this); } | |
275 | }; |