1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_IC_PROPERTY_BOX_H 17 #define ECMASCRIPT_IC_PROPERTY_BOX_H 18 19 #include "ecmascript/ecma_macros.h" 20 #include "ecmascript/js_hclass.h" 21 #include "ecmascript/js_tagged_value.h" 22 #include "ecmascript/mem/slots.h" 23 #include "ecmascript/mem/visitor.h" 24 #include "ecmascript/property_attributes.h" 25 26 namespace panda { 27 namespace ecmascript { 28 class PropertyBox : public TaggedObject { 29 public: Cast(TaggedObject * object)30 static PropertyBox *Cast(TaggedObject *object) 31 { 32 ASSERT(JSTaggedValue(object).IsPropertyBox()); 33 return static_cast<PropertyBox *>(object); 34 } 35 36 void Clear(const JSThread *thread); 37 IsInvalid()38 inline bool IsInvalid() const 39 { 40 return GetValue().IsHole(); 41 } 42 43 static constexpr size_t VALUE_OFFSET = TaggedObjectSize(); 44 ACCESSORS(Value, VALUE_OFFSET, SIZE); 45 46 DECL_VISIT_OBJECT(VALUE_OFFSET, SIZE) 47 DECL_DUMP() 48 }; 49 } // namespace ecmascript 50 } // namespace panda 51 52 #endif