diff --git a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp index c2c4a02303..c8452c8da5 100644 --- a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp +++ b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp @@ -63,8 +63,7 @@ void MallocTracer::target_did_malloc(Badge, FlatPtr address, size_t si return; auto* region = m_emulator.mmu().find_region({ 0x23, address }); VERIFY(region); - VERIFY(is(*region)); - auto& mmap_region = static_cast(*region); + auto& mmap_region = verify_cast(*region); auto* shadow_bits = mmap_region.shadow_data() + address - mmap_region.base(); memset(shadow_bits, 0, size); @@ -93,8 +92,7 @@ void MallocTracer::target_did_change_chunk_size(Badge, FlatPtr block, return; auto* region = m_emulator.mmu().find_region({ 0x23, block }); VERIFY(region); - VERIFY(is(*region)); - auto& mmap_region = static_cast(*region); + auto& mmap_region = verify_cast(*region); update_metadata(mmap_region, chunk_size); } @@ -153,8 +151,7 @@ void MallocTracer::target_did_realloc(Badge, FlatPtr address, size_t s return; auto* region = m_emulator.mmu().find_region({ 0x23, address }); VERIFY(region); - VERIFY(is(*region)); - auto& mmap_region = static_cast(*region); + auto& mmap_region = verify_cast(*region); VERIFY(mmap_region.is_malloc_block()); diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp index 67bc3a6e8f..c2442028ac 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp @@ -61,8 +61,7 @@ void SoftMMU::ensure_split_at(X86::LogicalAddress address) // If we get here, we know that the page exists and belongs to a region, that there is // a previous page, and that it belongs to the same region. - VERIFY(is(m_page_to_region_map[page_index])); - auto* old_region = static_cast(m_page_to_region_map[page_index]); + auto* old_region = verify_cast(m_page_to_region_map[page_index]); //dbgln("splitting at {:p}", address.offset()); //dbgln(" old region: {:p}-{:p}", old_region->base(), old_region->end() - 1); diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index cebea7d1d1..c523381556 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -244,8 +244,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj return {}; auto& this_er = get_this_environment(interpreter.vm()); - VERIFY(is(this_er)); - static_cast(this_er).bind_this_value(global_object, result); + verify_cast(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(*m_property)); - return static_cast(*m_property).string(); - } + if (!is_computed()) + return verify_cast(*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(*m_object).string(); if (is_computed()) return String::formatted("{}[]", object_string); - VERIFY(is(*m_property)); - return String::formatted("{}.{}", object_string, static_cast(*m_property).string()); + return String::formatted("{}.{}", object_string, verify_cast(*m_property).string()); } Value MemberExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index a6029f20cc..936faf86ee 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -390,9 +390,8 @@ void AssignmentExpression::generate_bytecode(Bytecode::Generator& generator) con m_rhs->generate_bytecode(generator); generator.emit(object_reg, property_reg); } else { - VERIFY(is(expression.property())); m_rhs->generate_bytecode(generator); - auto identifier_table_ref = generator.intern_string(static_cast(expression.property()).string()); + auto identifier_table_ref = generator.intern_string(verify_cast(expression.property()).string()); generator.emit(object_reg, identifier_table_ref); } return; @@ -628,8 +627,7 @@ void MemberExpression::generate_bytecode(Bytecode::Generator& generator) const property().generate_bytecode(generator); generator.emit(object_reg); } else { - VERIFY(is(property())); - auto identifier_table_ref = generator.intern_string(static_cast(property()).string()); + auto identifier_table_ref = generator.intern_string(verify_cast(property()).string()); generator.emit(identifier_table_ref); } } diff --git a/Userland/Libraries/LibJS/Interpreter.cpp b/Userland/Libraries/LibJS/Interpreter.cpp index fda2d1af0d..01cc133c0c 100644 --- a/Userland/Libraries/LibJS/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Interpreter.cpp @@ -200,8 +200,7 @@ Value Interpreter::execute_statement(GlobalObject& global_object, const Statemen FunctionEnvironmentRecord* Interpreter::current_function_environment_record() { - VERIFY(is(vm().running_execution_context().lexical_environment)); - return static_cast(vm().running_execution_context().lexical_environment); + return verify_cast(vm().running_execution_context().lexical_environment); } } diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index 55cd4070dd..38e4a8e19b 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -193,8 +193,7 @@ EnvironmentRecord& get_this_environment(VM& vm) Object* get_super_constructor(VM& vm) { auto& env = get_this_environment(vm); - VERIFY(is(env)); - auto& active_function = static_cast(env).function_object(); + auto& active_function = verify_cast(env).function_object(); auto* super_constructor = active_function.prototype(); return super_constructor; } diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index cd6fd9f65c..80427df7c0 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -459,8 +459,7 @@ Value VM::construct(Function& function, Function& new_target, Optional(lexical_environment())); - static_cast(lexical_environment())->replace_this_binding(result); + verify_cast(lexical_environment())->replace_this_binding(result); } auto prototype = new_target.get(names.prototype); if (exception()) @@ -502,8 +501,7 @@ String VM::join_arguments(size_t start_index) const Value VM::get_new_target() { auto& env = get_this_environment(*this); - VERIFY(is(env)); - return static_cast(env).new_target(); + return verify_cast(env).new_target(); } Value VM::call_internal(Function& function, Value this_value, Optional arguments) diff --git a/Userland/Libraries/LibRegex/RegexByteCode.h b/Userland/Libraries/LibRegex/RegexByteCode.h index df5207877d..4ab85fd967 100644 --- a/Userland/Libraries/LibRegex/RegexByteCode.h +++ b/Userland/Libraries/LibRegex/RegexByteCode.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -720,31 +721,27 @@ ALWAYS_INLINE bool is(const OpCode& opcode) } template -ALWAYS_INLINE const T& to(const OpCode& opcode) +ALWAYS_INLINE T const& to(OpCode const& opcode) { - VERIFY(is(opcode)); - return static_cast(opcode); + return verify_cast(opcode); } template ALWAYS_INLINE T* to(OpCode* opcode) { - VERIFY(is(opcode)); - return static_cast(opcode); + return verify_cast(opcode); } template -ALWAYS_INLINE const T* to(const OpCode* opcode) +ALWAYS_INLINE T const* to(OpCode const* opcode) { - VERIFY(is(opcode)); - return static_cast(opcode); + return verify_cast(opcode); } template ALWAYS_INLINE T& to(OpCode& opcode) { - VERIFY(is(opcode)); - return static_cast(opcode); + return verify_cast(opcode); } } diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index d30ca56b7d..8d806c6bd3 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -450,13 +450,13 @@ void dump_sheet(const CSS::StyleSheet& sheet) dbgln("{}", builder.string_view()); } -void dump_sheet(StringBuilder& builder, const CSS::StyleSheet& sheet) +void dump_sheet(StringBuilder& builder, CSS::StyleSheet const& sheet) { - VERIFY(is(sheet)); + auto& css_stylesheet = verify_cast(sheet); - builder.appendff("CSSStyleSheet{{{}}}: {} rule(s)\n", &sheet, static_cast(sheet).rules().size()); + builder.appendff("CSSStyleSheet{{{}}}: {} rule(s)\n", &sheet, css_stylesheet.rules().size()); - for (auto& rule : static_cast(sheet).rules()) { + for (auto& rule : css_stylesheet.rules()) { dump_rule(builder, rule); } } diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index 89e3f836fa..8e6065deb6 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -276,7 +276,6 @@ void FrameLoader::resource_did_load() if (auto* host_element = browsing_context().host_element()) { // FIXME: Perhaps in the future we'll have a better common base class for and