1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

Userland: Replace VERIFY(is<T>) with verify_cast<T>

Instead of doing a VERIFY(is<T>(x)) and *then* casting it to T, we can
just do the cast right away with verify_cast<T>. :^)
This commit is contained in:
Andreas Kling 2021-06-24 21:13:09 +02:00
parent 7fef8c5648
commit e59bf87374
10 changed files with 26 additions and 43 deletions

View file

@ -244,8 +244,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj
return {};
auto& this_er = get_this_environment(interpreter.vm());
VERIFY(is<FunctionEnvironmentRecord>(this_er));
static_cast<FunctionEnvironmentRecord&>(this_er).bind_this_value(global_object, result);
verify_cast<FunctionEnvironmentRecord>(this_er).bind_this_value(global_object, result);
} else {
result = vm.call(function, this_value, move(arguments));
}
@ -1776,10 +1775,9 @@ void MemberExpression::dump(int indent) const
PropertyName MemberExpression::computed_property_name(Interpreter& interpreter, GlobalObject& global_object) const
{
if (!is_computed()) {
VERIFY(is<Identifier>(*m_property));
return static_cast<Identifier const&>(*m_property).string();
}
if (!is_computed())
return verify_cast<Identifier>(*m_property).string();
auto value = m_property->execute(interpreter, global_object);
if (interpreter.exception())
return {};
@ -1794,8 +1792,7 @@ String MemberExpression::to_string_approximation() const
object_string = static_cast<Identifier const&>(*m_object).string();
if (is_computed())
return String::formatted("{}[<computed>]", object_string);
VERIFY(is<Identifier>(*m_property));
return String::formatted("{}.{}", object_string, static_cast<Identifier const&>(*m_property).string());
return String::formatted("{}.{}", object_string, verify_cast<Identifier>(*m_property).string());
}
Value MemberExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const