LibJS: Add FunctionObject::fast_is<BoundFunction>()

This commit is contained in:
Aliaksandr Kalenik 2025-09-25 18:11:22 +02:00 committed by Alexander Kalenik
parent e1e7007707
commit aec20e032b
2 changed files with 9 additions and 0 deletions

View File

@ -36,9 +36,14 @@ private:
ThrowCompletionOr<void> get_stack_frame_size(size_t& registers_and_constants_and_locals_count, size_t& argument_count) override;
virtual void visit_edges(Visitor&) override;
virtual bool is_bound_function() const final { return true; }
GC::Ptr<FunctionObject> m_bound_target_function; // [[BoundTargetFunction]]
Value m_bound_this; // [[BoundThis]]
Vector<Value> m_bound_arguments; // [[BoundArguments]]
};
template<>
inline bool FunctionObject::fast_is<BoundFunction>() const { return is_bound_function(); }
}

View File

@ -42,6 +42,9 @@ public:
virtual FunctionParameters const& formal_parameters() const { VERIFY_NOT_REACHED(); }
template<typename T>
bool fast_is() const = delete;
protected:
explicit FunctionObject(Realm&, Object* prototype, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
explicit FunctionObject(Object& prototype, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
@ -50,6 +53,7 @@ protected:
private:
virtual bool is_function() const override { return true; }
virtual bool is_bound_function() const { return false; }
};
template<>