1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:57:44 +00:00

AK+GMLCompiler: Remove JsonValue::as_double()

Replace its single (non-test) usage with newly created as_number(),
which does not leak information about internal integer storage type.
This commit is contained in:
Dan Klishch 2023-11-14 00:49:41 -05:00 committed by Andrew Kaster
parent 5230d2af91
commit faef802229
3 changed files with 27 additions and 13 deletions

View file

@ -154,10 +154,24 @@ public:
return *m_value.as_array;
}
double as_double() const
Variant<u64, i64, double> as_number() const
{
VERIFY(is_double());
return m_value.as_double;
VERIFY(is_number());
switch (m_type) {
case Type::Int32:
return static_cast<i64>(m_value.as_i32);
case Type::UnsignedInt32:
return static_cast<i64>(m_value.as_u32);
case Type::Int64:
return m_value.as_i64;
case Type::UnsignedInt64:
return m_value.as_u64;
case Type::Double:
return m_value.as_double;
default:
VERIFY_NOT_REACHED();
}
}
Type type() const