feat(furvm): introduce comparison operators

This commit is contained in:
2026-06-15 00:06:50 +02:00
parent eec25e3aea
commit 8dfc880c07
4 changed files with 181 additions and 2 deletions
+30
View File
@@ -65,6 +65,36 @@ enum class instruction_t : byte {
*/
Mod,
/**
* @brief Compares two top-most things from the stack for equality.
*/
Equals,
/**
* @brief Compares two top-most things from the stack for inequality.
*/
NotEquals,
/**
* @brief Compares if the first top-most thing is less than the second top-most thing.
*/
LessThan,
/**
* @brief Compares if the first top-most thing is greater than the second top-most thing.
*/
GreaterThan,
/**
* @brief Compares if the first top-most thing is less than or equal to the second top-most thing.
*/
LessEqual,
/**
* @brief Compares if the first top-most thing is greater than or equal to the second top-most thing.
*/
GreaterEqual,
/**
* @brief Pushes a variable onto the stack.
*
+54 -1
View File
@@ -135,6 +135,59 @@ public:
* @return Shared pointer to result thing.
*/
friend thing_p operator%(const thing_p& lhs, const thing_p& rhs);
/**
* @brief Compares two things for equality.
*
* @param lhs Left-hand-side thing.
* @param rhs Right-hand-side thing.
* @return Shared pointer to result thing.
*/
friend thing_p operator==(const thing_p& lhs, const thing_p& rhs);
/**
* @brief Compares two things for equality.
*
* @param lhs Left-hand-side thing.
* @param rhs Right-hand-side thing.
* @return Shared pointer to result thing.
*/
friend thing_p operator!=(const thing_p& lhs, const thing_p& rhs);
/**
* @brief Compares if the left thing is less than the right thing.
*
* @param lhs Left-hand-side thing.
* @param rhs Right-hand-side thing.
* @return Shared pointer to result thing.
*/
friend thing_p operator<(const thing_p& lhs, const thing_p& rhs);
/**
* @brief Compares if the left thing is greater than the right thing.
*
* @param lhs Left-hand-side thing.
* @param rhs Right-hand-side thing.
* @return Shared pointer to result thing.
*/
friend thing_p operator>(const thing_p& lhs, const thing_p& rhs);
/**
* @brief Compares if the left thing is less than or equal to the right thing.
*
* @param lhs Left-hand-side thing.
* @param rhs Right-hand-side thing.
* @return Shared pointer to result thing.
*/
friend thing_p operator<=(const thing_p& lhs, const thing_p& rhs);
/**
* @brief Compares if the left thing is greater than or equal to the right thing.
*
* @param lhs Left-hand-side thing.
* @param rhs Right-hand-side thing.
* @return Shared pointer to result thing.
*/
friend thing_p operator>=(const thing_p& lhs, const thing_p& rhs);
public:
/**
* @brief Returns a new thing.
@@ -208,4 +261,4 @@ private:
} // namespace furvm
#endif // FURVM_THING_HPP
#endif // FURVM_THING_HPP