[Decompiler] WIP Expression Stacking (#178)

* wip

* fix the stupid if thing

* update

* fix

* fix some ordering issues
This commit is contained in:
water111
2021-01-02 18:24:45 -05:00
committed by GitHub
parent feead303aa
commit 7af6dce1b2
14 changed files with 693 additions and 140 deletions
+11 -4
View File
@@ -1,14 +1,20 @@
#pragma once
#include <vector>
#include <optional>
#include "decompiler/IR/IR.h"
#include "decompiler/Disasm/Register.h"
#include "decompiler/util/TP_Type.h"
/*!
* An ExpressionStack is used to track partial expressions when rebuilding the tree structure of
* GOAL code. Linear sequences of operations are added onto the expression stack.
*/
class ExpressionStack {
public:
ExpressionStack() = default;
void set(Register reg, std::shared_ptr<IR> value);
void set(Register reg, std::shared_ptr<IR> value, bool sequence_point);
void add_no_set(std::shared_ptr<IR> value, bool sequence_point);
std::shared_ptr<IR> get(Register reg);
bool is_single_expression();
std::string print(LinkedObjectFile& file);
@@ -16,9 +22,10 @@ class ExpressionStack {
private:
struct StackEntry {
bool display = true; // should this appear in the output?
Register destination; // what register we are setting
std::shared_ptr<IR> source; // the value we are setting the register to.
bool display = true; // should this appear in the output?
std::optional<Register> destination; // what register we are setting (or nullopt if no dest.)
std::shared_ptr<IR> source; // the value we are setting the register to.
bool sequence_point = false;
// TP_Type type;
std::string print(LinkedObjectFile& file);
};