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;
|
159
|
33 enum LINK;
|
|
34 enum PROT;
|
|
35
|
|
36 struct Scope
|
|
37 {
|
|
38 Scope *enclosing; // enclosing Scope
|
|
39
|
|
40 Module *module; // Root module
|
|
41 ScopeDsymbol *scopesym; // current symbol
|
|
42 ScopeDsymbol *sd; // if in static if, and declaring new symbols,
|
|
43 // sd gets the addMember()
|
|
44 FuncDeclaration *func; // function we are in
|
|
45 Dsymbol *parent; // parent to use
|
|
46 LabelStatement *slabel; // enclosing labelled statement
|
|
47 SwitchStatement *sw; // enclosing switch statement
|
|
48 TryFinallyStatement *tf; // enclosing try finally statement; set inside its finally block
|
309
|
49 EnclosingHandler *tfOfTry; // enclosing try-finally, volatile or synchronized statement; set inside its try or body block
|
159
|
50 Statement *sbreak; // enclosing statement that supports "break"
|
|
51 Statement *scontinue; // enclosing statement that supports "continue"
|
|
52 ForeachStatement *fes; // if nested function for ForeachStatement, this is it
|
|
53 unsigned offset; // next offset to use in aggregate
|
|
54 int inunion; // we're processing members of a union
|
|
55 int incontract; // we're inside contract code
|
|
56 int nofree; // set if shouldn't free it
|
|
57 int noctor; // set if constructor calls aren't allowed
|
|
58 int intypeof; // in typeof(exp)
|
|
59 int parameterSpecialization; // if in template parameter specialization
|
|
60 int noaccesscheck; // don't do access checks
|
|
61
|
|
62 unsigned callSuper; // primitive flow analysis for constructors
|
|
63 #define CSXthis_ctor 1 // called this()
|
|
64 #define CSXsuper_ctor 2 // called super()
|
|
65 #define CSXthis 4 // referenced this
|
|
66 #define CSXsuper 8 // referenced super
|
|
67 #define CSXlabel 0x10 // seen a label
|
|
68 #define CSXreturn 0x20 // seen a return statement
|
|
69 #define CSXany_ctor 0x40 // either this() or super() was called
|
|
70
|
|
71 unsigned structalign; // alignment for struct members
|
|
72 enum LINK linkage; // linkage for external functions
|
|
73
|
|
74 enum PROT protection; // protection for class members
|
|
75 int explicitProtection; // set if in an explicit protection attribute
|
|
76
|
|
77 unsigned stc; // storage class
|
|
78
|
|
79 unsigned flags;
|
|
80 #define SCOPEctor 1 // constructor type
|
|
81 #define SCOPEstaticif 2 // inside static if
|
|
82 #define SCOPEfree 4 // is on free list
|
|
83
|
|
84 AnonymousAggregateDeclaration *anonAgg; // for temporary analysis
|
|
85
|
|
86 DocComment *lastdc; // documentation comment for last symbol at this scope
|
|
87 unsigned lastoffset; // offset in docbuf of where to insert next dec
|
|
88 OutBuffer *docbuf; // buffer for documentation output
|
|
89
|
|
90 static Scope *freelist;
|
|
91 static void *operator new(size_t sz);
|
|
92 static Scope *createGlobal(Module *module);
|
|
93
|
|
94 Scope();
|
|
95 Scope(Module *module);
|
|
96 Scope(Scope *enclosing);
|
|
97
|
|
98 Scope *push();
|
|
99 Scope *push(ScopeDsymbol *ss);
|
|
100 Scope *pop();
|
|
101
|
|
102 void mergeCallSuper(Loc loc, unsigned cs);
|
|
103
|
|
104 Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym);
|
|
105 Dsymbol *insert(Dsymbol *s);
|
|
106
|
|
107 ClassDeclaration *getClassScope();
|
|
108 AggregateDeclaration *getStructClassScope();
|
|
109 void setNoFree();
|
|
110 };
|
|
111
|
|
112 #endif /* DMD_SCOPE_H */
|