comparison dmd2/scope.h @ 758:f04dde6e882c

Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 11 Nov 2008 01:38:48 +0100
parents
children 356e65836fb5
comparison
equal deleted inserted replaced
757:2c730d530c98 758:f04dde6e882c
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 struct EnclosingHandler;
33 struct AnonDeclaration;
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
49 TryFinallyStatement *tf; // enclosing try finally statement; set inside its finally block
50 EnclosingHandler *tfOfTry; // enclosing try-finally, volatile or synchronized statement; set inside its try or body block
51 TemplateInstance *tinst; // enclosing template instance
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 */