• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 COMMON_INTERFACES_OBJECTS_BASE_OBJECT_DESCRIPTOR_H
17 #define COMMON_INTERFACES_OBJECTS_BASE_OBJECT_DESCRIPTOR_H
18 
19 #include "objects/base_object.h"
20 #include "objects/base_type.h"
21 #include "thread/thread_holder.h"
22 
23 namespace panda::ecmascript {
24 class HandlerBase;
25 }
26 namespace common {
27 // for IC
28 using HandlerBase = panda::ecmascript::HandlerBase;
29 
30 class DynamicObjectDescriptorInterface {
31     // GetProperty is used to get the value of a property and its ic information
32     // from a dynamic object with the given name.
33     virtual std::pair<JSTaggedValue, HandlerBase> GetProperty(ThreadHolder *thread, const BaseObject *obj,
34                                                               const char *name) const = 0;
35 
36     // SetProperty is used to set the value of a property and get its ic information
37     // from a dynamic object with the given name.
38     virtual std::pair<bool, HandlerBase> SetProperty(ThreadHolder *thread, BaseObject *obj, const char *name,
39                                                      JSTaggedValue value) = 0;
40 
41     // GetElementByIdx is used to get the value of an element and its ic information
42     // from a dynamic object with the give index.
43     virtual std::pair<JSTaggedValue, HandlerBase> GetElementByIdx(ThreadHolder *thread, const BaseObject *obj,
44                                                                   const uint32_t index) const = 0;
45 
46     // SetElementByIdx is used to set the value of an element and get its ic information
47     // from a dynamic object with the given index.
48     virtual std::pair<bool, HandlerBase> SetElementByIdx(ThreadHolder *thread, BaseObject *obj, const uint32_t index,
49                                                          JSTaggedValue value) = 0;
50 };
51 
52 // interfaces used to access property layout infomation for static object.
53 // It will be declared and implemented by static vm side.
54 class StaticObjectDescriptorInterface {};
55 }  // namespace common
56 #endif  // COMMON_INTERFACES_OBJECTS_BASE_OBJECT_DESCRIPTOR_H