- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunc.cpp
More file actions
Latest commit
23 lines (15 loc) · 509 Bytes
/
Copy pathFunc.cpp
File metadata and controls
23 lines (15 loc) · 509 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include"Func.hpp"
#include"asm.hpp"
Func::Func(const std::string& name, Scope* scope) : _name(name), _scope(scope) {
}
voidFunc::eval(std::ostream& out) const {
const std::string my_name = _name == "main" ? "alpha_main" : _name;
out << ".globl\t_" << my_name << std::endl;
out << '_' << my_name << ':' << std::endl;
gas::push(out, P_BASE);
gas::mov(out, P_STACK, P_BASE);
_scope->prepare();
_scope->eval(out);
gas::pop(out, P_BASE);
out << "ret" << std::endl;
}