mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibJS: Implement standard semantics for relational operators (#2417)
Previously, the relational operators where casting any value to double and comparing the results according to C++ semantics. This patch makes the relational operators in JS behave according to the standard specification. Since we don't have BigInt yet, the implementation doesn't take it into account. Moved PreferredType from Object to Value. Value::to_primitive now passes preferred_type to Object::to_primitive.
This commit is contained in:
committed by
GitHub
parent
cbe506020b
commit
eadce65e04
@@ -97,14 +97,8 @@ public:
|
||||
void set_prototype(Object*);
|
||||
bool has_prototype(const Object* prototype) const;
|
||||
|
||||
enum class PreferredType {
|
||||
Default,
|
||||
String,
|
||||
Number,
|
||||
};
|
||||
|
||||
virtual Value value_of() const { return Value(const_cast<Object*>(this)); }
|
||||
virtual Value to_primitive(PreferredType preferred_type = PreferredType::Default) const;
|
||||
virtual Value to_primitive(Value::PreferredType preferred_type = Value::PreferredType::Default) const;
|
||||
virtual Value to_string() const;
|
||||
|
||||
Value get_direct(size_t index) const { return m_storage[index]; }
|
||||
|
||||
Reference in New Issue
Block a user