• 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 LoadObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef profileTypeInfo, GateRef slotId,
42         ProfileOperation callback = ProfileOperation());
43     GateRef StoreObjByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value, GateRef profileTypeInfo,
44                             GateRef slotId, ProfileOperation callback = ProfileOperation());
45     GateRef DeprecatedLoadObjByValue(GateRef glue, GateRef receiver, GateRef key);
46     GateRef TryLoadGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
47                                 GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
48     GateRef TryStoreGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info,
49                                  GateRef value, GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
50     GateRef LoadGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
51                           GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback);
52     GateRef StoreGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info,
53                            GateRef value, GateRef profileTypeInfo, GateRef slotId);
54 private:
55     GateRef ResolvePropKey(GateRef glue, GateRef prop, const StringIdInfo &info);
56     GateRef jsFunc_ { Circuit::NullGate() };
57 };
58 }  // namespace panda::ecmascript::kungfu
59 #endif  // ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H
60