2020-04-04 23:13:13 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
2020-04-04 23:13:13 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-04 23:13:13 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2025-07-19 13:49:30 -07:00
|
|
|
#include <LibJS/Export.h>
|
2020-04-04 23:13:13 +02:00
|
|
|
#include <LibJS/Runtime/Object.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2025-07-19 13:49:30 -07:00
|
|
|
class JS_API NumberObject : public Object {
|
2020-06-21 15:14:02 +02:00
|
|
|
JS_OBJECT(NumberObject, Object);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(NumberObject);
|
2020-06-21 15:14:02 +02:00
|
|
|
|
2020-04-04 23:13:13 +02:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
static GC::Ref<NumberObject> create(Realm&, double);
|
2020-04-17 18:55:53 +02:00
|
|
|
|
2022-03-14 10:25:06 -06:00
|
|
|
virtual ~NumberObject() override = default;
|
2020-04-04 23:13:13 +02:00
|
|
|
|
2020-07-14 15:26:15 -07:00
|
|
|
double number() const { return m_value; }
|
|
|
|
|
2022-08-28 23:51:28 +02:00
|
|
|
protected:
|
|
|
|
NumberObject(double, Object& prototype);
|
|
|
|
|
2020-04-04 23:13:13 +02:00
|
|
|
private:
|
2025-03-25 08:34:06 +00:00
|
|
|
virtual bool is_number_object() const final { return true; }
|
|
|
|
|
2020-04-04 23:13:13 +02:00
|
|
|
double m_value { 0 };
|
|
|
|
};
|
|
|
|
|
2025-03-25 08:34:06 +00:00
|
|
|
template<>
|
|
|
|
inline bool Object::fast_is<NumberObject>() const { return is_number_object(); }
|
|
|
|
|
2020-04-04 23:13:13 +02:00
|
|
|
}
|