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 22namespace panda::ecmascript::kungfu { 23class AccessObjectStubBuilder : public StubBuilder { 24public: 25 explicit AccessObjectStubBuilder(StubBuilder *parent) : StubBuilder(parent) 26 { 27 jsFunc_ = Circuit::NullGate(); 28 } 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); 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 StoreOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value, GateRef profileTypeInfo, 59 GateRef slotId, ProfileOperation callback = ProfileOperation()); 60 GateRef DeprecatedLoadObjByValue(GateRef glue, GateRef receiver, GateRef key); 61 GateRef TryLoadGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info, 62 GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback); 63 GateRef TryStoreGlobalByName(GateRef glue, GateRef prop, const StringIdInfo &info, 64 GateRef value, GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback); 65 GateRef LoadGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info, 66 GateRef profileTypeInfo, GateRef slotId, ProfileOperation callback); 67 GateRef StoreGlobalVar(GateRef glue, GateRef prop, const StringIdInfo &info, 68 GateRef value, GateRef profileTypeInfo, GateRef slotId); 69 GateRef StOwnByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value); 70 GateRef StOwnByValue(GateRef glue, GateRef receiver, GateRef key, GateRef value); 71 GateRef StOwnByName(GateRef glue, GateRef receiver, GateRef key, GateRef value); 72 GateRef StOwnByValueWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value); 73 GateRef StOwnByNameWithNameSet(GateRef glue, GateRef receiver, GateRef key, GateRef value); 74 GateRef StObjByIndex(GateRef glue, GateRef receiver, GateRef index, GateRef value); 75 GateRef LdObjByIndex(GateRef glue, GateRef receiver, GateRef index); 76 77private: 78 GateRef ResolvePropKey(GateRef glue, GateRef prop, const StringIdInfo &info); 79 GateRef jsFunc_ { Circuit::NullGate() }; 80}; 81} // namespace panda::ecmascript::kungfu 82#endif // ECMASCRIPT_COMPILER_ACCESS_OBJECT_STUB_BUILDER_H 83