blob: 6b2745241ce917ff791ba167c812768999e75382 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/**
** \file ast/if-exp.hh
** \brief Declaration of ast::IfExp.
*/
#pragma once
#include <ast/exp.hh>
#include <ast/seq-exp.hh>
namespace ast
{
/// IfExp.
class IfExp : public Exp
{
public:
IfExp(const Location& location, Exp* test, Exp* thenclause)
: Exp(location)
, test_(test)
, thenclause_(thenclause)
, elseclause_(new SeqExp(location, new exps_type()))
{}
public:
/** \name Ctor & dtor.
** \{ */
/// Construct an IfExp node.
IfExp(const Location& location,
Exp* test,
Exp* thenclause,
Exp* elseclause);
IfExp(const IfExp&) = delete;
IfExp& operator=(const IfExp&) = delete;
/// Destroy an IfExp node.
~IfExp() override;
/** \} */
/// \name Visitors entry point.
/// \{ */
/// Accept a const visitor \a v.
void accept(ConstVisitor& v) const override;
/// Accept a non-const visitor \a v.
void accept(Visitor& v) override;
/// \}
/** \name Accessors.
** \{ */
/// Return condition.
const Exp& test_get() const;
/// Return condition.
Exp& test_get();
/// Return instructions executed if condition is true.
const Exp& thenclause_get() const;
/// Return instructions executed if condition is true.
Exp& thenclause_get();
/// Return instructions executed if condition is false.
const Exp& elseclause_get() const;
/// Return instructions executed if condition is false.
Exp& elseclause_get();
/** \} */
protected:
/// Condition.
Exp* test_;
/// Instructions executed if condition is true.
Exp* thenclause_;
/// Instructions executed if condition is false.
Exp* elseclause_;
};
} // namespace ast
#include <ast/if-exp.hxx>
|