2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
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
23 /**************************************************************/
25 class AttribDeclaration
: public Dsymbol
28 Dsymbols
*decl
; // array of Dsymbol's
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
);
48 bool hasStaticCtorOrDtor();
49 void checkCtorConstInit();
50 void addLocalClass(ClassDeclarations
*);
51 AttribDeclaration
*isAttribDeclaration() { return this; }
53 void accept(Visitor
*v
) { v
->visit(this); }
56 class StorageClassDeclaration
: public AttribDeclaration
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; }
68 void accept(Visitor
*v
) { v
->visit(this); }
71 class DeprecatedDeclaration
: public StorageClassDeclaration
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); }
86 class LinkDeclaration
: public AttribDeclaration
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); }
99 class CPPMangleDeclaration
: public AttribDeclaration
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); }
111 class ProtDeclaration
: public AttribDeclaration
115 Identifiers
* pkg_identifiers
;
117 ProtDeclaration(Loc loc
, Prot p
, Dsymbols
*decl
);
118 ProtDeclaration(Loc loc
, Identifiers
* pkg_identifiers
, Dsymbols
*decl
);
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); }
128 class AlignDeclaration
: public AttribDeclaration
132 structalign_t salign
;
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); }
142 class AnonDeclaration
: public AttribDeclaration
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
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); }
161 class PragmaDeclaration
: public AttribDeclaration
164 Expressions
*args
; // array of Expression's
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); }
174 class ConditionalDeclaration
: public AttribDeclaration
177 Condition
*condition
;
178 Dsymbols
*elsedecl
; // array of Dsymbol's for else block
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); }
189 class StaticIfDeclaration
: public ConditionalDeclaration
192 ScopeDsymbol
*scopesym
;
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); }
206 class StaticForeachDeclaration
: public ConditionalDeclaration
210 ScopeDsymbol
*scopesym
;
214 Dsymbol
*syntaxCopy(Dsymbol
*s
);
215 bool oneMember(Dsymbol
**ps
, Identifier
*ident
);
216 Dsymbols
*include(Scope
*sc
, ScopeDsymbol
*sds
);
217 void addMember(Scope
*sc
, ScopeDsymbol
*sds
);
218 void addComment(const utf8_t
*comment
);
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); }
226 class ForwardingAttribDeclaration
: AttribDeclaration
229 ForwardingScopeDsymbol
*sym
;
231 Scope
*newScope(Scope
*sc
);
232 void addMember(Scope
*sc
, ScopeDsymbol
*sds
);
233 ForwardingAttribDeclaration
*isForwardingAttribDeclaration() { return this; }
236 // Mixin declarations
238 class CompileDeclaration
: public AttribDeclaration
243 ScopeDsymbol
*scopesym
;
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); }
257 * User defined attributes look like:
260 class UserAttributeDeclaration
: public AttribDeclaration
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); }