comparison dmd/scope.h @ 1:c53b6e3fe49a trunk

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