Mercurial > projects > ldc
annotate dmd/scope.h @ 1168:ab186e535e72
A different fix to #218 and DMD2682 that does not lead to constant folding regressions.
Fixes run/const_15, run/c/const_16_B.
The price is removing the lvalueness of struct literals. If it turns out too
much code depends on this behavior or we don't want to break with DMD, we
could keep struct literals as lvalues and instead convert struct literals used
as expression initializers into struct initializers.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 29 Mar 2009 11:43:45 +0200 |
parents | f99a3b393c03 |
children | e961851fb8be |
rev | line source |
---|---|
159 | 1 |
2 // Copyright (c) 1999-2005 by Digital Mars | |
3 // All Rights Reserved | |
4 // written by Walter Bright | |
5 // http://www.digitalmars.com | |
6 // License for redistribution is by either the Artistic License | |
7 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
8 // See the included readme.txt for details. | |
9 | |
10 #ifndef DMD_SCOPE_H | |
11 #define DMD_SCOPE_H | |
12 | |
13 #ifdef __DMC__ | |
14 #pragma once | |
15 #endif /* __DMC__ */ | |
16 | |
17 struct Dsymbol; | |
18 struct ScopeDsymbol; | |
19 struct Array; | |
20 struct Identifier; | |
21 struct Module; | |
22 struct Statement; | |
23 struct SwitchStatement; | |
24 struct TryFinallyStatement; | |
25 struct LabelStatement; | |
26 struct ForeachStatement; | |
27 struct ClassDeclaration; | |
28 struct AggregateDeclaration; | |
29 struct AnonymousAggregateDeclaration; | |
30 struct FuncDeclaration; | |
31 struct DocComment; | |
309 | 32 struct EnclosingHandler; |
737
041c1596d217
Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
561
diff
changeset
|
33 struct AnonDeclaration; |
159 | 34 enum LINK; |
35 enum PROT; | |
36 | |
37 struct Scope | |
38 { | |
39 Scope *enclosing; // enclosing Scope | |
40 | |
41 Module *module; // Root module | |
42 ScopeDsymbol *scopesym; // current symbol | |
43 ScopeDsymbol *sd; // if in static if, and declaring new symbols, | |
44 // sd gets the addMember() | |
45 FuncDeclaration *func; // function we are in | |
46 Dsymbol *parent; // parent to use | |
47 LabelStatement *slabel; // enclosing labelled statement | |
48 SwitchStatement *sw; // enclosing switch statement | |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
737
diff
changeset
|
49 TryFinallyStatement *enclosingFinally; // enclosing try finally statement; set inside its finally block |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
737
diff
changeset
|
50 Statement *enclosingScopeExit; // enclosing statement that wants to do something on scope exit |
561
d4e95db0e62b
Introducing template instantiation traces for static asserts and errors within templates.
Christian Kamm <kamm incasoftware de>
parents:
309
diff
changeset
|
51 TemplateInstance *tinst; // enclosing template instance |
159 | 52 Statement *sbreak; // enclosing statement that supports "break" |
53 Statement *scontinue; // enclosing statement that supports "continue" | |
54 ForeachStatement *fes; // if nested function for ForeachStatement, this is it | |
55 unsigned offset; // next offset to use in aggregate | |
56 int inunion; // we're processing members of a union | |
57 int incontract; // we're inside contract code | |
58 int nofree; // set if shouldn't free it | |
59 int noctor; // set if constructor calls aren't allowed | |
60 int intypeof; // in typeof(exp) | |
61 int parameterSpecialization; // if in template parameter specialization | |
62 int noaccesscheck; // don't do access checks | |
63 | |
64 unsigned callSuper; // primitive flow analysis for constructors | |
65 #define CSXthis_ctor 1 // called this() | |
66 #define CSXsuper_ctor 2 // called super() | |
67 #define CSXthis 4 // referenced this | |
68 #define CSXsuper 8 // referenced super | |
69 #define CSXlabel 0x10 // seen a label | |
70 #define CSXreturn 0x20 // seen a return statement | |
71 #define CSXany_ctor 0x40 // either this() or super() was called | |
72 | |
73 unsigned structalign; // alignment for struct members | |
74 enum LINK linkage; // linkage for external functions | |
75 | |
76 enum PROT protection; // protection for class members | |
77 int explicitProtection; // set if in an explicit protection attribute | |
78 | |
79 unsigned stc; // storage class | |
80 | |
81 unsigned flags; | |
82 #define SCOPEctor 1 // constructor type | |
83 #define SCOPEstaticif 2 // inside static if | |
84 #define SCOPEfree 4 // is on free list | |
85 | |
86 AnonymousAggregateDeclaration *anonAgg; // for temporary analysis | |
87 | |
88 DocComment *lastdc; // documentation comment for last symbol at this scope | |
89 unsigned lastoffset; // offset in docbuf of where to insert next dec | |
90 OutBuffer *docbuf; // buffer for documentation output | |
91 | |
92 static Scope *freelist; | |
93 static void *operator new(size_t sz); | |
94 static Scope *createGlobal(Module *module); | |
95 | |
96 Scope(); | |
97 Scope(Module *module); | |
98 Scope(Scope *enclosing); | |
99 | |
100 Scope *push(); | |
101 Scope *push(ScopeDsymbol *ss); | |
102 Scope *pop(); | |
103 | |
104 void mergeCallSuper(Loc loc, unsigned cs); | |
105 | |
106 Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym); | |
107 Dsymbol *insert(Dsymbol *s); | |
108 | |
109 ClassDeclaration *getClassScope(); | |
110 AggregateDeclaration *getStructClassScope(); | |
111 void setNoFree(); | |
112 }; | |
113 | |
114 #endif /* DMD_SCOPE_H */ |