Skip to content

Commit 22cc16b

Browse files
LibJS: FDI bytecode WIP
LibJS: FDI bytecode WIP CreateMappedArguments LibJS: FDI bytecode WIP CreateRestParams LibWeb: FDI bytecode WIP create variable for non-locals LibJS: FDI bytecode WIP CreateUnmappedArguments LibJS: FDI bytecode WIP fill arguments with js_undefined LibJS: FDI bytecode WIP init annexB LibJS: FDI bytecode WIP default params for bindings LibJS: FDI bytecode WIP rest hack LibJS: FDI bytecode WIP init annexB functions LibWeb: FDI bytecode WIP LibWeb: FDI bytecode WIP create lex env when needed LibJS: FDI bytecode WIP mapped args length LibJS: FDI bytecode WIP WIP LibJS: FDI bytecode WIP comment out default params executables LibJS: FDI bytecode WIP hmmmmmmm LibJS: FDI bytecode WIP some progress LibJS: FDI bytecode WIP some progress LibJS: FDI bytecode WIP wat LibJS: FDI bytecode WIP save argument count in copied EC LibJS: FDI bytecode WIP dupes LibJS: FDI bytecode WIP module wrappers fix LibJS: FDI bytecode WIP some progress LibJS: FDI bytecode WIP some progress LibJS: FDI bytecode WIP some progress LibJS: FDI bytecode WIP some cleanup LibJS: FDI bytecode WIP some cleanup LibJS: FDI bytecode WIP some cleanup LibJS: FDI bytecode WIP some cleanup LibJS: FDI bytecode WIP some cleanup
1 parent 8d3eb93 commit 22cc16b

17 files changed

+596
-442
lines changed

Userland/Libraries/LibJS/AST.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <LibJS/Bytecode/CodeGenerationError.h>
1919
#include <LibJS/Bytecode/Executable.h>
2020
#include <LibJS/Bytecode/IdentifierTable.h>
21+
#include <LibJS/Bytecode/Op.h>
2122
#include <LibJS/Bytecode/Operand.h>
2223
#include <LibJS/Forward.h>
2324
#include <LibJS/Heap/Handle.h>
@@ -710,6 +711,9 @@ class FunctionNode {
710711
FunctionKind kind() const { return m_kind; }
711712
UsesThis uses_this() const { return m_uses_this; }
712713

714+
virtual bool has_name() const = 0;
715+
virtual Value instantiate_ordinary_function_expression(VM&, DeprecatedFlyString given_name) const = 0;
716+
713717
protected:
714718
FunctionNode(RefPtr<Identifier const> name, ByteString source_text, NonnullRefPtr<Statement const> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Vector<DeprecatedFlyString> local_variables_names, UsesThis uses_this)
715719
: m_name(move(name))
@@ -769,6 +773,12 @@ class FunctionDeclaration final
769773

770774
void set_should_do_additional_annexB_steps() { m_is_hoisted = true; }
771775

776+
bool has_name() const override { return true; }
777+
Value instantiate_ordinary_function_expression(VM&, DeprecatedFlyString) const override
778+
{
779+
VERIFY_NOT_REACHED();
780+
}
781+
772782
private:
773783
bool m_is_hoisted { false };
774784
};
@@ -790,9 +800,9 @@ class FunctionExpression final
790800
virtual Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> generate_bytecode(Bytecode::Generator&, Optional<Bytecode::Operand> preferred_dst = {}) const override;
791801
virtual Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> generate_bytecode_with_lhs_name(Bytecode::Generator&, Optional<Bytecode::IdentifierTableIndex> lhs_name, Optional<Bytecode::Operand> preferred_dst = {}) const;
792802

793-
bool has_name() const { return !name().is_empty(); }
803+
bool has_name() const override { return !name().is_empty(); }
794804

795-
Value instantiate_ordinary_function_expression(VM&, DeprecatedFlyString given_name) const;
805+
Value instantiate_ordinary_function_expression(VM&, DeprecatedFlyString given_name) const override;
796806

797807
private:
798808
virtual bool is_function_expression() const override { return true; }
@@ -2181,6 +2191,8 @@ class SyntheticReferenceExpression final : public Expression {
21812191
Value m_value;
21822192
};
21832193

2194+
Bytecode::CodeGenerationErrorOr<void> generate_binding_pattern_bytecode(Bytecode::Generator& generator, BindingPattern const& pattern, Bytecode::Op::SetVariable::InitializationMode, Bytecode::Operand const& input_value, bool create_variables);
2195+
21842196
template<>
21852197
inline bool ASTNode::fast_is<NewExpression>() const { return is_new_expression(); }
21862198

Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@ Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> SuperCall::generate
398398
return dst;
399399
}
400400

401-
static Bytecode::CodeGenerationErrorOr<void> generate_binding_pattern_bytecode(Bytecode::Generator& generator, BindingPattern const& pattern, Bytecode::Op::SetVariable::InitializationMode, Bytecode::Operand const& input_value, bool create_variables);
402-
403401
Bytecode::CodeGenerationErrorOr<Optional<Bytecode::Operand>> AssignmentExpression::generate_bytecode(Bytecode::Generator& generator, Optional<Bytecode::Operand> preferred_dst) const
404402
{
405403
Bytecode::Generator::SourceLocationScope scope(generator, *this);
@@ -1410,7 +1408,7 @@ static Bytecode::CodeGenerationErrorOr<void> generate_array_binding_pattern_byte
14101408
return {};
14111409
}
14121410

1413-
static Bytecode::CodeGenerationErrorOr<void> generate_binding_pattern_bytecode(Bytecode::Generator& generator, BindingPattern const& pattern, Bytecode::Op::SetVariable::InitializationMode initialization_mode, Bytecode::Operand const& input_value, bool create_variables)
1411+
Bytecode::CodeGenerationErrorOr<void> generate_binding_pattern_bytecode(Bytecode::Generator& generator, BindingPattern const& pattern, Bytecode::Op::SetVariable::InitializationMode initialization_mode, Bytecode::Operand const& input_value, bool create_variables)
14141412
{
14151413
if (pattern.kind == BindingPattern::Kind::Object)
14161414
return generate_object_binding_pattern_bytecode(generator, pattern, initialization_mode, input_value, create_variables);

Userland/Libraries/LibJS/Bytecode/CommonImplementations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ inline ThrowCompletionOr<void> set_variable(
415415
return {};
416416
}
417417

418-
inline Value new_function(VM& vm, FunctionExpression const& function_node, Optional<IdentifierTableIndex> const& lhs_name, Optional<Operand> const& home_object)
418+
inline Value new_function(VM& vm, FunctionNode const& function_node, Optional<IdentifierTableIndex> const& lhs_name, Optional<Operand> const& home_object)
419419
{
420420
Value value;
421421

0 commit comments

Comments
 (0)