summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/Value.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-12-06 16:55:19 +0000
committerAndreas Kling <kling@serenityos.org>2020-12-06 18:52:52 +0100
commit5eb1f752ab1db98d3825320f20e4a543b71bffe6 (patch)
tree9dcf8874abc6ceec0f1e596c05d0928d27616deb /Libraries/LibJS/Runtime/Value.cpp
parent2313e583930bd0bd8eeec18afc8d72c4b8350093 (diff)
downloadserenity-5eb1f752ab1db98d3825320f20e4a543b71bffe6.zip
LibJS: Use new format functions everywhere
This changes the remaining uses of the following functions across LibJS: - String::format() => String::formatted() - dbg() => dbgln() - printf() => out(), outln() - fprintf() => warnln() I also removed the relevant 'LogStream& operator<<' overloads as they're not needed anymore.
Diffstat (limited to 'Libraries/LibJS/Runtime/Value.cpp')
-rw-r--r--Libraries/LibJS/Runtime/Value.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/Libraries/LibJS/Runtime/Value.cpp b/Libraries/LibJS/Runtime/Value.cpp
index eb00a5116e..4822aae8e5 100644
--- a/Libraries/LibJS/Runtime/Value.cpp
+++ b/Libraries/LibJS/Runtime/Value.cpp
@@ -118,7 +118,8 @@ String Value::to_string_without_side_effects() const
return is_negative_infinity() ? "-Infinity" : "Infinity";
if (is_integer())
return String::number(as_i32());
- return String::format("%.4f", m_value.as_double);
+ // FIXME: This should be more sophisticated: don't cut off decimals, don't include trailing zeros
+ return String::formatted("{:.4}", m_value.as_double);
case Type::String:
return m_value.as_string->string();
case Type::Symbol:
@@ -162,7 +163,8 @@ String Value::to_string(GlobalObject& global_object, bool legacy_null_to_empty_s
return is_negative_infinity() ? "-Infinity" : "Infinity";
if (is_integer())
return String::number(as_i32());
- return String::format("%.4f", m_value.as_double);
+ // FIXME: This should be more sophisticated: don't cut off decimals, don't include trailing zeros
+ return String::formatted("{:.4}", m_value.as_double);
case Type::String:
return m_value.as_string->string();
case Type::Symbol:
@@ -237,7 +239,7 @@ Object* Value::to_object(GlobalObject& global_object) const
case Type::Object:
return &const_cast<Object&>(as_object());
default:
- dbg() << "Dying because I can't to_object() on " << *this;
+ dbgln("Dying because I can't to_object() on {}", *this);
ASSERT_NOT_REACHED();
}
}
@@ -822,11 +824,6 @@ Value ordinary_has_instance(GlobalObject& global_object, Value lhs, Value rhs)
}
}
-const LogStream& operator<<(const LogStream& stream, const Value& value)
-{
- return stream << (value.is_empty() ? "<empty>" : value.to_string_without_side_effects());
-}
-
bool same_value(Value lhs, Value rhs)
{
if (lhs.type() != rhs.type())