Scan dynamic libraries for GC roots
[delight/core.git] / dmd2 / scope.h
blobc5417fe00d665a95d9af24d97853906f47992bb3
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.
10 /* NOTE: This file has been patched from the original DMD distribution to
11 work with the GDC compiler.
13 Modified by David Friedman, December 2006
16 #ifndef DMD_SCOPE_H
17 #define DMD_SCOPE_H
19 #ifdef __DMC__
20 #pragma once
21 #endif /* __DMC__ */
23 struct Dsymbol;
24 struct ScopeDsymbol;
25 struct Array;
26 struct Identifier;
27 struct Module;
28 struct Statement;
29 struct SwitchStatement;
30 struct TryFinallyStatement;
31 struct LabelStatement;
32 struct ForeachStatement;
33 struct ClassDeclaration;
34 struct AggregateDeclaration;
35 struct AnonymousAggregateDeclaration;
36 struct FuncDeclaration;
37 struct DocComment;
38 enum LINK;
39 enum PROT;
41 struct Scope
43 Scope *enclosing; // enclosing Scope
45 Module *module; // Root module
46 ScopeDsymbol *scopesym; // current symbol
47 ScopeDsymbol *sd; // if in static if, and declaring new symbols,
48 // sd gets the addMember()
49 FuncDeclaration *func; // function we are in
50 Dsymbol *parent; // parent to use
51 LabelStatement *slabel; // enclosing labelled statement
52 SwitchStatement *sw; // enclosing switch statement
53 TryFinallyStatement *tf; // enclosing try finally statement
54 Statement *sbreak; // enclosing statement that supports "break"
55 Statement *scontinue; // enclosing statement that supports "continue"
56 ForeachStatement *fes; // if nested function for ForeachStatement, this is it
57 target_size_t offset; // next offset to use in aggregate
58 int inunion; // we're processing members of a union
59 int incontract; // we're inside contract code
60 int nofree; // set if shouldn't free it
61 int noctor; // set if constructor calls aren't allowed
62 int intypeof; // in typeof(exp)
63 int parameterSpecialization; // if in template parameter specialization
64 int noaccesscheck; // don't do access checks
65 bool fromDcode; // use D type rules, not Delight ones
67 unsigned callSuper; // primitive flow analysis for constructors
68 #define CSXthis_ctor 1 // called this()
69 #define CSXsuper_ctor 2 // called super()
70 #define CSXthis 4 // referenced this
71 #define CSXsuper 8 // referenced super
72 #define CSXlabel 0x10 // seen a label
73 #define CSXreturn 0x20 // seen a return statement
74 #define CSXany_ctor 0x40 // either this() or super() was called
76 unsigned structalign; // alignment for struct members
77 enum LINK linkage; // linkage for external functions
79 enum PROT protection; // protection for class members
80 int explicitProtection; // set if in an explicit protection attribute
82 unsigned stc; // storage class
83 Expressions * attributes; // GCC decl/type attributes
85 unsigned flags;
86 #define SCOPEctor 1 // constructor type
87 #define SCOPEstaticif 2 // inside static if
88 #define SCOPEfree 4 // is on free list
90 AnonymousAggregateDeclaration *anonAgg; // for temporary analysis
92 DocComment *lastdc; // documentation comment for last symbol at this scope
93 unsigned lastoffset; // offset in docbuf of where to insert next dec
94 OutBuffer *docbuf; // buffer for documentation output
96 static Scope *freelist;
97 static void *operator new(size_t sz);
98 static Scope *createGlobal(Module *module);
100 Scope();
101 Scope(Module *module);
102 Scope(Scope *enclosing);
104 Scope *push();
105 Scope *push(ScopeDsymbol *ss);
106 Scope *pop();
108 void mergeCallSuper(Loc loc, unsigned cs);
110 Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym);
111 Dsymbol *insert(Dsymbol *s);
113 ClassDeclaration *getClassScope();
114 AggregateDeclaration *getStructClassScope();
115 void setNoFree();
118 #endif /* DMD_SCOPE_H */