diff --git a/common/goal_constants.h b/common/goal_constants.h index 81f5a46fb..f0cf906cd 100644 --- a/common/goal_constants.h +++ b/common/goal_constants.h @@ -37,3 +37,5 @@ constexpr double METER_LENGTH = 4096.0; constexpr double DEGREES_PER_ROT = 65536.0; constexpr double DEGREES_LENGTH = DEGREES_PER_ROT / 360.0; constexpr u64 TICKS_PER_SECOND = 300.0; + +constexpr float DEFAULT_RES_TIME = -1000000000.0; \ No newline at end of file diff --git a/decompiler/CMakeLists.txt b/decompiler/CMakeLists.txt index 83cf941bb..af05b22de 100644 --- a/decompiler/CMakeLists.txt +++ b/decompiler/CMakeLists.txt @@ -44,6 +44,7 @@ add_library( IR2/AtomicOpTypeAnalysis.cpp IR2/bitfields.cpp IR2/Env.cpp + IR2/ExpressionHelpers.cpp IR2/Form.cpp IR2/FormExpressionAnalysis.cpp IR2/FormStack.cpp diff --git a/decompiler/IR2/AtomicOp.h b/decompiler/IR2/AtomicOp.h index 4196ddf28..debee3b13 100644 --- a/decompiler/IR2/AtomicOp.h +++ b/decompiler/IR2/AtomicOp.h @@ -152,7 +152,13 @@ class SimpleAtom { bool is_int() const { return m_kind == Kind::INTEGER_CONSTANT; }; bool is_int(s64 integer) const { return is_int() && get_int() == integer; } bool is_sym_ptr() const { return m_kind == Kind::SYMBOL_PTR; }; + bool is_sym_ptr(const std::string& str) const { + return m_kind == Kind::SYMBOL_PTR && m_string == str; + } bool is_sym_val() const { return m_kind == Kind::SYMBOL_VAL; }; + bool is_sym_val(const std::string& str) const { + return m_kind == Kind::SYMBOL_VAL && m_string == str; + } bool is_empty_list() const { return m_kind == Kind::EMPTY_LIST; }; bool is_static_addr() const { return m_kind == Kind::STATIC_ADDRESS; }; Kind get_kind() const { return m_kind; } diff --git a/decompiler/IR2/ExpressionHelpers.cpp b/decompiler/IR2/ExpressionHelpers.cpp new file mode 100644 index 000000000..d2a66df64 --- /dev/null +++ b/decompiler/IR2/ExpressionHelpers.cpp @@ -0,0 +1,203 @@ +#include "ExpressionHelpers.h" +#include "decompiler/IR2/Form.h" +#include "decompiler/IR2/Env.h" +#include "common/goal_constants.h" + +namespace decompiler { + +FormElement* handle_get_property_value_float(const std::vector