]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/d/dmd/cond.h
d: Merge upstream dmd 13d67c575.
[thirdparty/gcc.git] / gcc / d / dmd / cond.h
CommitLineData
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
17class Expression;
18class Identifier;
19struct OutBuffer;
20class Module;
21struct Scope;
22class ScopeDsymbol;
23class DebugCondition;
24class ForeachStatement;
25class ForeachRangeStatement;
26
5bc13e52 27int findCondition(Identifiers *ids, Identifier *ident);
b4c522fa 28
98866120 29class Condition : public ASTNode
b4c522fa
IB
30{
31public:
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
47class StaticForeach
48{
49public:
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
61void staticForeachPrepare(StaticForeach *sfe, Scope *sc);
62bool staticForeachReady(StaticForeach *sfe);
63
b4c522fa
IB
64class DVCondition : public Condition
65{
66public:
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
77class DebugCondition : public DVCondition
78{
79public:
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
89class VersionCondition : public DVCondition
90{
91public:
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
102class StaticIfCondition : public Condition
103{
104public:
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};