| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2021, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  | #include <AK/DeprecatedFlyString.h>
 | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  | #include <AK/DistinctNumeric.h>
 | 
					
						
							|  |  |  | #include <AK/Vector.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace JS::Bytecode { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-06 10:12:02 +02:00
										 |  |  | struct IdentifierTableIndex { | 
					
						
							|  |  |  |     bool is_valid() const { return value != NumericLimits<u32>::max(); } | 
					
						
							|  |  |  |     u32 value { 0 }; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class IdentifierTable { | 
					
						
							|  |  |  |     AK_MAKE_NONMOVABLE(IdentifierTable); | 
					
						
							|  |  |  |     AK_MAKE_NONCOPYABLE(IdentifierTable); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     IdentifierTable() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     IdentifierTableIndex insert(DeprecatedFlyString); | 
					
						
							|  |  |  |     DeprecatedFlyString const& get(IdentifierTableIndex) const; | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  |     void dump() const; | 
					
						
							|  |  |  |     bool is_empty() const { return m_identifiers.is_empty(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     Vector<DeprecatedFlyString> m_identifiers; | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |