-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.cpp
More file actions
114 lines (91 loc) · 1.73 KB
/
check.cpp
File metadata and controls
114 lines (91 loc) · 1.73 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "check.hpp"
void check_visitor::visit( bool_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( and_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( or_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( not_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( cond_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( equal_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( inequal_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( int_expr* e )
{
r = &e->get_context().int_ty;
}
void check_visitor::visit( neg_expr* e )
{
r = &e->get_context().int_ty;
}
void check_visitor::visit( add_expr* e )
{
r = &e->get_context().int_ty;
}
void check_visitor::visit( sub_expr* e )
{
r = &e->get_context().int_ty;
}
void check_visitor::visit( mul_expr* e )
{
r = &e->get_context().int_ty;
}
void check_visitor::visit( div_expr* e )
{
r = &e->get_context().int_ty;
}
void check_visitor::visit( rem_expr* e )
{
r = &e->get_context().int_ty;
}
void check_visitor::visit( less_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( greater_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( lesseq_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( greatereq_expr* e )
{
r = &e->get_context().bool_ty;
}
void check_visitor::visit( ref_expr* e )
{
r = e->get_type();
}
void check_visitor::visit( value_expr* e )
{
auto parent = static_cast<ref_expr*>( e->get_parent() );
r = parent->get_type();
}
void check_visitor::visit( assign_expr* e )
{
}
const type* check( expr* e )
{
check_visitor v;
e->accept( v );
return v.r;
}