chromium/v8/src/objects/js-disposable-stack.h

// Copyright 2024 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_OBJECTS_JS_DISPOSABLE_STACK_H_
#define V8_OBJECTS_JS_DISPOSABLE_STACK_H_

#include "src/base/bit-field.h"
#include "src/handles/handles.h"
#include "src/handles/maybe-handles.h"
#include "src/objects/contexts.h"
#include "src/objects/heap-object.h"
#include "src/objects/js-objects.h"
#include "src/objects/js-promise.h"
#include "torque-generated/bit-fields.h"

// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"

namespace v8 {
namespace internal {

#include "torque-generated/src/objects/js-disposable-stack-tq.inc"

// Valid states for a DisposableStack.
// https://arai-a.github.io/ecma262-compare/?pr=3000&id=sec-disposablestack-objects
enum class DisposableStackState {};

// kValueIsReceiver: Call the method with no argument
// kValueIsArgument: Pass the value as the argument to the dispose method,
// `disposablestack.prototype.adopt` is the only method that uses
// kValueIsArgument as DisposeMethodCallType.
enum class DisposeMethodCallType {};

// Valid hints for a DisposableStack.
// https://arai-a.github.io/ecma262-compare/?pr=3000&id=sec-disposableresource-records
enum class DisposeMethodHint {};

// Types of disposable resources in a DisposableStack.
enum class DisposableStackResourcesType {};

DisposeCallTypeBit;
using DisposeHintBit = DisposeCallTypeBit::Next<DisposeMethodHint, 1>;

class JSDisposableStackBase
    : public TorqueGeneratedJSDisposableStackBase<JSDisposableStackBase,
                                                  JSObject> {};

class JSSyncDisposableStack
    : public TorqueGeneratedJSSyncDisposableStack<JSSyncDisposableStack,
                                                  JSDisposableStackBase> {};

class JSAsyncDisposableStack
    : public TorqueGeneratedJSAsyncDisposableStack<JSAsyncDisposableStack,
                                                   JSDisposableStackBase> {};

}  // namespace internal
}  // namespace v8

#include "src/objects/object-macros-undef.h"

#endif  // V8_OBJECTS_JS_DISPOSABLE_STACK_H_