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_INL_H_ 61cb0ef41Sopenharmony_ci#define V8_OBJECTS_STRUCT_INL_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/objects/struct.h" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include "src/heap/heap-write-barrier-inl.h" 111cb0ef41Sopenharmony_ci#include "src/objects/objects-inl.h" 121cb0ef41Sopenharmony_ci#include "src/objects/oddball.h" 131cb0ef41Sopenharmony_ci#include "src/roots/roots-inl.h" 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci// Has to be the last include (doesn't have include guards): 161cb0ef41Sopenharmony_ci#include "src/objects/object-macros.h" 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cinamespace v8 { 191cb0ef41Sopenharmony_cinamespace internal { 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci#include "torque-generated/src/objects/struct-tq-inl.inc" 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ciTQ_OBJECT_CONSTRUCTORS_IMPL(Struct) 241cb0ef41Sopenharmony_ciTQ_OBJECT_CONSTRUCTORS_IMPL(Tuple2) 251cb0ef41Sopenharmony_ciTQ_OBJECT_CONSTRUCTORS_IMPL(AccessorPair) 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciNEVER_READ_ONLY_SPACE_IMPL(AccessorPair) 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ciTQ_OBJECT_CONSTRUCTORS_IMPL(ClassPositions) 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ciObject AccessorPair::get(AccessorComponent component) { 321cb0ef41Sopenharmony_ci return component == ACCESSOR_GETTER ? getter() : setter(); 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_civoid AccessorPair::set(AccessorComponent component, Object value) { 361cb0ef41Sopenharmony_ci if (component == ACCESSOR_GETTER) { 371cb0ef41Sopenharmony_ci set_getter(value); 381cb0ef41Sopenharmony_ci } else { 391cb0ef41Sopenharmony_ci set_setter(value); 401cb0ef41Sopenharmony_ci } 411cb0ef41Sopenharmony_ci} 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_civoid AccessorPair::set(AccessorComponent component, Object value, 441cb0ef41Sopenharmony_ci ReleaseStoreTag tag) { 451cb0ef41Sopenharmony_ci if (component == ACCESSOR_GETTER) { 461cb0ef41Sopenharmony_ci set_getter(value, tag); 471cb0ef41Sopenharmony_ci } else { 481cb0ef41Sopenharmony_ci set_setter(value, tag); 491cb0ef41Sopenharmony_ci } 501cb0ef41Sopenharmony_ci} 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ciRELEASE_ACQUIRE_ACCESSORS(AccessorPair, getter, Object, kGetterOffset) 531cb0ef41Sopenharmony_ciRELEASE_ACQUIRE_ACCESSORS(AccessorPair, setter, Object, kSetterOffset) 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_civoid AccessorPair::SetComponents(Object getter, Object setter) { 561cb0ef41Sopenharmony_ci if (!getter.IsNull()) set_getter(getter); 571cb0ef41Sopenharmony_ci if (!setter.IsNull()) set_setter(setter); 581cb0ef41Sopenharmony_ci} 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_cibool AccessorPair::Equals(Object getter_value, Object setter_value) { 611cb0ef41Sopenharmony_ci return (getter() == getter_value) && (setter() == setter_value); 621cb0ef41Sopenharmony_ci} 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci} // namespace internal 651cb0ef41Sopenharmony_ci} // namespace v8 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci#include "src/objects/object-macros-undef.h" 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_ci#endif // V8_OBJECTS_STRUCT_INL_H_ 70