Fixed semi-colon parsing in C-style for loops
[delight/core.git] / dmd2 / scope.h
blob975be26d379b637616085949f9e633d8e2a18955
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
66 unsigned callSuper; // primitive flow analysis for constructors
67 #define CSXthis_ctor 1 // called this()
68 #define CSXsuper_ctor 2 // called super()
69 #define CSXthis 4 // referenced this
70 #define CSXsuper 8 // referenced super
71 #define CSXlabel 0x10 // seen a label
72 #define CSXreturn 0x20 // seen a return statement
73 #define CSXany_ctor 0x40 // either this() or super() was called
75 unsigned structalign; // alignment for struct members
76 enum LINK linkage; // linkage for external functions
78 enum PROT protection; // protection for class members
79 int explicitProtection; // set if in an explicit protection attribute
81 unsigned stc; // storage class
82 Expressions * attributes; // GCC decl/type attributes
84 unsigned flags;
85 #define SCOPEctor 1 // constructor type
86 #define SCOPEstaticif 2 // inside static if
87 #define SCOPEfree 4 // is on free list
89 AnonymousAggregateDeclaration *anonAgg; // for temporary analysis
91 DocComment *lastdc; // documentation comment for last symbol at this scope
92 unsigned lastoffset; // offset in docbuf of where to insert next dec
93 OutBuffer *docbuf; // buffer for documentation output
95 static Scope *freelist;
96 static void *operator new(size_t sz);
97 static Scope *createGlobal(Module *module);
99 Scope();
100 Scope(Module *module);
101 Scope(Scope *enclosing);
103 Scope *push();
104 Scope *push(ScopeDsymbol *ss);
105 Scope *pop();
107 void mergeCallSuper(Loc loc, unsigned cs);
109 Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym);
110 Dsymbol *insert(Dsymbol *s);
112 ClassDeclaration *getClassScope();
113 AggregateDeclaration *getStructClassScope();
114 void setNoFree();
117 #endif /* DMD_SCOPE_H */