This repository was archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstmt.cpp
145 lines (120 loc) · 3.74 KB
/
stmt.cpp
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "stmt.hpp"
#include <iostream>
void AssignStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_lvalue_) p_lvalue_->UpdateDepth(depth + 1);
if (p_expr_) p_expr_->UpdateDepth(depth + 1);
}
void AssignStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_lvalue_) p_lvalue_->Print(os);
if (p_expr_) p_expr_->Print(os);
}
void ProcCallStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_id_) p_id_->UpdateDepth(depth + 1);
if (p_actual_params_) p_actual_params_->UpdateDepth(depth + 1);
}
void ProcCallStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_id_) p_id_->Print(os);
if (p_actual_params_) p_actual_params_->Print(os);
}
void ReadStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_read_params_) p_read_params_->UpdateDepth(depth + 1);
}
void ReadStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_read_params_) p_read_params_->Print(os);
}
void WriteStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_write_params_) p_write_params_->UpdateDepth(depth + 1);
}
void WriteStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_write_params_) p_write_params_->Print(os);
}
void IfStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_expr_) p_expr_->UpdateDepth(depth + 1);
if (p_stmts_) p_stmts_->UpdateDepth(depth + 1);
if (p_elif_sections_) p_elif_sections_->UpdateDepth(depth + 1);
if (p_else_section_) p_else_section_->UpdateDepth(depth + 1);
}
void IfStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_expr_) p_expr_->Print(os);
if (p_stmts_) p_stmts_->Print(os);
if (p_elif_sections_) p_elif_sections_->Print(os);
if (p_else_section_) p_else_section_->Print(os);
}
void ElifSection::UpdateDepth(int depth) {
Node::UpdateDepth(depth);
if (p_expr_) p_expr_->UpdateDepth(depth + 1);
if (p_stmts_) p_stmts_->UpdateDepth(depth + 1);
}
void ElifSection::Print(std::ostream& os) const {
Node::Print(os);
if (p_expr_) p_expr_->Print(os);
if (p_stmts_) p_stmts_->Print(os);
}
void ElseSection::UpdateDepth(int depth) {
Node::UpdateDepth(depth);
if (p_stmts_) p_stmts_->UpdateDepth(depth + 1);
}
void ElseSection::Print(std::ostream& os) const {
Node::Print(os);
if (p_stmts_) p_stmts_->Print(os);
}
void WhileStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_expr_) p_expr_->UpdateDepth(depth + 1);
if (p_stmts_) p_stmts_->UpdateDepth(depth + 1);
}
void WhileStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_expr_) p_expr_->Print(os);
if (p_stmts_) p_stmts_->Print(os);
}
void LoopStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_stmts_) p_stmts_->UpdateDepth(depth + 1);
}
void LoopStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_stmts_) p_stmts_->Print(os);
}
void ForStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_id_) p_id_->UpdateDepth(depth + 1);
if (p_begin_) p_begin_->UpdateDepth(depth + 1);
if (p_end_) p_end_->UpdateDepth(depth + 1);
if (p_step_) p_step_->UpdateDepth(depth + 1);
if (p_stmts_) p_stmts_->UpdateDepth(depth + 1);
}
void ForStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_id_) p_id_->Print(os);
if (p_begin_) p_begin_->Print(os);
if (p_end_) p_end_->Print(os);
if (p_step_) p_step_->Print(os);
if (p_stmts_) p_stmts_->Print(os);
}
void ForStep::UpdateDepth(int depth) {
Node::UpdateDepth(depth);
if (p_expr_) p_expr_->UpdateDepth(depth + 1);
}
void ForStep::Print(std::ostream& os) const {
Node::Print(os);
if (p_expr_) p_expr_->Print(os);
}
void ReturnStmt::UpdateDepth(int depth) {
Stmt::UpdateDepth(depth);
if (p_expr_) p_expr_->UpdateDepth(depth + 1);
}
void ReturnStmt::Print(std::ostream& os) const {
Stmt::Print(os);
if (p_expr_) p_expr_->Print(os);
}