mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:02:43 +00:00 
			
		
		
		
	 216e21a1fa
			
		
	
	
		216e21a1fa
		
	
	
	
	
		
			
			This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			698 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			698 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Format.h>
 | |
| #include <LibJS/Bytecode/BasicBlock.h>
 | |
| 
 | |
| namespace JS::Bytecode {
 | |
| 
 | |
| class Label {
 | |
| public:
 | |
|     explicit Label(BasicBlock const& block)
 | |
|         : m_block(&block)
 | |
|     {
 | |
|     }
 | |
| 
 | |
|     auto& block() const { return *m_block; }
 | |
| 
 | |
| private:
 | |
|     BasicBlock const* m_block { nullptr };
 | |
| };
 | |
| 
 | |
| }
 | |
| 
 | |
| template<>
 | |
| struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
 | |
|     ErrorOr<void> format(FormatBuilder& builder, JS::Bytecode::Label const& value)
 | |
|     {
 | |
|         return AK::Formatter<FormatString>::format(builder, "@{}", value.block().name());
 | |
|     }
 | |
| };
 |