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
|
#pragma once
|
27
|
|
28
|
#include <ast/expressions/LeafExpression.hpp>
|
29
|
#include <cstdint>
|
30
|
#include <ast/IAstVisitor.hpp>
|
31
|
|
32
|
namespace Ast {
|
33
|
|
34
|
template <class T>
|
35
|
class ValueExpression
|
36
|
: public LeafExpression
|
37
|
{
|
38
|
protected:
|
39
|
T m_value;
|
40
|
|
41
|
ValueExpression(LeafTypeEnum type, ExpressionKind k):
|
42
|
LeafExpression(type, k),
|
43
|
m_value ()
|
44
|
{};
|
45
|
ValueExpression(const ValueExpression &toCopy):
|
46
|
LeafExpression(toCopy),
|
47
|
m_value(toCopy.m_value)
|
48
|
{};
|
49
|
public:
|
50
|
T value() {return m_value;};
|
51
|
};
|
52
|
|
53
|
class BoolValueExpression final
|
54
|
: public ValueExpression<bool>
|
55
|
{
|
56
|
protected:
|
57
|
BoolValueExpression():
|
58
|
ValueExpression(LeafTypeEnum::_bool, ExpressionKind::Value_Bool)
|
59
|
{};
|
60
|
BoolValueExpression(const BoolValueExpression& toCopy):
|
61
|
ValueExpression(toCopy)
|
62
|
{};
|
63
|
|
64
|
static BoolValueExpression* create(ExpressionKind) {return new BoolValueExpression();}
|
65
|
static BoolValueExpression* createCopy(const BoolValueExpression& toCopy) {return new BoolValueExpression(toCopy);}
|
66
|
public:
|
67
|
friend class Ast;
|
68
|
friend class Expression;
|
69
|
|
70
|
void init(std::int32_t line, std::int32_t pos, Type* typeRef,
|
71
|
IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, bool value)
|
72
|
{
|
73
|
Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
|
74
|
m_value = value;
|
75
|
}
|
76
|
|
77
|
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
78
|
};
|
79
|
|
80
|
class IntValueExpression final
|
81
|
: public ValueExpression<std::int64_t>
|
82
|
{
|
83
|
protected:
|
84
|
IntValueExpression():
|
85
|
ValueExpression(LeafTypeEnum::integer, ExpressionKind::Value_Integer)
|
86
|
{};
|
87
|
IntValueExpression(const IntValueExpression& toCopy):
|
88
|
ValueExpression(toCopy)
|
89
|
{};
|
90
|
|
91
|
static IntValueExpression* create(ExpressionKind) {return new IntValueExpression();}
|
92
|
static IntValueExpression* createCopy(const IntValueExpression& toCopy) {return new IntValueExpression(toCopy);}
|
93
|
public:
|
94
|
friend class Ast;
|
95
|
friend class Expression;
|
96
|
|
97
|
void init(std::int32_t line, std::int32_t pos,
|
98
|
Type* typeRef,IdentifierList* callTargetsIdentifierListRef,
|
99
|
SymbolTable* symbTabRef, std::int64_t value)
|
100
|
{
|
101
|
Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
|
102
|
m_value = value;
|
103
|
}
|
104
|
|
105
|
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
106
|
};
|
107
|
|
108
|
class RefValueExpression final
|
109
|
: public ValueExpression<void*>
|
110
|
{
|
111
|
protected:
|
112
|
RefValueExpression():
|
113
|
ValueExpression(LeafTypeEnum::reference, ExpressionKind::Value_Reference)
|
114
|
{};
|
115
|
RefValueExpression(const RefValueExpression& toCopy):
|
116
|
ValueExpression(toCopy)
|
117
|
{};
|
118
|
|
119
|
static RefValueExpression* create(ExpressionKind) {return new RefValueExpression();}
|
120
|
static RefValueExpression* createCopy(const RefValueExpression& toCopy) {return new RefValueExpression(toCopy);}
|
121
|
public:
|
122
|
friend class Ast;
|
123
|
friend class Expression;
|
124
|
|
125
|
void init(std::int32_t line, std::int32_t pos, Type* typeRef,
|
126
|
IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef, void* value)
|
127
|
{
|
128
|
Expression::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef);
|
129
|
m_value = value;
|
130
|
}
|
131
|
void accept(IAstVisitor& visitor) override {visitor.visit(this);};
|
132
|
};
|
133
|
|
134
|
|
135
|
|
136
|
|
137
|
}
|