#ifndef V8_OBJECTS_JS_PROXY_H_
#define V8_OBJECTS_JS_PROXY_H_
#include "src/objects/js-objects.h"
#include "src/objects/oddball.h"
#include "torque-generated/builtin-definitions.h"
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
class KeyAccumulator;
#include "torque-generated/src/objects/js-proxy-tq.inc"
class JSProxy : public TorqueGeneratedJSProxy<JSProxy, JSReceiver> {
public:
V8_WARN_UNUSED_RESULT static MaybeDirectHandle<JSProxy> New(
Isolate* isolate, DirectHandle<Object>, DirectHandle<Object>,
bool revocable);
V8_INLINE bool is_revocable() const;
V8_INLINE bool IsRevoked() const;
static void Revoke(DirectHandle<JSProxy> proxy);
static MaybeDirectHandle<JSPrototype> GetPrototype(
DirectHandle<JSProxy> receiver);
V8_WARN_UNUSED_RESULT static Maybe<bool> SetPrototype(
Isolate* isolate, DirectHandle<JSProxy> proxy, DirectHandle<Object> value,
bool from_javascript, ShouldThrow should_throw);
V8_WARN_UNUSED_RESULT static Maybe<bool> IsExtensible(
DirectHandle<JSProxy> proxy);
V8_WARN_UNUSED_RESULT static Maybe<bool> IsArray(DirectHandle<JSProxy> proxy);
V8_WARN_UNUSED_RESULT static Maybe<bool> PreventExtensions(
DirectHandle<JSProxy> proxy, ShouldThrow should_throw);
V8_WARN_UNUSED_RESULT static Maybe<bool> GetOwnPropertyDescriptor(
Isolate* isolate, DirectHandle<JSProxy> proxy, DirectHandle<Name> name,
PropertyDescriptor* desc);
V8_WARN_UNUSED_RESULT static Maybe<bool> DefineOwnProperty(
Isolate* isolate, DirectHandle<JSProxy> object, DirectHandle<Object> key,
PropertyDescriptor* desc, Maybe<ShouldThrow> should_throw);
V8_WARN_UNUSED_RESULT static Maybe<bool> HasProperty(
Isolate* isolate, DirectHandle<JSProxy> proxy, DirectHandle<Name> name);
V8_WARN_UNUSED_RESULT static Maybe<bool> CheckHasTrap(
Isolate* isolate, DirectHandle<Name> name,
DirectHandle<JSReceiver> target);
V8_WARN_UNUSED_RESULT static Maybe<bool> CheckDeleteTrap(
Isolate* isolate, DirectHandle<Name> name,
DirectHandle<JSReceiver> target);
V8_WARN_UNUSED_RESULT static MaybeHandle<JSAny> GetProperty(
Isolate* isolate, DirectHandle<JSProxy> proxy, DirectHandle<Name> name,
DirectHandle<JSAny> receiver, bool* was_found);
enum AccessKind { kGet, kSet };
static MaybeHandle<JSAny> CheckGetSetTrapResult(
Isolate* isolate, DirectHandle<Name> name,
DirectHandle<JSReceiver> target, DirectHandle<Object> trap_result,
AccessKind access_kind);
V8_WARN_UNUSED_RESULT static Maybe<bool> SetProperty(
DirectHandle<JSProxy> proxy, DirectHandle<Name> name,
DirectHandle<Object> value, DirectHandle<JSAny> receiver,
Maybe<ShouldThrow> should_throw);
V8_WARN_UNUSED_RESULT static Maybe<bool> DeletePropertyOrElement(
DirectHandle<JSProxy> proxy, DirectHandle<Name> name,
LanguageMode language_mode);
V8_WARN_UNUSED_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes(
LookupIterator* it);
DECL_VERIFIER(JSProxy)
static const int kMaxIterationLimit = 100 * 1024;
static_assert(static_cast<int>(JSObject::kElementsOffset) ==
static_cast<int>(JSProxy::kTargetOffset));
class BodyDescriptor;
static Maybe<bool> SetPrivateSymbol(Isolate* isolate,
DirectHandle<JSProxy> proxy,
DirectHandle<Symbol> private_name,
PropertyDescriptor* desc,
Maybe<ShouldThrow> should_throw);
using IsRevocableBit = base::BitField<bool, 0, 1>;
static constexpr int kIsRevocableBit = IsRevocableBit::encode(true);
TQ_OBJECT_CONSTRUCTORS(JSProxy)
};
class JSProxyRevocableResult
: public TorqueGeneratedJSProxyRevocableResult<JSProxyRevocableResult,
JSObject> {
public:
static const int kProxyIndex = 0;
static const int kRevokeIndex = 1;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxyRevocableResult);
};
}
}
#include "src/objects/object-macros-undef.h"
#endif