d: Merge dmd, druntime d8e3976a58, phobos 7a6e95688
[official-gcc.git] / gcc / d / dmd / cond.h
blobfe497c2da7e14ddea7235d69aa9c8f7e6137de9b
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * https://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * https://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/cond.h
9 */
11 #pragma once
13 #include "ast_node.h"
14 #include "globals.h"
15 #include "visitor.h"
17 class Expression;
18 class Identifier;
19 class Module;
20 struct Scope;
21 class DebugCondition;
22 class ForeachStatement;
23 class ForeachRangeStatement;
25 enum Include
27 INCLUDEnotComputed, /// not computed yet
28 INCLUDEyes, /// include the conditional code
29 INCLUDEno /// do not include the conditional code
32 class Condition : public ASTNode
34 public:
35 Loc loc;
36 Include inc;
38 DYNCAST dyncast() const override final { return DYNCAST_CONDITION; }
40 virtual Condition *syntaxCopy() = 0;
41 virtual int include(Scope *sc) = 0;
42 virtual DebugCondition *isDebugCondition() { return NULL; }
43 virtual VersionCondition *isVersionCondition() { return NULL; }
44 void accept(Visitor *v) override { v->visit(this); }
47 class StaticForeach final : public RootObject
49 public:
50 Loc loc;
52 ForeachStatement *aggrfe;
53 ForeachRangeStatement *rangefe;
55 d_bool needExpansion;
58 class DVCondition : public Condition
60 public:
61 unsigned level;
62 Identifier *ident;
63 Module *mod;
65 DVCondition *syntaxCopy() override final;
66 void accept(Visitor *v) override { v->visit(this); }
69 class DebugCondition final : public DVCondition
71 public:
72 static void addGlobalIdent(const char *ident);
74 int include(Scope *sc) override;
75 DebugCondition *isDebugCondition() override { return this; }
76 void accept(Visitor *v) override { v->visit(this); }
79 class VersionCondition final : public DVCondition
81 public:
82 static void addGlobalIdent(const char *ident);
83 static void addPredefinedGlobalIdent(const char *ident);
85 int include(Scope *sc) override;
86 VersionCondition *isVersionCondition() override { return this; }
87 void accept(Visitor *v) override { v->visit(this); }
90 class StaticIfCondition final : public Condition
92 public:
93 Expression *exp;
95 StaticIfCondition *syntaxCopy() override;
96 int include(Scope *sc) override;
97 void accept(Visitor *v) override { v->visit(this); }