root/branches/dmdfe-2.0/cond.h

Revision 914, 2.6 kB (checked in by Gregor, 3 months ago)

MERGE: DMD 2.019

Line 
1 // Compiler implementation of the D programming language
2 // Copyright (c) 1999-2008 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_DEBCOND_H
11 #define DMD_DEBCOND_H
12
13 struct Expression;
14 struct Identifier;
15 struct OutBuffer;
16 struct Module;
17 struct Scope;
18 struct ScopeDsymbol;
19 #ifdef _DH
20 #include "lexer.h" // dmdhg
21 #endif
22 enum TOK;
23 #ifdef _DH
24 struct HdrGenState;
25 #endif
26
27 int findCondition(Array *ids, Identifier *ident);
28
29 struct Condition
30 {
31     Loc loc;
32     int inc;        // 0: not computed yet
33             // 1: include
34             // 2: do not include
35
36     Condition(Loc loc);
37
38     virtual Condition *syntaxCopy() = 0;
39     virtual int include(Scope *sc, ScopeDsymbol *s) = 0;
40     virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0;
41 };
42
43 struct DVCondition : Condition
44 {
45     unsigned level;
46     Identifier *ident;
47     Module *mod;
48
49     DVCondition(Module *mod, unsigned level, Identifier *ident);
50
51     Condition *syntaxCopy();
52 };
53
54 struct DebugCondition : DVCondition
55 {
56     static void setGlobalLevel(unsigned level);
57     static void addGlobalIdent(const char *ident);
58     static void addPredefinedGlobalIdent(const char *ident);
59
60     DebugCondition(Module *mod, unsigned level, Identifier *ident);
61
62     int include(Scope *sc, ScopeDsymbol *s);
63     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
64 };
65
66 struct VersionCondition : DVCondition
67 {
68     static void setGlobalLevel(unsigned level);
69     static void checkPredefined(Loc loc, const char *ident);
70     static void addGlobalIdent(const char *ident);
71     static void addPredefinedGlobalIdent(const char *ident);
72
73     VersionCondition(Module *mod, unsigned level, Identifier *ident);
74
75     int include(Scope *sc, ScopeDsymbol *s);
76     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
77 };
78
79 struct StaticIfCondition : Condition
80 {
81     Expression *exp;
82
83     StaticIfCondition(Loc loc, Expression *exp);
84     Condition *syntaxCopy();
85     int include(Scope *sc, ScopeDsymbol *s);
86     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
87 };
88
89 struct IftypeCondition : Condition
90 {
91     /* iftype (targ id tok tspec)
92      */
93     Type *targ;
94     Identifier *id; // can be NULL
95     enum TOK tok;   // ':' or '=='
96     Type *tspec;    // can be NULL
97
98     IftypeCondition(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec);
99     Condition *syntaxCopy();
100     int include(Scope *sc, ScopeDsymbol *s);
101     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
102 };
103
104
105 #endif
Note: See TracBrowser for help on using the browser.