-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpression.h
More file actions
43 lines (31 loc) · 826 Bytes
/
Copy pathexpression.h
File metadata and controls
43 lines (31 loc) · 826 Bytes
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
#ifndef __EXPRESSION_H__
#define __EXPRESSION_H__
#include <string>
enum class expression_type
{
Long = 1,
Double,
};
std::string to_string(expression_type type) {
if (type == expression_type::Long)
return "long";
if (type == expression_type::Double)
return "double";
throw new std::runtime_error("Unknown type.");
}
struct expression_node
{
private:
expression_type _type;
std::string _register_name;
public:
expression_node(expression_type type, const std::string& register_name) : _type(type), _register_name(register_name) { }
expression_type type() const { return _type; }
std::string register_name() const { return _register_name; }
std::string to_string() const {
if (type() == expression_type::Double)
return "double " + register_name();
return "i64 " + register_name();
}
};
#endif