summaryrefslogtreecommitdiff
path: root/value.h
blob: fbc0baeead8a1c1b4631321d87c9582d9a96962b (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

#ifndef VALUE_H_
#define VALUE_H_

#include <string>

#include "register_address.h"

class evaluator;

enum value_type {
	VALUE_TYPE_GENERIC,
	VALUE_TYPE_TREE,
	VALUE_TYPE_CONST,
	VALUE_TYPE_FLOAT
};

class value {
public:
	value(enum value_type type);

	virtual value * simplify() = 0;
	virtual value * clone() = 0;
	virtual std::string to_string() = 0;
	enum value_type get_type();

private:
	enum value_type m_type;
};

class tree_value : public value {
public:
	tree_value(evaluator *, value * lchild, value * rchild);
	value * simplify();
	value * clone();
	std::string to_string();
private:
	evaluator * m_evaluator;
	value * m_lchild;
	value * m_rchild;
};

class float_value : public value {
public:
	float_value();
	float_value(float init_value);
	value * simplify();
	value * clone();
	std::string to_string();

	void set_value(float value);

	bool m_has_value;
	float m_value;
};

class const_value : public value {
public:
	const_value(
		register_address reg,
		float_value * value);
	value * simplify();
	value * clone();
	std::string to_string();
private:
	register_address m_reg_address;
	float_value * m_value;
};

#endif //VALUE_H_