1 |
7
|
krennw
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
2
|
krennw
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
#pragma once
|
27 |
|
|
|
28 |
|
|
#include <ast/expressions/Expression.hpp>
|
29 |
|
|
#include <ast/IScope.hpp>
|
30 |
|
|
|
31 |
|
|
namespace Ast {
|
32 |
|
|
|
33 |
|
|
class TernaryOperator final
|
34 |
|
|
: public Expression
|
35 |
|
|
{
|
36 |
|
|
protected:
|
37 |
|
|
Expression* m_left;
|
38 |
|
|
Expression* m_mid;
|
39 |
|
|
Expression* m_right;
|
40 |
|
|
IScope* m_definingScope;
|
41 |
|
|
|
42 |
|
|
TernaryOperator(ExpressionKind kind):
|
43 |
|
|
Expression(kind),
|
44 |
|
|
m_left (nullptr),
|
45 |
|
|
m_mid (nullptr),
|
46 |
|
|
m_right(nullptr),
|
47 |
|
|
m_definingScope (nullptr)
|
48 |
|
|
{}
|
49 |
|
|
TernaryOperator(const TernaryOperator& toCopy):
|
50 |
|
|
Expression(toCopy),
|
51 |
|
|
m_left (toCopy.m_left),
|
52 |
|
|
m_mid (toCopy.m_mid),
|
53 |
|
|
m_right(toCopy.m_right),
|
54 |
|
|
m_definingScope (toCopy.m_definingScope)
|
55 |
|
|
{}
|
56 |
|
|
|
57 |
|
|
static TernaryOperator* create(ExpressionKind k){return new TernaryOperator(k);}
|
58 |
|
|
static TernaryOperator* createCopy(const TernaryOperator& toCopy){return new TernaryOperator(toCopy);}
|
59 |
|
|
public:
|
60 |
|
|
friend class Ast;
|
61 |
|
|
friend class Expression;
|
62 |
|
|
|
63 |
|
|
void init(std::int32_t line, std::int32_t pos,
|
64 |
|
|
Type* typeRef,IdentifierList* callTargetsIdentifierListRef,
|
65 |
|
|
SymbolTable* symbTabRef, Expression* left, Expression* mid,
|
66 |
|
|
Expression* right, IScope* defScopeRef)
|
67 |
|
|
{
|
68 |
|
|
Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
|
69 |
|
|
m_left = left;
|
70 |
|
|
m_mid = mid;
|
71 |
|
|
m_right = right;
|
72 |
|
|
m_definingScope = defScopeRef;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
Expression* left() {return m_left;};
|
77 |
|
|
Expression* mid() {return m_mid;};
|
78 |
|
|
Expression* right() {return m_right;};
|
79 |
|
|
IScope* definingScope() {return m_definingScope;};
|
80 |
|
|
|
81 |
|
|
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
82 |
|
|
void setLeftChild(Expression* newExpression) {m_left = newExpression;};
|
83 |
|
|
void setMidChild(Expression* newExpression) {m_mid = newExpression;};
|
84 |
|
|
void setRightChild(Expression* newExpression) {m_right = newExpression;};
|
85 |
|
|
};
|
86 |
|
|
} |