]>
Commit | Line | Data |
---|---|---|
b4c522fa IB |
1 | |
2 | /* Compiler implementation of the D programming language | |
8e788ac6 | 3 | * Copyright (C) 1999-2020 by The D Language Foundation, All Rights Reserved |
b4c522fa IB |
4 | * written by Walter Bright |
5 | * http://www.digitalmars.com | |
6 | * Distributed under the Boost Software License, Version 1.0. | |
7 | * http://www.boost.org/LICENSE_1_0.txt | |
8 | * https://github.com/dlang/dmd/blob/master/src/dmd/cond.h | |
9 | */ | |
10 | ||
11 | #pragma once | |
12 | ||
98866120 | 13 | #include "ast_node.h" |
b4c522fa IB |
14 | #include "globals.h" |
15 | #include "visitor.h" | |
16 | ||
17 | class Expression; | |
18 | class Identifier; | |
19 | struct OutBuffer; | |
20 | class Module; | |
21 | struct Scope; | |
22 | class ScopeDsymbol; | |
23 | class DebugCondition; | |
24 | class ForeachStatement; | |
25 | class ForeachRangeStatement; | |
26 | ||
5bc13e52 | 27 | int findCondition(Identifiers *ids, Identifier *ident); |
b4c522fa | 28 | |
98866120 | 29 | class Condition : public ASTNode |
b4c522fa IB |
30 | { |
31 | public: | |
32 | Loc loc; | |
33 | // 0: not computed yet | |
34 | // 1: include | |
35 | // 2: do not include | |
36 | int inc; | |
37 | ||
38 | Condition(Loc loc); | |
39 | ||
40 | virtual Condition *syntaxCopy() = 0; | |
d3da83f6 | 41 | virtual int include(Scope *sc) = 0; |
b4c522fa | 42 | virtual DebugCondition *isDebugCondition() { return NULL; } |
77f4fb57 | 43 | virtual VersionCondition *isVersionCondition() { return NULL; } |
98866120 | 44 | void accept(Visitor *v) { v->visit(this); } |
b4c522fa IB |
45 | }; |
46 | ||
47 | class StaticForeach | |
48 | { | |
49 | public: | |
50 | Loc loc; | |
51 | ||
52 | ForeachStatement *aggrfe; | |
53 | ForeachRangeStatement *rangefe; | |
54 | ||
55 | bool needExpansion; | |
56 | ||
5b74dd0a | 57 | StaticForeach(Loc loc, ForeachStatement *aggrfe, ForeachRangeStatement *rangefe); |
b4c522fa IB |
58 | StaticForeach *syntaxCopy(); |
59 | }; | |
60 | ||
5b74dd0a IB |
61 | void staticForeachPrepare(StaticForeach *sfe, Scope *sc); |
62 | bool staticForeachReady(StaticForeach *sfe); | |
63 | ||
b4c522fa IB |
64 | class DVCondition : public Condition |
65 | { | |
66 | public: | |
67 | unsigned level; | |
68 | Identifier *ident; | |
69 | Module *mod; | |
70 | ||
71 | DVCondition(Module *mod, unsigned level, Identifier *ident); | |
72 | ||
73 | Condition *syntaxCopy(); | |
74 | void accept(Visitor *v) { v->visit(this); } | |
75 | }; | |
76 | ||
77 | class DebugCondition : public DVCondition | |
78 | { | |
79 | public: | |
b4c522fa IB |
80 | static void addGlobalIdent(const char *ident); |
81 | ||
82 | DebugCondition(Module *mod, unsigned level, Identifier *ident); | |
83 | ||
d3da83f6 | 84 | int include(Scope *sc); |
b4c522fa IB |
85 | DebugCondition *isDebugCondition() { return this; } |
86 | void accept(Visitor *v) { v->visit(this); } | |
87 | }; | |
88 | ||
89 | class VersionCondition : public DVCondition | |
90 | { | |
91 | public: | |
b4c522fa IB |
92 | static void addGlobalIdent(const char *ident); |
93 | static void addPredefinedGlobalIdent(const char *ident); | |
94 | ||
95 | VersionCondition(Module *mod, unsigned level, Identifier *ident); | |
96 | ||
d3da83f6 | 97 | int include(Scope *sc); |
77f4fb57 | 98 | VersionCondition *isVersionCondition() { return this; } |
b4c522fa IB |
99 | void accept(Visitor *v) { v->visit(this); } |
100 | }; | |
101 | ||
102 | class StaticIfCondition : public Condition | |
103 | { | |
104 | public: | |
105 | Expression *exp; | |
b4c522fa IB |
106 | |
107 | StaticIfCondition(Loc loc, Expression *exp); | |
108 | Condition *syntaxCopy(); | |
d3da83f6 | 109 | int include(Scope *sc); |
b4c522fa IB |
110 | void accept(Visitor *v) { v->visit(this); } |
111 | }; |