-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast_output.hpp
43 lines (35 loc) · 1.2 KB
/
ast_output.hpp
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
#ifndef ast_output_hpp
#define ast_output_hpp
#include <string>
#include <iostream>
#include "ast_node.hpp"
#include "ast_listnode.hpp"
class Output : public Node {
private:
ListPtr functions;
public:
Output(ListPtr _functions)
: functions(_functions)
{}
virtual void print(std::ostream &dst, int span) const override{
for (int i = 0; i<(functions)->size(); i++) {
(*functions)[i]->print(dst, span);
}
}
virtual void riscv_asm(std::ostream &dst,
Helper &helper,
std::string destReg,
std::map<std::string, std::vector<std::string>> &bindings,
std::string datatype = "None") const override{
for (int i = 0; i<(functions)->size(); i++) {
datatype = (*functions)[i]->getType();
if (datatype == "float" || datatype == "double" || datatype == "long double"){
(*functions)[i]->riscv_asm(dst,helper,"fa0", bindings, datatype);
}
else{
(*functions)[i]->riscv_asm(dst,helper,"a0", bindings, datatype);
}
}
}
};
#endif