• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H
16 #define ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H
17 
18 #include "ecmascript/compiler/interpreter_stub.h"
19 #include "ecmascript/compiler/profiler_operation.h"
20 #include "ecmascript/compiler/stub_builder.h"
21 
22 namespace panda::ecmascript::kungfu {
23 class AccessObjectStubBuilder : public StubBuilder {
24 public:
AccessObjectStubBuilder(StubBuilder * parent)25     explicit AccessObjectStubBuilder(StubBuilder *parent) : StubBuilder(parent)
26     {
27         jsFunc_ = Circuit::NullGate();
28     }
AccessObjectStubBuilder(StubBuilder * parent,GateRef jsFunc)29     explicit AccessObjectStubBuilder(StubBuilder *parent, GateRef jsFunc)
30         : StubBuilder(parent), jsFunc_(jsFunc) {}
31     ~AccessObjectStubBuilder() override = default;
32     NO_MOVE_SEMANTIC(AccessObjectStubBuilder);
33     NO_COPY_SEMANTIC(AccessObjectStubBuilder);
GenerateCircuit()34     void GenerateCircuit() override {}
35 
36     GateRef LoadObjByName(GateRef glue, GateRef receiver, GateRef prop, const StringIdInfo &info,
37                           GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback = ProfileOperation());
38     GateRef DeprecatedLoadObjByName(GateRef glue, GateRef receiver, GateRef propKey);
39     GateRef StoreObjByName(GateRef glue, GateRef receiver, GateRef prop, const StringIdInfo &info, GateRef value,
40         GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback = ProfileOperation());
41     GateRef LoadPrivatePropertyByName(GateRef glue,
42                                       GateRef receiver,
43                                       GateRef key,
44                                       GateRef profileTypeInfo,
45                                       GateRef slotId,
46                                       ProfileOperation callback);
47     GateRef StorePrivatePropertyByName(GateRef glue,
48                                        GateRef receiver,
49                                        GateRef key,
50                                        GateRef value,
51                                        GateRef profileTypeInfo,
52                                        GateRef slotId,
53                                        ProfileOperation callback = ProfileOperation());
54     GateRef LoadObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo, GateRef slotId,
55         ProfileOperation callback = ProfileOperation());
56     GateRef StoreObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef profileTypeInfo,
57                             GateRef slotId, ProfileOperation callback = ProfileOperation());
58     GateRef DeprecatedLoadObjByValue(GateRef glue, GateRef receiver, GateRef key);
59     GateRef TryLoadGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
60                                 GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
61     GateRef TryStoreGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
62                                  GateRef value, GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
63     GateRef LoadGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
64                           GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
65     GateRef StoreGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
66                            GateRef value, GateRef profileTypeInfo, GateRef slotId);
67     GateRef StOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value);
68     GateRef StOwnByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value);
69     GateRef StOwnByName(GateRef glue, GateRef receiver, GateRef key, GateRef value);
70     GateRef StOwnByValueWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value);
71     GateRef StOwnByNameWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value);
72     GateRef StObjByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value);
73     GateRef LdObjByIndex(GateRef glue, GateRef receiver, GateRef index);
74 
75 private:
76     GateRef ResolvePropKey(GateRef glue, GateRef prop, const StringIdInfo &info);
77     GateRef jsFunc_ { Circuit::NullGate() };
78 };
79 }  // namespace panda::ecmascript::kungfu
80 #endif  // ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H
81