mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibJS/Bytecode: Make Generator aware of the function it's compiling
This commit is contained in:
parent
59c2637fdc
commit
9d57b55f24
Notes:
sideshowbarker
2024-07-17 03:00:02 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9d57b55f24 Pull-request: https://github.com/SerenityOS/serenity/pull/24504
@ -17,7 +17,7 @@
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
Generator::Generator(VM& vm, MustPropagateCompletion must_propagate_completion)
|
||||
Generator::Generator(VM& vm, GCPtr<ECMAScriptFunctionObject const> function, MustPropagateCompletion must_propagate_completion)
|
||||
: m_vm(vm)
|
||||
, m_string_table(make<StringTable>())
|
||||
, m_identifier_table(make<IdentifierTable>())
|
||||
@ -25,6 +25,7 @@ Generator::Generator(VM& vm, MustPropagateCompletion must_propagate_completion)
|
||||
, m_constants(vm.heap())
|
||||
, m_accumulator(*this, Operand(Register::accumulator()))
|
||||
, m_must_propagate_completion(must_propagate_completion == MustPropagateCompletion::Yes)
|
||||
, m_function(function)
|
||||
{
|
||||
}
|
||||
|
||||
@ -199,7 +200,7 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
|
||||
|
||||
CodeGenerationErrorOr<NonnullGCPtr<Executable>> Generator::compile(VM& vm, ASTNode const& node, FunctionKind enclosing_function_kind, GCPtr<ECMAScriptFunctionObject const> function, MustPropagateCompletion must_propagate_completion)
|
||||
{
|
||||
Generator generator(vm, must_propagate_completion);
|
||||
Generator generator(vm, function, must_propagate_completion);
|
||||
|
||||
generator.switch_to_basic_block(generator.make_block());
|
||||
SourceLocationScope scope(generator, node);
|
||||
|
@ -353,7 +353,7 @@ private:
|
||||
void generate_scoped_jump(JumpType);
|
||||
void generate_labelled_jump(JumpType, DeprecatedFlyString const& label);
|
||||
|
||||
Generator(VM&, MustPropagateCompletion);
|
||||
Generator(VM&, GCPtr<ECMAScriptFunctionObject const>, MustPropagateCompletion);
|
||||
~Generator() = default;
|
||||
|
||||
void grow(size_t);
|
||||
@ -393,6 +393,8 @@ private:
|
||||
|
||||
bool m_finished { false };
|
||||
bool m_must_propagate_completion { true };
|
||||
|
||||
GCPtr<ECMAScriptFunctionObject const> m_function;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user