Commit ea90d4dc authored by Yang's avatar Yang

recover ASMInst change

parent 78b2f265
......@@ -8,16 +8,13 @@
class CodeGen {
public:
explicit CodeGen(Module *module) : m(module) {}
~CodeGen(){
for(auto i : output) delete i;
}
std::string print() const;
void run();
template <class... Args> void append_inst(Args... arg) {
output.emplace_back(new ASMInstruction(arg...));
output.emplace_back(arg...);
}
void
......@@ -29,7 +26,7 @@ class CodeGen {
}
content.pop_back();
content.pop_back();
output.emplace_back(new ASMInstruction(content, ty));
output.emplace_back(content, ty);
}
private:
......@@ -101,5 +98,5 @@ class CodeGen {
} context;
Module *m;
std::list<ASMInstruction*> output;
std::list<ASMInstruction> output;
};
......@@ -405,7 +405,7 @@ void CodeGen::run() {
}
// 函数代码段
output.emplace_back(new ASMInstruction(".text", ASMInstruction::Attribute));
output.emplace_back(".text", ASMInstruction::Attribute);
for (auto func : m->get_functions()) {
if (not func->is_declaration()) {
// 更新 context
......@@ -511,8 +511,8 @@ void CodeGen::run() {
std::string CodeGen::print() const {
std::string result;
for (const auto inst : output) {
result += inst->format();
for (const auto& inst : output) {
result += inst.format();
}
return result;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment