| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/OwnPtr.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  | #include <AK/SinglyLinkedList.h>
 | 
					
						
							| 
									
										
										
										
											2023-09-01 16:53:55 +02:00
										 |  |  | #include <LibJS/AST.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  | #include <LibJS/Bytecode/BasicBlock.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-12 19:54:08 +03:30
										 |  |  | #include <LibJS/Bytecode/CodeGenerationError.h>
 | 
					
						
							| 
									
										
										
										
											2021-10-24 13:30:49 +02:00
										 |  |  | #include <LibJS/Bytecode/Executable.h>
 | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  | #include <LibJS/Bytecode/IdentifierTable.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-04 12:07:38 +02:00
										 |  |  | #include <LibJS/Bytecode/Label.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-11 01:35:01 +04:30
										 |  |  | #include <LibJS/Bytecode/Op.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-09 00:50:42 +02:00
										 |  |  | #include <LibJS/Bytecode/Register.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-09 10:02:01 +02:00
										 |  |  | #include <LibJS/Bytecode/StringTable.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | #include <LibJS/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-11 00:46:07 +03:30
										 |  |  | #include <LibJS/Runtime/FunctionKind.h>
 | 
					
						
							| 
									
										
										
										
											2023-07-13 10:49:07 +02:00
										 |  |  | #include <LibRegex/Regex.h>
 | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace JS::Bytecode { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Generator { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-02-12 19:48:45 +03:30
										 |  |  |     enum class SurroundingScopeKind { | 
					
						
							|  |  |  |         Global, | 
					
						
							|  |  |  |         Function, | 
					
						
							|  |  |  |         Block, | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2023-10-03 08:18:10 +02:00
										 |  |  |     static CodeGenerationErrorOr<NonnullRefPtr<Executable>> generate(ASTNode const&, FunctionKind = FunctionKind::Normal); | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Register allocate_register(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-01 16:53:55 +02:00
										 |  |  |     class SourceLocationScope { | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         SourceLocationScope(Generator&, ASTNode const& node); | 
					
						
							|  |  |  |         ~SourceLocationScope(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         Generator& m_generator; | 
					
						
							|  |  |  |         ASTNode const* m_previous_node { nullptr }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-19 23:18:54 +02:00
										 |  |  |     class UnwindContext { | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         UnwindContext(Generator&, Optional<Label> finalizer); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         UnwindContext const* previous() const { return m_previous_context; } | 
					
						
							|  |  |  |         void set_handler(Label handler) { m_handler = handler; } | 
					
						
							|  |  |  |         Optional<Label> handler() const { return m_handler; } | 
					
						
							|  |  |  |         Optional<Label> finalizer() const { return m_finalizer; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ~UnwindContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         Generator& m_generator; | 
					
						
							|  |  |  |         Optional<Label> m_finalizer; | 
					
						
							|  |  |  |         Optional<Label> m_handler {}; | 
					
						
							|  |  |  |         UnwindContext const* m_previous_context { nullptr }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  |     template<typename OpType, typename... Args> | 
					
						
							| 
									
										
										
										
											2023-09-28 12:48:29 +02:00
										 |  |  |     void emit(Args&&... args) | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |         VERIFY(!is_current_block_terminated()); | 
					
						
							| 
									
										
										
										
											2023-09-28 09:29:42 +02:00
										 |  |  |         size_t slot_offset = m_current_basic_block->size(); | 
					
						
							| 
									
										
										
										
											2021-06-09 00:50:42 +02:00
										 |  |  |         grow(sizeof(OpType)); | 
					
						
							| 
									
										
										
										
											2023-09-28 09:29:42 +02:00
										 |  |  |         void* slot = m_current_basic_block->data() + slot_offset; | 
					
						
							| 
									
										
										
										
											2021-06-09 00:50:42 +02:00
										 |  |  |         new (slot) OpType(forward<Args>(args)...); | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |         if constexpr (OpType::IsTerminator) | 
					
						
							| 
									
										
										
										
											2023-09-28 09:29:42 +02:00
										 |  |  |             m_current_basic_block->terminate({}); | 
					
						
							| 
									
										
										
										
											2023-09-01 16:53:55 +02:00
										 |  |  |         auto* op = static_cast<OpType*>(slot); | 
					
						
							|  |  |  |         op->set_source_record({ m_current_ast_node->start_offset(), m_current_ast_node->end_offset() }); | 
					
						
							| 
									
										
										
										
											2021-06-07 15:12:43 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     template<typename OpType, typename... Args> | 
					
						
							| 
									
										
										
										
											2023-09-28 12:29:50 +02:00
										 |  |  |     void emit_with_extra_register_slots(size_t extra_register_slots, Args&&... args) | 
					
						
							| 
									
										
										
										
											2021-06-07 15:12:43 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |         VERIFY(!is_current_block_terminated()); | 
					
						
							| 
									
										
										
										
											2022-09-09 16:47:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         size_t size_to_allocate = round_up_to_power_of_two(sizeof(OpType) + extra_register_slots * sizeof(Register), alignof(void*)); | 
					
						
							| 
									
										
										
										
											2023-09-28 09:29:42 +02:00
										 |  |  |         size_t slot_offset = m_current_basic_block->size(); | 
					
						
							| 
									
										
										
										
											2022-09-09 16:47:42 +02:00
										 |  |  |         grow(size_to_allocate); | 
					
						
							| 
									
										
										
										
											2023-09-28 09:29:42 +02:00
										 |  |  |         void* slot = m_current_basic_block->data() + slot_offset; | 
					
						
							| 
									
										
										
										
											2021-06-09 00:50:42 +02:00
										 |  |  |         new (slot) OpType(forward<Args>(args)...); | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |         if constexpr (OpType::IsTerminator) | 
					
						
							| 
									
										
										
										
											2023-09-28 09:29:42 +02:00
										 |  |  |             m_current_basic_block->terminate({}); | 
					
						
							| 
									
										
										
										
											2023-09-01 16:53:55 +02:00
										 |  |  |         auto* op = static_cast<OpType*>(slot); | 
					
						
							|  |  |  |         op->set_source_record({ m_current_ast_node->start_offset(), m_current_ast_node->end_offset() }); | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-04 15:22:07 +02:00
										 |  |  |     struct ReferenceRegisters { | 
					
						
							|  |  |  |         Register base;                      // [[Base]]
 | 
					
						
							|  |  |  |         Optional<Register> referenced_name; // [[ReferencedName]]
 | 
					
						
							|  |  |  |         Register this_value;                // [[ThisValue]]
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CodeGenerationErrorOr<Optional<ReferenceRegisters>> emit_load_from_reference(JS::ASTNode const&); | 
					
						
							| 
									
										
										
										
											2022-02-12 19:54:08 +03:30
										 |  |  |     CodeGenerationErrorOr<void> emit_store_to_reference(JS::ASTNode const&); | 
					
						
							| 
									
										
										
										
											2023-10-04 15:22:07 +02:00
										 |  |  |     CodeGenerationErrorOr<void> emit_store_to_reference(ReferenceRegisters const&); | 
					
						
							| 
									
										
										
										
											2022-03-27 19:50:09 +01:00
										 |  |  |     CodeGenerationErrorOr<void> emit_delete_reference(JS::ASTNode const&); | 
					
						
							| 
									
										
										
										
											2021-10-25 15:16:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-06 17:02:06 -04:00
										 |  |  |     CodeGenerationErrorOr<ReferenceRegisters> emit_super_reference(MemberExpression const&); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-05 02:17:10 +02:00
										 |  |  |     void emit_set_variable(JS::Identifier const& identifier, Bytecode::Op::SetVariable::InitializationMode initialization_mode = Bytecode::Op::SetVariable::InitializationMode::Set, Bytecode::Op::EnvironmentMode mode = Bytecode::Op::EnvironmentMode::Lexical); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 10:25:05 +02:00
										 |  |  |     void push_home_object(Register); | 
					
						
							|  |  |  |     void pop_home_object(); | 
					
						
							| 
									
										
										
										
											2023-06-28 18:17:13 +02:00
										 |  |  |     void emit_new_function(JS::FunctionExpression const&, Optional<IdentifierTableIndex> lhs_name); | 
					
						
							| 
									
										
										
										
											2023-06-23 14:27:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-28 18:17:13 +02:00
										 |  |  |     CodeGenerationErrorOr<void> emit_named_evaluation_if_anonymous_function(Expression const&, Optional<IdentifierTableIndex> lhs_name); | 
					
						
							| 
									
										
										
										
											2023-06-16 10:25:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     void begin_continuable_scope(Label continue_target, Vector<DeprecatedFlyString> const& language_label_set); | 
					
						
							| 
									
										
										
										
											2021-06-06 13:33:02 +02:00
										 |  |  |     void end_continuable_scope(); | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     void begin_breakable_scope(Label breakable_target, Vector<DeprecatedFlyString> const& language_label_set); | 
					
						
							| 
									
										
										
										
											2021-06-10 20:28:43 +08:00
										 |  |  |     void end_breakable_scope(); | 
					
						
							| 
									
										
										
										
											2021-06-06 13:33:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |     [[nodiscard]] Label nearest_continuable_scope() const; | 
					
						
							| 
									
										
										
										
											2021-06-10 20:28:43 +08:00
										 |  |  |     [[nodiscard]] Label nearest_breakable_scope() const; | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  | 
 | 
					
						
							|  |  |  |     void switch_to_basic_block(BasicBlock& block) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_current_basic_block = █ | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 15:04:38 +02:00
										 |  |  |     [[nodiscard]] BasicBlock& current_block() { return *m_current_basic_block; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-26 23:57:51 -04:00
										 |  |  |     BasicBlock& make_block(String name = {}) | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |     { | 
					
						
							|  |  |  |         if (name.is_empty()) | 
					
						
							| 
									
										
										
										
											2023-10-26 23:57:51 -04:00
										 |  |  |             name = MUST(String::number(m_next_block++)); | 
					
						
							| 
									
										
										
										
											2023-10-19 23:18:54 +02:00
										 |  |  |         auto block = BasicBlock::create(name); | 
					
						
							|  |  |  |         if (auto const* context = m_current_unwind_context) { | 
					
						
							|  |  |  |             if (context->handler().has_value()) | 
					
						
							|  |  |  |                 block->set_handler(context->handler().value().block()); | 
					
						
							|  |  |  |             if (m_current_unwind_context->finalizer().has_value()) | 
					
						
							|  |  |  |                 block->set_finalizer(context->finalizer().value().block()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         m_root_basic_blocks.append(move(block)); | 
					
						
							| 
									
										
										
										
											2023-03-06 17:16:25 +01:00
										 |  |  |         return *m_root_basic_blocks.last(); | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool is_current_block_terminated() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_current_basic_block->is_terminated(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-06-06 13:33:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     StringTableIndex intern_string(DeprecatedString string) | 
					
						
							| 
									
										
										
										
											2021-06-09 10:02:01 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2021-10-24 15:14:14 +02:00
										 |  |  |         return m_string_table->insert(move(string)); | 
					
						
							| 
									
										
										
										
											2021-06-09 10:02:01 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-13 10:49:07 +02:00
										 |  |  |     RegexTableIndex intern_regex(ParsedRegex regex) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return m_regex_table->insert(move(regex)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |     IdentifierTableIndex intern_identifier(DeprecatedFlyString string) | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         return m_identifier_table->insert(move(string)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-14 21:44:36 +01:00
										 |  |  |     bool is_in_generator_or_async_function() const { return m_enclosing_function_kind == FunctionKind::Async || m_enclosing_function_kind == FunctionKind::Generator || m_enclosing_function_kind == FunctionKind::AsyncGenerator; } | 
					
						
							|  |  |  |     bool is_in_generator_function() const { return m_enclosing_function_kind == FunctionKind::Generator || m_enclosing_function_kind == FunctionKind::AsyncGenerator; } | 
					
						
							|  |  |  |     bool is_in_async_function() const { return m_enclosing_function_kind == FunctionKind::Async || m_enclosing_function_kind == FunctionKind::AsyncGenerator; } | 
					
						
							| 
									
										
										
										
											2023-07-14 21:45:41 +01:00
										 |  |  |     bool is_in_async_generator_function() const { return m_enclosing_function_kind == FunctionKind::AsyncGenerator; } | 
					
						
							| 
									
										
										
										
											2021-06-11 01:38:30 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-12 19:48:45 +03:30
										 |  |  |     enum class BindingMode { | 
					
						
							|  |  |  |         Lexical, | 
					
						
							|  |  |  |         Var, | 
					
						
							|  |  |  |         Global, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     struct LexicalScope { | 
					
						
							|  |  |  |         SurroundingScopeKind kind; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 16:34:47 +02:00
										 |  |  |     void block_declaration_instantiation(ScopeNode const&); | 
					
						
							| 
									
										
										
										
											2022-03-14 02:34:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 16:34:47 +02:00
										 |  |  |     void begin_variable_scope(); | 
					
						
							| 
									
										
										
										
											2022-03-14 02:34:01 +00:00
										 |  |  |     void end_variable_scope(); | 
					
						
							| 
									
										
										
										
											2022-02-12 19:48:45 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-13 11:51:02 +03:30
										 |  |  |     enum class BlockBoundaryType { | 
					
						
							|  |  |  |         Break, | 
					
						
							|  |  |  |         Continue, | 
					
						
							|  |  |  |         Unwind, | 
					
						
							| 
									
										
										
										
											2022-11-13 20:56:53 +01:00
										 |  |  |         ReturnToFinally, | 
					
						
							| 
									
										
										
										
											2022-03-14 02:34:01 +00:00
										 |  |  |         LeaveLexicalEnvironment, | 
					
						
							| 
									
										
										
										
											2022-03-13 11:51:02 +03:30
										 |  |  |     }; | 
					
						
							|  |  |  |     template<typename OpType> | 
					
						
							| 
									
										
										
										
											2022-11-25 16:42:29 +01:00
										 |  |  |     void perform_needed_unwinds() | 
					
						
							|  |  |  |     requires(OpType::IsTerminator && !IsSame<OpType, Op::Jump>) | 
					
						
							| 
									
										
										
										
											2022-03-13 11:51:02 +03:30
										 |  |  |     { | 
					
						
							|  |  |  |         for (size_t i = m_boundaries.size(); i > 0; --i) { | 
					
						
							|  |  |  |             auto boundary = m_boundaries[i - 1]; | 
					
						
							| 
									
										
										
										
											2022-11-13 20:56:53 +01:00
										 |  |  |             using enum BlockBoundaryType; | 
					
						
							|  |  |  |             switch (boundary) { | 
					
						
							|  |  |  |             case Unwind: | 
					
						
							| 
									
										
										
										
											2022-11-25 16:42:29 +01:00
										 |  |  |                 if constexpr (IsSame<OpType, Bytecode::Op::Throw>) | 
					
						
							|  |  |  |                     return; | 
					
						
							| 
									
										
										
										
											2022-03-13 11:51:02 +03:30
										 |  |  |                 emit<Bytecode::Op::LeaveUnwindContext>(); | 
					
						
							| 
									
										
										
										
											2022-11-13 20:56:53 +01:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case LeaveLexicalEnvironment: | 
					
						
							| 
									
										
										
										
											2023-06-16 16:43:24 +02:00
										 |  |  |                 emit<Bytecode::Op::LeaveLexicalEnvironment>(); | 
					
						
							| 
									
										
										
										
											2022-11-13 20:56:53 +01:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             case Break: | 
					
						
							|  |  |  |             case Continue: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case ReturnToFinally: | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             }; | 
					
						
							| 
									
										
										
										
											2022-03-13 11:51:02 +03:30
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-25 16:15:34 +01:00
										 |  |  |     void generate_break(); | 
					
						
							|  |  |  |     void generate_break(DeprecatedFlyString const& break_label); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-25 16:35:39 +01:00
										 |  |  |     void generate_continue(); | 
					
						
							|  |  |  |     void generate_continue(DeprecatedFlyString const& continue_label); | 
					
						
							| 
									
										
										
										
											2022-06-11 23:09:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-13 11:51:02 +03:30
										 |  |  |     void start_boundary(BlockBoundaryType type) { m_boundaries.append(type); } | 
					
						
							|  |  |  |     void end_boundary(BlockBoundaryType type) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         VERIFY(m_boundaries.last() == type); | 
					
						
							|  |  |  |         m_boundaries.take_last(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-08 17:43:26 +02:00
										 |  |  |     void emit_get_by_id(IdentifierTableIndex); | 
					
						
							|  |  |  |     void emit_get_by_id_with_this(IdentifierTableIndex, Register); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-12 04:06:59 +02:00
										 |  |  |     [[nodiscard]] size_t next_global_variable_cache() { return m_next_global_variable_cache++; } | 
					
						
							| 
									
										
										
										
											2023-10-26 10:39:40 +02:00
										 |  |  |     [[nodiscard]] size_t next_environment_variable_cache() { return m_next_environment_variable_cache++; } | 
					
						
							| 
									
										
										
										
											2023-07-12 04:06:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2023-07-19 19:44:10 +12:00
										 |  |  |     enum class JumpType { | 
					
						
							|  |  |  |         Continue, | 
					
						
							|  |  |  |         Break, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     void generate_scoped_jump(JumpType); | 
					
						
							| 
									
										
										
										
											2023-07-19 20:06:25 +12:00
										 |  |  |     void generate_labelled_jump(JumpType, DeprecatedFlyString const& label); | 
					
						
							| 
									
										
										
										
											2023-07-19 19:44:10 +12:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  |     Generator(); | 
					
						
							| 
									
										
										
										
											2022-03-14 10:25:06 -06:00
										 |  |  |     ~Generator() = default; | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-09 00:50:42 +02:00
										 |  |  |     void grow(size_t); | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-11 23:09:37 +01:00
										 |  |  |     struct LabelableScope { | 
					
						
							|  |  |  |         Label bytecode_target; | 
					
						
							| 
									
										
										
										
											2023-01-08 19:23:00 -05:00
										 |  |  |         Vector<DeprecatedFlyString> language_label_set; | 
					
						
							| 
									
										
										
										
											2022-06-11 23:09:37 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |     BasicBlock* m_current_basic_block { nullptr }; | 
					
						
							| 
									
										
										
										
											2023-09-01 16:53:55 +02:00
										 |  |  |     ASTNode const* m_current_ast_node { nullptr }; | 
					
						
							| 
									
										
										
										
											2023-10-19 23:18:54 +02:00
										 |  |  |     UnwindContext const* m_current_unwind_context { nullptr }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-06 17:16:25 +01:00
										 |  |  |     Vector<NonnullOwnPtr<BasicBlock>> m_root_basic_blocks; | 
					
						
							| 
									
										
										
										
											2021-06-09 10:02:01 +02:00
										 |  |  |     NonnullOwnPtr<StringTable> m_string_table; | 
					
						
							| 
									
										
										
										
											2021-10-24 15:34:30 +02:00
										 |  |  |     NonnullOwnPtr<IdentifierTable> m_identifier_table; | 
					
						
							| 
									
										
										
										
											2023-07-13 10:49:07 +02:00
										 |  |  |     NonnullOwnPtr<RegexTable> m_regex_table; | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-26 14:42:30 +02:00
										 |  |  |     u32 m_next_register { Register::reserved_register_count }; | 
					
						
							| 
									
										
										
										
											2021-06-09 06:49:58 +04:30
										 |  |  |     u32 m_next_block { 1 }; | 
					
						
							| 
									
										
										
										
											2023-07-08 17:43:26 +02:00
										 |  |  |     u32 m_next_property_lookup_cache { 0 }; | 
					
						
							| 
									
										
										
										
											2023-07-12 04:06:59 +02:00
										 |  |  |     u32 m_next_global_variable_cache { 0 }; | 
					
						
							| 
									
										
										
										
											2023-10-26 10:39:40 +02:00
										 |  |  |     u32 m_next_environment_variable_cache { 0 }; | 
					
						
							| 
									
										
										
										
											2022-01-15 00:30:02 +01:00
										 |  |  |     FunctionKind m_enclosing_function_kind { FunctionKind::Normal }; | 
					
						
							| 
									
										
										
										
											2022-06-11 23:09:37 +01:00
										 |  |  |     Vector<LabelableScope> m_continuable_scopes; | 
					
						
							|  |  |  |     Vector<LabelableScope> m_breakable_scopes; | 
					
						
							| 
									
										
										
										
											2022-03-13 11:51:02 +03:30
										 |  |  |     Vector<BlockBoundaryType> m_boundaries; | 
					
						
							| 
									
										
										
										
											2023-06-16 10:25:05 +02:00
										 |  |  |     Vector<Register> m_home_objects; | 
					
						
							| 
									
										
										
										
											2021-06-03 10:46:30 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |