-
Notifications
You must be signed in to change notification settings - Fork 8
/
type_base.h
53 lines (39 loc) · 1.12 KB
/
type_base.h
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
#pragma once
#include <string>
#include <memory>
namespace compiler
{
using namespace std;
class type_base;
typedef shared_ptr<type_base> type_base_ptr;
class type_base
{
public:
type_base(const string &name, const string &id);
const string id;
const string name;
virtual bool is_assignable_from(type_base_ptr b) const = 0;
virtual bool can_be_cast_to(type_base_ptr to_type) const = 0;
virtual bool is_primitive() const;
virtual bool is_integral() const;
virtual bool is_void() const;
virtual bool is_pointer() const;
virtual bool is_array() const;
virtual type_base_ptr implicit_cast_with(type_base_ptr a, type_base_ptr b) const = 0;
virtual size_t size() const = 0;
virtual bool operator== (const type_base &b) const;
virtual bool operator!= (const type_base &b) const;
};
struct type_representation
{
type_base_ptr base_type;
bool is_const;
bool is_static;
bool is_built_in = false;
bool is_lvalue = false;
type_representation(type_base_ptr base_type, bool is_const, bool is_static);
type_representation(type_base_ptr base_type);
type_representation();
string to_string();
};
}