- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnv.cpp
More file actions
Latest commit
29 lines (23 loc) · 552 Bytes
/
Copy pathEnv.cpp
File metadata and controls
29 lines (23 loc) · 552 Bytes
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
#include"Env.hpp"
#include<iostream>
voidEnv::addFunc(const Func* func) {
_funcs.emplace_back(func);
}
voidEnv::eval(std::ostream& out) const {
bool has_main = false;
for (auto& func : _funcs) {
if (func->getName() == "main") {
has_main = true;
break;
}
}
if (!has_main) {
std::cerr << "Error: No main function" << std::endl;
return;
}
out << ".text" << std::endl;
for (auto& func : _funcs) {
func->eval(out);
}
this->labels.eval(out);
}