#pragma once #include #include #include "decompiler/IR/IR.h" #include "decompiler/Disasm/Register.h" #include "decompiler/util/TP_Type.h" namespace decompiler { /*! * 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 value, bool sequence_point); void add_no_set(std::shared_ptr value, bool sequence_point); std::shared_ptr get(Register reg); bool is_single_expression(); std::string print(LinkedObjectFile& file); std::vector> get_result(); private: struct StackEntry { bool display = true; // should this appear in the output? std::optional destination; // what register we are setting (or nullopt if no dest.) std::shared_ptr source; // the value we are setting the register to. bool sequence_point = false; // TP_Type type; std::string print(LinkedObjectFile& file); }; std::vector m_stack; bool display_stack_empty(); StackEntry& get_display_stack_top(); }; } // namespace decompiler