comparison dmd/cond.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 2667e3a145be
comparison
equal deleted inserted replaced
0:a9e71648e74d 1:c53b6e3fe49a
1
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2006 by Digital Mars
4 // All Rights Reserved
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
10
11 #ifndef DMD_DEBCOND_H
12 #define DMD_DEBCOND_H
13
14 struct Expression;
15 struct Identifier;
16 struct OutBuffer;
17 struct Module;
18 struct Scope;
19 struct ScopeDsymbol;
20 #ifdef _DH
21 #include "lexer.h" // dmdhg
22 #endif
23 enum TOK;
24 #ifdef _DH
25 struct HdrGenState;
26 #endif
27
28 int findCondition(Array *ids, Identifier *ident);
29
30 struct Condition
31 {
32 Loc loc;
33 int inc; // 0: not computed yet
34 // 1: include
35 // 2: do not include
36
37 Condition(Loc loc);
38
39 virtual Condition *syntaxCopy() = 0;
40 virtual int include(Scope *sc, ScopeDsymbol *s) = 0;
41 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0;
42 };
43
44 struct DVCondition : Condition
45 {
46 unsigned level;
47 Identifier *ident;
48 Module *mod;
49
50 DVCondition(Module *mod, unsigned level, Identifier *ident);
51
52 Condition *syntaxCopy();
53 };
54
55 struct DebugCondition : DVCondition
56 {
57 static void setGlobalLevel(unsigned level);
58 static void addGlobalIdent(char *ident);
59 static void addPredefinedGlobalIdent(char *ident);
60
61 DebugCondition(Module *mod, unsigned level, Identifier *ident);
62
63 int include(Scope *sc, ScopeDsymbol *s);
64 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
65 };
66
67 struct VersionCondition : DVCondition
68 {
69 static void setGlobalLevel(unsigned level);
70 static void checkPredefined(Loc loc, char *ident);
71 static void addGlobalIdent(char *ident);
72 static void addPredefinedGlobalIdent(char *ident);
73
74 VersionCondition(Module *mod, unsigned level, Identifier *ident);
75
76 int include(Scope *sc, ScopeDsymbol *s);
77 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
78 };
79
80 struct StaticIfCondition : Condition
81 {
82 Expression *exp;
83
84 StaticIfCondition(Loc loc, Expression *exp);
85 Condition *syntaxCopy();
86 int include(Scope *sc, ScopeDsymbol *s);
87 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
88 };
89
90 struct IftypeCondition : Condition
91 {
92 /* iftype (targ id tok tspec)
93 */
94 Type *targ;
95 Identifier *id; // can be NULL
96 enum TOK tok; // ':' or '=='
97 Type *tspec; // can be NULL
98
99 IftypeCondition(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec);
100 Condition *syntaxCopy();
101 int include(Scope *sc, ScopeDsymbol *s);
102 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
103 };
104
105
106 #endif