-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstatements.cpp
33 lines (30 loc) · 859 Bytes
/
statements.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
/**
* Implementation of \ref Statements class
*/
#include "statements.h"
/**
* Tells whether this set of statements return anything
* @return true if the return something false otherwise
*/
bool Statements::has_return() {
for (int i = 0; i < statements_list.size(); i++) {
if (statements_list[i]->has_return()) {
return true;
}
}
return false;
}
Value *Statements::generateCode(Constructs *compilerConstructs) {
Value *v = ConstantInt::get(compilerConstructs->Context, llvm::APInt(32, 1));
for (auto &stmt : statements_list) {
v = stmt->generateCode(compilerConstructs);
}
return v;
}
/**
* Add a given statement to the list of statements
* @param statement statement to be added
*/
void Statements::push_back(class Statement *statement) {
statements_list.push_back(statement);
}