mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:02:45 +00:00 
			
		
		
		
	 ece961f882
			
		
	
	
		ece961f882
		
	
	
	
	
		
			
			(Instead of MarkedVector<Value>.) This is a step towards not storing argument lists in MarkedVector<Value> at all. Note that they still end up in MarkedVectors since that's what ExecutionContext has.
		
			
				
	
	
		
			65 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
 | |
|  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibJS/Runtime/Completion.h>
 | |
| #include <LibJS/Runtime/FunctionObject.h>
 | |
| 
 | |
| namespace JS {
 | |
| 
 | |
| class ProxyObject final : public FunctionObject {
 | |
|     JS_OBJECT(ProxyObject, FunctionObject);
 | |
|     JS_DECLARE_ALLOCATOR(ProxyObject);
 | |
| 
 | |
| public:
 | |
|     static NonnullGCPtr<ProxyObject> create(Realm&, Object& target, Object& handler);
 | |
| 
 | |
|     virtual ~ProxyObject() override = default;
 | |
| 
 | |
|     virtual DeprecatedFlyString const& name() const override;
 | |
|     virtual bool has_constructor() const override;
 | |
| 
 | |
|     Object const& target() const { return m_target; }
 | |
|     Object const& handler() const { return m_handler; }
 | |
| 
 | |
|     bool is_revoked() const { return m_is_revoked; }
 | |
|     void revoke() { m_is_revoked = true; }
 | |
| 
 | |
|     // 10.5 Proxy Object Internal Methods and Internal Slots, https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots
 | |
| 
 | |
|     virtual ThrowCompletionOr<Object*> internal_get_prototype_of() const override;
 | |
|     virtual ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override;
 | |
|     virtual ThrowCompletionOr<bool> internal_is_extensible() const override;
 | |
|     virtual ThrowCompletionOr<bool> internal_prevent_extensions() override;
 | |
|     virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const override;
 | |
|     virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&) override;
 | |
|     virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const override;
 | |
|     virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata*) const override;
 | |
|     virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*) override;
 | |
|     virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
 | |
|     virtual ThrowCompletionOr<MarkedVector<Value>> internal_own_property_keys() const override;
 | |
|     virtual ThrowCompletionOr<Value> internal_call(Value this_argument, ReadonlySpan<Value> arguments_list) override;
 | |
|     virtual ThrowCompletionOr<NonnullGCPtr<Object>> internal_construct(ReadonlySpan<Value> arguments_list, FunctionObject& new_target) override;
 | |
| 
 | |
| private:
 | |
|     ProxyObject(Object& target, Object& handler, Object& prototype);
 | |
| 
 | |
|     virtual void visit_edges(Visitor&) override;
 | |
| 
 | |
|     virtual bool is_function() const override { return m_target->is_function(); }
 | |
|     virtual bool is_proxy_object() const final { return true; }
 | |
| 
 | |
|     NonnullGCPtr<Object> m_target;
 | |
|     NonnullGCPtr<Object> m_handler;
 | |
|     bool m_is_revoked { false };
 | |
| };
 | |
| 
 | |
| template<>
 | |
| inline bool Object::fast_is<ProxyObject>() const { return is_proxy_object(); }
 | |
| 
 | |
| }
 |