11cb0ef41Sopenharmony_ci// Copyright 2018 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_OBJECTS_STRUCT_H_
61cb0ef41Sopenharmony_ci#define V8_OBJECTS_STRUCT_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/objects/heap-object.h"
91cb0ef41Sopenharmony_ci#include "src/objects/objects.h"
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci// Has to be the last include (doesn't have include guards):
121cb0ef41Sopenharmony_ci#include "src/objects/object-macros.h"
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cinamespace v8 {
151cb0ef41Sopenharmony_cinamespace internal {
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciclass StructBodyDescriptor;
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci#include "torque-generated/src/objects/struct-tq.inc"
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci// An abstract superclass, a marker class really, for simple structure classes.
221cb0ef41Sopenharmony_ci// It doesn't carry any functionality but allows struct classes to be
231cb0ef41Sopenharmony_ci// identified in the type system.
241cb0ef41Sopenharmony_ciclass Struct : public TorqueGeneratedStruct<Struct, HeapObject> {
251cb0ef41Sopenharmony_ci public:
261cb0ef41Sopenharmony_ci  void BriefPrintDetails(std::ostream& os);
271cb0ef41Sopenharmony_ci  STATIC_ASSERT(kHeaderSize == HeapObject::kHeaderSize);
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(Struct)
301cb0ef41Sopenharmony_ci};
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ciclass Tuple2 : public TorqueGeneratedTuple2<Tuple2, Struct> {
331cb0ef41Sopenharmony_ci public:
341cb0ef41Sopenharmony_ci  void BriefPrintDetails(std::ostream& os);
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci  using BodyDescriptor = StructBodyDescriptor;
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(Tuple2)
391cb0ef41Sopenharmony_ci};
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci// Support for JavaScript accessors: A pair of a getter and a setter. Each
421cb0ef41Sopenharmony_ci// accessor can either be
431cb0ef41Sopenharmony_ci//   * a JavaScript function or proxy: a real accessor
441cb0ef41Sopenharmony_ci//   * a FunctionTemplateInfo: a real (lazy) accessor
451cb0ef41Sopenharmony_ci//   * undefined: considered an accessor by the spec, too, strangely enough
461cb0ef41Sopenharmony_ci//   * null: an accessor which has not been set
471cb0ef41Sopenharmony_ciclass AccessorPair : public TorqueGeneratedAccessorPair<AccessorPair, Struct> {
481cb0ef41Sopenharmony_ci public:
491cb0ef41Sopenharmony_ci  NEVER_READ_ONLY_SPACE
501cb0ef41Sopenharmony_ci  static Handle<AccessorPair> Copy(Isolate* isolate, Handle<AccessorPair> pair);
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci  inline Object get(AccessorComponent component);
531cb0ef41Sopenharmony_ci  inline void set(AccessorComponent component, Object value);
541cb0ef41Sopenharmony_ci  inline void set(AccessorComponent component, Object value,
551cb0ef41Sopenharmony_ci                  ReleaseStoreTag tag);
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci  using TorqueGeneratedAccessorPair::getter;
581cb0ef41Sopenharmony_ci  using TorqueGeneratedAccessorPair::set_getter;
591cb0ef41Sopenharmony_ci  DECL_RELEASE_ACQUIRE_ACCESSORS(getter, Object)
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci  using TorqueGeneratedAccessorPair::set_setter;
621cb0ef41Sopenharmony_ci  using TorqueGeneratedAccessorPair::setter;
631cb0ef41Sopenharmony_ci  DECL_RELEASE_ACQUIRE_ACCESSORS(setter, Object)
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci  // Note: Returns undefined if the component is not set.
661cb0ef41Sopenharmony_ci  static Handle<Object> GetComponent(Isolate* isolate,
671cb0ef41Sopenharmony_ci                                     Handle<NativeContext> native_context,
681cb0ef41Sopenharmony_ci                                     Handle<AccessorPair> accessor_pair,
691cb0ef41Sopenharmony_ci                                     AccessorComponent component);
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci  // Set both components, skipping arguments which are a JavaScript null.
721cb0ef41Sopenharmony_ci  inline void SetComponents(Object getter, Object setter);
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ci  inline bool Equals(Object getter_value, Object setter_value);
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_ci  using BodyDescriptor = StructBodyDescriptor;
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(AccessorPair)
791cb0ef41Sopenharmony_ci};
801cb0ef41Sopenharmony_ci
811cb0ef41Sopenharmony_ciclass ClassPositions
821cb0ef41Sopenharmony_ci    : public TorqueGeneratedClassPositions<ClassPositions, Struct> {
831cb0ef41Sopenharmony_ci public:
841cb0ef41Sopenharmony_ci  // Dispatched behavior.
851cb0ef41Sopenharmony_ci  void BriefPrintDetails(std::ostream& os);
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci  using BodyDescriptor = StructBodyDescriptor;
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ci  TQ_OBJECT_CONSTRUCTORS(ClassPositions)
901cb0ef41Sopenharmony_ci};
911cb0ef41Sopenharmony_ci
921cb0ef41Sopenharmony_ci}  // namespace internal
931cb0ef41Sopenharmony_ci}  // namespace v8
941cb0ef41Sopenharmony_ci
951cb0ef41Sopenharmony_ci#include "src/objects/object-macros-undef.h"
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci#endif  // V8_OBJECTS_STRUCT_H_
98