1 // Copyright 2018 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_OBJECTS_STRUCT_INL_H_ 6 #define V8_OBJECTS_STRUCT_INL_H_ 7 8 #include "src/objects/struct.h" 9 10 #include "src/heap/heap-write-barrier-inl.h" 11 #include "src/objects/objects-inl.h" 12 #include "src/objects/oddball.h" 13 #include "src/roots/roots-inl.h" 14 15 // Has to be the last include (doesn't have include guards): 16 #include "src/objects/object-macros.h" 17 18 namespace v8 { 19 namespace internal { 20 21 #include "torque-generated/src/objects/struct-tq-inl.inc" 22 23 TQ_OBJECT_CONSTRUCTORS_IMPL(Struct) TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple2)24TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple2) 25 TQ_OBJECT_CONSTRUCTORS_IMPL(AccessorPair) 26 27 NEVER_READ_ONLY_SPACE_IMPL(AccessorPair) 28 29 TQ_OBJECT_CONSTRUCTORS_IMPL(ClassPositions) 30 31 void Struct::InitializeBody(int object_size) { 32 Object value = GetReadOnlyRoots().undefined_value(); 33 for (int offset = kHeaderSize; offset < object_size; offset += kTaggedSize) { 34 WRITE_FIELD(*this, offset, value); 35 } 36 } 37 get(AccessorComponent component)38Object AccessorPair::get(AccessorComponent component) { 39 return component == ACCESSOR_GETTER ? getter() : setter(); 40 } 41 set(AccessorComponent component,Object value)42void AccessorPair::set(AccessorComponent component, Object value) { 43 if (component == ACCESSOR_GETTER) { 44 set_getter(value); 45 } else { 46 set_setter(value); 47 } 48 } 49 SetComponents(Object getter,Object setter)50void AccessorPair::SetComponents(Object getter, Object setter) { 51 if (!getter.IsNull()) set_getter(getter); 52 if (!setter.IsNull()) set_setter(setter); 53 } 54 Equals(Object getter_value,Object setter_value)55bool AccessorPair::Equals(Object getter_value, Object setter_value) { 56 return (getter() == getter_value) && (setter() == setter_value); 57 } 58 59 } // namespace internal 60 } // namespace v8 61 62 #include "src/objects/object-macros-undef.h" 63 64 #endif // V8_OBJECTS_STRUCT_INL_H_ 65