diff --git a/decompiler/IR/IR.cpp b/decompiler/IR/IR.cpp index 218d548633..8635f8e8a3 100644 --- a/decompiler/IR/IR.cpp +++ b/decompiler/IR/IR.cpp @@ -23,29 +23,30 @@ std::vector> IR::get_all_ir(LinkedObjectFile& file) const { } std::string IR::print(const LinkedObjectFile& file) const { - return to_form(file)->toStringPretty(); + return pretty_print::to_string(to_form(file)); } -std::shared_ptr
IR_Failed::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Failed::to_form(const LinkedObjectFile& file) const { (void)file; - return buildList("INVALID-OPERATION"); + return pretty_print::build_list("INVALID-OPERATION"); } void IR_Failed::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr IR_Register::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Register::to_form(const LinkedObjectFile& file) const { (void)file; - return toForm(reg.to_charp()); + return pretty_print::to_symbol(reg.to_charp()); } void IR_Register::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr IR_Set::to_form(const LinkedObjectFile& file) const { - return buildList(toForm("set!"), dst->to_form(file), src->to_form(file)); +goos::Object IR_Set::to_form(const LinkedObjectFile& file) const { + return pretty_print::build_list(pretty_print::to_symbol("set!"), dst->to_form(file), + src->to_form(file)); } void IR_Set::get_children(std::vector>* output) const { @@ -55,7 +56,7 @@ void IR_Set::get_children(std::vector>* output) const { output->push_back(src); } -std::shared_ptr IR_Store::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Store::to_form(const LinkedObjectFile& file) const { std::string store_operator; switch (kind) { case FLOAT: @@ -86,37 +87,38 @@ std::shared_ptr IR_Store::to_form(const LinkedObjectFile& file) const { assert(false); } - return buildList(toForm(store_operator), dst->to_form(file), src->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(store_operator), dst->to_form(file), + src->to_form(file)); } -std::shared_ptr IR_Symbol::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Symbol::to_form(const LinkedObjectFile& file) const { (void)file; - return toForm("'" + name); + return pretty_print::to_symbol("'" + name); } void IR_Symbol::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr IR_SymbolValue::to_form(const LinkedObjectFile& file) const { +goos::Object IR_SymbolValue::to_form(const LinkedObjectFile& file) const { (void)file; - return toForm(name); + return pretty_print::to_symbol(name); } void IR_SymbolValue::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr IR_StaticAddress::to_form(const LinkedObjectFile& file) const { - // return buildList(toForm("&"), file.get_label_name(label_id)); - return toForm(file.get_label_name(label_id)); +goos::Object IR_StaticAddress::to_form(const LinkedObjectFile& file) const { + // return pretty_print::build_list(pretty_print::to_symbol("&"), file.get_label_name(label_id)); + return pretty_print::to_symbol(file.get_label_name(label_id)); } void IR_StaticAddress::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr IR_Load::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Load::to_form(const LinkedObjectFile& file) const { std::string load_operator; switch (kind) { case FLOAT: @@ -161,14 +163,14 @@ std::shared_ptr IR_Load::to_form(const LinkedObjectFile& file) const { default: assert(false); } - return buildList(toForm(load_operator), location->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(load_operator), location->to_form(file)); } void IR_Load::get_children(std::vector>* output) const { output->push_back(location); } -std::shared_ptr IR_FloatMath2::to_form(const LinkedObjectFile& file) const { +goos::Object IR_FloatMath2::to_form(const LinkedObjectFile& file) const { std::string math_operator; switch (kind) { case DIV: @@ -193,7 +195,8 @@ std::shared_ptr IR_FloatMath2::to_form(const LinkedObjectFile& file) const assert(false); } - return buildList(toForm(math_operator), arg0->to_form(file), arg1->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg0->to_form(file), + arg1->to_form(file)); } void IR_FloatMath2::get_children(std::vector>* output) const { @@ -205,7 +208,7 @@ void IR_FloatMath1::get_children(std::vector>* output) const output->push_back(arg); } -std::shared_ptr IR_IntMath2::to_form(const LinkedObjectFile& file) const { +goos::Object IR_IntMath2::to_form(const LinkedObjectFile& file) const { std::string math_operator; switch (kind) { case ADD: @@ -256,7 +259,8 @@ std::shared_ptr IR_IntMath2::to_form(const LinkedObjectFile& file) const { default: assert(false); } - return buildList(toForm(math_operator), arg0->to_form(file), arg1->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg0->to_form(file), + arg1->to_form(file)); } void IR_IntMath2::get_children(std::vector>* output) const { @@ -264,7 +268,7 @@ void IR_IntMath2::get_children(std::vector>* output) const { output->push_back(arg1); } -std::shared_ptr IR_IntMath1::to_form(const LinkedObjectFile& file) const { +goos::Object IR_IntMath1::to_form(const LinkedObjectFile& file) const { std::string math_operator; switch (kind) { case NOT: @@ -276,14 +280,14 @@ std::shared_ptr IR_IntMath1::to_form(const LinkedObjectFile& file) const { default: assert(false); } - return buildList(toForm(math_operator), arg->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg->to_form(file)); } void IR_IntMath1::get_children(std::vector>* output) const { output->push_back(arg); } -std::shared_ptr IR_FloatMath1::to_form(const LinkedObjectFile& file) const { +goos::Object IR_FloatMath1::to_form(const LinkedObjectFile& file) const { std::string math_operator; switch (kind) { case FLOAT_TO_INT: @@ -304,50 +308,57 @@ std::shared_ptr IR_FloatMath1::to_form(const LinkedObjectFile& file) const default: assert(false); } - return buildList(toForm(math_operator), arg->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg->to_form(file)); } -std::shared_ptr IR_Call::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Call::to_form(const LinkedObjectFile& file) const { (void)file; - return buildList("call!"); + return pretty_print::build_list("call!"); } void IR_Call::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr IR_IntegerConstant::to_form(const LinkedObjectFile& file) const { +goos::Object IR_IntegerConstant::to_form(const LinkedObjectFile& file) const { (void)file; - return toForm(std::to_string(value)); + return pretty_print::to_symbol(std::to_string(value)); } void IR_IntegerConstant::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr BranchDelay::to_form(const LinkedObjectFile& file) const { +goos::Object BranchDelay::to_form(const LinkedObjectFile& file) const { (void)file; switch (kind) { case NOP: - return buildList("nop"); + return pretty_print::build_list("nop"); case SET_REG_FALSE: - return buildList(toForm("set!"), destination->to_form(file), "'#f"); + return pretty_print::build_list(pretty_print::to_symbol("set!"), destination->to_form(file), + "'#f"); case SET_REG_TRUE: - return buildList(toForm("set!"), destination->to_form(file), "'#t"); + return pretty_print::build_list(pretty_print::to_symbol("set!"), destination->to_form(file), + "'#t"); case SET_REG_REG: - return buildList(toForm("set!"), destination->to_form(file), source->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol("set!"), destination->to_form(file), + source->to_form(file)); case SET_BINTEGER: - return buildList(toForm("set!"), destination->to_form(file), "binteger"); + return pretty_print::build_list(pretty_print::to_symbol("set!"), destination->to_form(file), + "binteger"); case SET_PAIR: - return buildList(toForm("set!"), destination->to_form(file), "pair"); + return pretty_print::build_list(pretty_print::to_symbol("set!"), destination->to_form(file), + "pair"); case DSLLV: - return buildList(toForm("set!"), destination->to_form(file), - buildList("shl", source->to_form(file), source2->to_form(file))); + return pretty_print::build_list( + pretty_print::to_symbol("set!"), destination->to_form(file), + pretty_print::build_list(pretty_print::to_symbol("shl"), source->to_form(file), + source2->to_form(file))); case NEGATE: - return buildList(toForm("set!"), destination->to_form(file), - buildList("-", source->to_form(file))); + return pretty_print::build_list(pretty_print::to_symbol("set!"), destination->to_form(file), + pretty_print::build_list("-", source->to_form(file))); case UNKNOWN: - return buildList("unknown-branch-delay"); + return pretty_print::build_list("unknown-branch-delay"); default: assert(false); } @@ -367,9 +378,9 @@ void BranchDelay::get_children(std::vector>* output) const { } } -std::shared_ptr IR_Nop::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Nop::to_form(const LinkedObjectFile& file) const { (void)file; - return buildList("nop!"); + return pretty_print::build_list("nop!"); } int Condition::num_args() const { @@ -414,7 +425,7 @@ void Condition::get_children(std::vector>* output) const { } } -std::shared_ptr Condition::to_form(const LinkedObjectFile& file) const { +goos::Object Condition::to_form(const LinkedObjectFile& file) const { int nargs = num_args(); std::string condtion_operator; switch (kind) { @@ -489,23 +500,26 @@ std::shared_ptr Condition::to_form(const LinkedObjectFile& file) const { } if (nargs == 2) { - return buildList(toForm(condtion_operator), src0->to_form(file), src1->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(condtion_operator), src0->to_form(file), + src1->to_form(file)); } else if (nargs == 1) { if (condtion_operator.empty()) { return src0->to_form(file); } else { - return buildList(toForm(condtion_operator), src0->to_form(file)); + return pretty_print::build_list(pretty_print::to_symbol(condtion_operator), + src0->to_form(file)); } } else if (nargs == 0) { - return toForm(condtion_operator); + return pretty_print::to_symbol(condtion_operator); } else { assert(false); } } -std::shared_ptr IR_Branch::to_form(const LinkedObjectFile& file) const { - return buildList(toForm(likely ? "bl!" : "b!"), condition.to_form(file), - toForm(file.get_label_name(dest_label_idx)), branch_delay.to_form(file)); +goos::Object IR_Branch::to_form(const LinkedObjectFile& file) const { + return pretty_print::build_list( + pretty_print::to_symbol(likely ? "bl!" : "b!"), condition.to_form(file), + pretty_print::to_symbol(file.get_label_name(dest_label_idx)), branch_delay.to_form(file)); } void IR_Branch::get_children(std::vector>* output) const { @@ -513,7 +527,7 @@ void IR_Branch::get_children(std::vector>* output) const { branch_delay.get_children(output); } -std::shared_ptr IR_Compare::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Compare::to_form(const LinkedObjectFile& file) const { return condition.to_form(file); } @@ -521,9 +535,9 @@ void IR_Compare::get_children(std::vector>* output) const { condition.get_children(output); } -std::shared_ptr IR_Suspend::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Suspend::to_form(const LinkedObjectFile& file) const { (void)file; - return buildList("suspend!"); + return pretty_print::build_list("suspend!"); } void IR_Nop::get_children(std::vector>* output) const { @@ -534,13 +548,13 @@ void IR_Suspend::get_children(std::vector>* output) const { (void)output; } -std::shared_ptr IR_Begin::to_form(const LinkedObjectFile& file) const { - std::vector> list; - list.push_back(toForm("begin")); +goos::Object IR_Begin::to_form(const LinkedObjectFile& file) const { + std::vector list; + list.push_back(pretty_print::to_symbol("begin")); for (auto& x : forms) { list.push_back(x->to_form(file)); } - return buildList(list); + return pretty_print::build_list(list); } void IR_Begin::get_children(std::vector>* output) const { @@ -550,9 +564,7 @@ void IR_Begin::get_children(std::vector>* output) const { } namespace { -void print_inlining_begin(std::vector>* output, - IR* ir, - const LinkedObjectFile& file) { +void print_inlining_begin(std::vector* output, IR* ir, const LinkedObjectFile& file) { auto as_begin = dynamic_cast(ir); if (as_begin) { for (auto& x : as_begin->forms) { @@ -568,12 +580,12 @@ bool is_single_expression(IR* in) { } } // namespace -std::shared_ptr IR_WhileLoop::to_form(const LinkedObjectFile& file) const { - std::vector> list; - list.push_back(toForm("while")); +goos::Object IR_WhileLoop::to_form(const LinkedObjectFile& file) const { + std::vector list; + list.push_back(pretty_print::to_symbol("while")); list.push_back(condition->to_form(file)); print_inlining_begin(&list, body.get(), file); - return buildList(list); + return pretty_print::build_list(list); } void IR_WhileLoop::get_children(std::vector>* output) const { @@ -581,31 +593,31 @@ void IR_WhileLoop::get_children(std::vector>* output) const output->push_back(body); } -std::shared_ptr IR_CondWithElse::to_form(const LinkedObjectFile& file) const { +goos::Object IR_CondWithElse::to_form(const LinkedObjectFile& file) const { // for now we only turn it into an if statement if both cases won't require a begin at the top // level. I think it is more common to write these as a two-case cond instead of an if with begin. if (entries.size() == 1 && is_single_expression(entries.front().body.get()) && is_single_expression(else_ir.get())) { - std::vector> list; - list.push_back(toForm("if")); + std::vector list; + list.push_back(pretty_print::to_symbol("if")); list.push_back(entries.front().condition->to_form(file)); list.push_back(entries.front().body->to_form(file)); list.push_back(else_ir->to_form(file)); - return buildList(list); + return pretty_print::build_list(list); } else { - std::vector> list; - list.push_back(toForm("cond")); + std::vector list; + list.push_back(pretty_print::to_symbol("cond")); for (auto& e : entries) { - std::vector> entry; + std::vector entry; entry.push_back(e.condition->to_form(file)); print_inlining_begin(&entry, e.body.get(), file); - list.push_back(buildList(entry)); + list.push_back(pretty_print::build_list(entry)); } - std::vector> else_form; - else_form.push_back(toForm("else")); + std::vector else_form; + else_form.push_back(pretty_print::to_symbol("else")); print_inlining_begin(&else_form, else_ir.get(), file); - list.push_back(buildList(else_form)); - return buildList(list); + list.push_back(pretty_print::build_list(else_form)); + return pretty_print::build_list(list); } } @@ -617,40 +629,40 @@ void IR_CondWithElse::get_children(std::vector>* output) con output->push_back(else_ir); } -std::shared_ptr IR_GetRuntimeType::to_form(const LinkedObjectFile& file) const { - std::vector> list = {toForm("type-of"), object->to_form(file)}; - return buildList(list); +goos::Object IR_GetRuntimeType::to_form(const LinkedObjectFile& file) const { + std::vector list = {pretty_print::to_symbol("type-of"), object->to_form(file)}; + return pretty_print::build_list(list); } void IR_GetRuntimeType::get_children(std::vector>* output) const { output->push_back(object); } -std::shared_ptr IR_Cond::to_form(const LinkedObjectFile& file) const { +goos::Object IR_Cond::to_form(const LinkedObjectFile& file) const { if (entries.size() == 1 && is_single_expression(entries.front().body.get())) { // print as an if statement if we can put the body in a single form. - std::vector> list; - list.push_back(toForm("if")); + std::vector list; + list.push_back(pretty_print::to_symbol("if")); list.push_back(entries.front().condition->to_form(file)); list.push_back(entries.front().body->to_form(file)); - return buildList(list); + return pretty_print::build_list(list); } else if (entries.size() == 1) { // turn into a when if the body requires multiple forms - std::vector> list; - list.push_back(toForm("when")); + std::vector list; + list.push_back(pretty_print::to_symbol("when")); list.push_back(entries.front().condition->to_form(file)); print_inlining_begin(&list, entries.front().body.get(), file); - return buildList(list); + return pretty_print::build_list(list); } else { - std::vector> list; - list.push_back(toForm("cond")); + std::vector list; + list.push_back(pretty_print::to_symbol("cond")); for (auto& e : entries) { - std::vector> entry; + std::vector entry; entry.push_back(e.condition->to_form(file)); print_inlining_begin(&entry, e.body.get(), file); - list.push_back(buildList(entry)); + list.push_back(pretty_print::build_list(entry)); } - return buildList(list); + return pretty_print::build_list(list); } } @@ -661,17 +673,17 @@ void IR_Cond::get_children(std::vector>* output) const { } } -std::shared_ptr IR_ShortCircuit::to_form(const LinkedObjectFile& file) const { - std::vector> forms; +goos::Object IR_ShortCircuit::to_form(const LinkedObjectFile& file) const { + std::vector forms; switch (kind) { case UNKNOWN: - forms.push_back(toForm("unknown-sc")); + forms.push_back(pretty_print::to_symbol("unknown-sc")); break; case AND: - forms.push_back(toForm("and")); + forms.push_back(pretty_print::to_symbol("and")); break; case OR: - forms.push_back(toForm("or")); + forms.push_back(pretty_print::to_symbol("or")); break; default: assert(false); @@ -679,7 +691,7 @@ std::shared_ptr IR_ShortCircuit::to_form(const LinkedObjectFile& file) con for (auto& x : entries) { forms.push_back(x.condition->to_form(file)); } - return buildList(forms); + return pretty_print::build_list(forms); } void IR_ShortCircuit::get_children(std::vector>* output) const { @@ -691,8 +703,9 @@ void IR_ShortCircuit::get_children(std::vector>* output) con } } -std::shared_ptr IR_Ash::to_form(const LinkedObjectFile& file) const { - return buildList("ash", value->to_form(file), shift_amount->to_form(file)); +goos::Object IR_Ash::to_form(const LinkedObjectFile& file) const { + return pretty_print::build_list(pretty_print::to_symbol("ash"), value->to_form(file), + shift_amount->to_form(file)); } void IR_Ash::get_children(std::vector>* output) const { diff --git a/decompiler/IR/IR.h b/decompiler/IR/IR.h index aed60dc4bc..44fbe0545e 100644 --- a/decompiler/IR/IR.h +++ b/decompiler/IR/IR.h @@ -4,13 +4,13 @@ #include #include #include "decompiler/Disasm/Register.h" -#include "decompiler/util/LispPrint.h" +#include "common/goos/PrettyPrinter.h" class LinkedObjectFile; class IR { public: - virtual std::shared_ptr to_form(const LinkedObjectFile& file) const = 0; + virtual goos::Object to_form(const LinkedObjectFile& file) const = 0; std::vector> get_all_ir(LinkedObjectFile& file) const; std::string print(const LinkedObjectFile& file) const; virtual void get_children(std::vector>* output) const = 0; @@ -21,14 +21,14 @@ class IR { class IR_Failed : public IR { public: IR_Failed() = default; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; class IR_Register : public IR { public: IR_Register(Register _reg, int _instr_idx) : reg(_reg), instr_idx(_instr_idx) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; Register reg; int instr_idx = -1; @@ -49,7 +49,7 @@ class IR_Set : public IR { } kind; IR_Set(Kind _kind, std::shared_ptr _dst, std::shared_ptr _src) : kind(_kind), dst(std::move(_dst)), src(std::move(_src)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; std::shared_ptr dst, src; std::shared_ptr clobber = nullptr; @@ -61,14 +61,14 @@ class IR_Store : public IR_Set { IR_Store(Kind _kind, std::shared_ptr _dst, std::shared_ptr _src, int _size) : IR_Set(IR_Set::LOAD, std::move(_dst), std::move(_src)), kind(_kind), size(_size) {} int size; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; }; class IR_Symbol : public IR { public: explicit IR_Symbol(std::string _name) : name(std::move(_name)) {} std::string name; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -76,7 +76,7 @@ class IR_SymbolValue : public IR { public: explicit IR_SymbolValue(std::string _name) : name(std::move(_name)) {} std::string name; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -84,7 +84,7 @@ class IR_StaticAddress : public IR { public: explicit IR_StaticAddress(int _label_id) : label_id(_label_id) {} int label_id = -1; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -96,7 +96,7 @@ class IR_Load : public IR { : kind(_kind), size(_size), location(std::move(_location)) {} int size; std::shared_ptr location; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -106,7 +106,7 @@ class IR_FloatMath2 : public IR { IR_FloatMath2(Kind _kind, std::shared_ptr _arg0, std::shared_ptr _arg1) : kind(_kind), arg0(std::move(_arg0)), arg1(std::move(_arg1)) {} std::shared_ptr arg0, arg1; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -115,7 +115,7 @@ class IR_FloatMath1 : public IR { enum Kind { FLOAT_TO_INT, INT_TO_FLOAT, ABS, NEG, SQRT } kind; IR_FloatMath1(Kind _kind, std::shared_ptr _arg) : kind(_kind), arg(std::move(_arg)) {} std::shared_ptr arg; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -141,7 +141,7 @@ class IR_IntMath2 : public IR { IR_IntMath2(Kind _kind, std::shared_ptr _arg0, std::shared_ptr _arg1) : kind(_kind), arg0(std::move(_arg0)), arg1(std::move(_arg1)) {} std::shared_ptr arg0, arg1; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -150,14 +150,14 @@ class IR_IntMath1 : public IR { enum Kind { NOT, ABS } kind; IR_IntMath1(Kind _kind, std::shared_ptr _arg) : kind(_kind), arg(std::move(_arg)) {} std::shared_ptr arg; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; class IR_Call : public IR { public: IR_Call() = default; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -165,7 +165,7 @@ class IR_IntegerConstant : public IR { public: int64_t value; explicit IR_IntegerConstant(int64_t _value) : value(_value) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -183,7 +183,7 @@ struct BranchDelay { } kind; std::shared_ptr destination = nullptr, source = nullptr, source2 = nullptr; explicit BranchDelay(Kind _kind) : kind(_kind) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const; + goos::Object to_form(const LinkedObjectFile& file) const; void get_children(std::vector>* output) const; }; @@ -229,7 +229,7 @@ struct Condition { } int num_args() const; - std::shared_ptr to_form(const LinkedObjectFile& file) const; + goos::Object to_form(const LinkedObjectFile& file) const; std::shared_ptr src0, src1, clobber; void get_children(std::vector>* output) const; }; @@ -247,7 +247,7 @@ class IR_Branch : public IR { BranchDelay branch_delay; bool likely; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -257,21 +257,21 @@ class IR_Compare : public IR { Condition condition; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; class IR_Nop : public IR { public: IR_Nop() = default; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; class IR_Suspend : public IR { public: IR_Suspend() = default; - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -279,7 +279,7 @@ class IR_Begin : public IR { public: IR_Begin() = default; explicit IR_Begin(const std::vector>& _forms) : forms(std::move(_forms)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; std::vector> forms; }; @@ -288,7 +288,7 @@ class IR_WhileLoop : public IR { public: IR_WhileLoop(std::shared_ptr _condition, std::shared_ptr _body) : condition(std::move(_condition)), body(std::move(_body)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; std::shared_ptr condition, body; }; @@ -304,7 +304,7 @@ class IR_CondWithElse : public IR { std::shared_ptr else_ir; IR_CondWithElse(std::vector _entries, std::shared_ptr _else_ir) : entries(std::move(_entries)), else_ir(std::move(_else_ir)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -319,7 +319,7 @@ class IR_Cond : public IR { }; std::vector entries; explicit IR_Cond(std::vector _entries) : entries(std::move(_entries)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -329,7 +329,7 @@ class IR_GetRuntimeType : public IR { std::shared_ptr object, clobber; IR_GetRuntimeType(std::shared_ptr _object, std::shared_ptr _clobber) : object(std::move(_object)), clobber(std::move(_clobber)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -345,7 +345,7 @@ class IR_ShortCircuit : public IR { std::vector entries; explicit IR_ShortCircuit(std::vector _entries) : entries(std::move(_entries)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; }; @@ -358,7 +358,7 @@ class IR_Ash : public IR { : shift_amount(std::move(_shift_amount)), value(std::move(_value)), clobber(std::move(_clobber)) {} - std::shared_ptr to_form(const LinkedObjectFile& file) const override; + goos::Object to_form(const LinkedObjectFile& file) const override; void get_children(std::vector>* output) const override; };