mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:28:12 +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:
parent
cbe506020b
commit
eadce65e04
5 changed files with 641 additions and 44 deletions
|
@ -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]; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue