-
Notifications
You must be signed in to change notification settings - Fork 1
/
ast.cpp
57 lines (43 loc) · 1 KB
/
ast.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
#include "ast.hpp"
#include <iostream>
StmtAST::~StmtAST() {
}
fdata BlockStmtAST::statistics(fdata data) const {
for (auto e : _stmts)
data = e->statistics(data);
return data;
}
fdata LoopStmtAST::statistics(fdata data) const {
data.numLoops++;
data = _body->statistics(data);
return data;
}
fdata CallStmtAST::statistics(fdata data) const {
if(_name.compare(data.name) == 0)
data.recursive = true;
return data;
}
fdata AssignStmtAST::statistics(fdata data) const {
return data;
}
fdata IfElseStmtAST::statistics(fdata data) const {
data.numBranches++;
data = _then->statistics(data);
if(_else != nullptr)
data = _else->statistics(data);
return data;
}
fdata SwitchStmtAST::statistics(fdata data) const {
data.numBranches++;
for (auto e : _stmts)
data = e->statistics(data);
return data;
}
fdata DeclarationStmtAST::statistics(fdata data) const {
data.numVars += _numOfDecls;
return data;
}
/* return-break-continue */
fdata RBCStmtAST::statistics(fdata data) const {
return data;
}