• 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 ECMASCRIPT_COMPILER_OBJECT_OPERATOR_STUB_BUILDER_H
17 #define ECMASCRIPT_COMPILER_OBJECT_OPERATOR_STUB_BUILDER_H
18 
19 #include "ecmascript/compiler/stub_builder.h"
20 #include "ecmascript/object_operator.h"
21 
22 namespace panda::ecmascript::kungfu {
23 
24 class ObjectOperatorStubBuilder : public StubBuilder {
25 public:
ObjectOperatorStubBuilder(StubBuilder * parent)26     explicit ObjectOperatorStubBuilder(StubBuilder *parent)
27         : StubBuilder(parent) {}
ObjectOperatorStubBuilder(Environment * env)28     explicit ObjectOperatorStubBuilder(Environment *env)
29         : StubBuilder(env) {}
30     ~ObjectOperatorStubBuilder() override = default;
31     NO_MOVE_SEMANTIC(ObjectOperatorStubBuilder);
32     NO_COPY_SEMANTIC(ObjectOperatorStubBuilder);
GenerateCircuit()33     void GenerateCircuit() override {}
34 
35     void TryFastHandleStringKey(GateRef key, Variable *propKey, Variable *elemKey,
36                                 Label *isProperty, Label *isElement, Label *tryFailed);
37     void HandleKey(GateRef glue, GateRef key, Variable *propKey, Variable *elemKey, Label *isProperty, Label *isElement,
38                    Label *hasException, GateRef hir = Circuit::NullGate());
39     template <bool keyIsElement>
40     void CheckValidIndexOrKeyIsLength(GateRef glue, GateRef key, GateRef obj, Label *checkSucc, Label *checkFail);
41     template <bool keyIsElement>
42     void UpdateHolder(GateRef glue, Variable *holder, GateRef key, Label *holderUpdated);
43     template <bool keyIsElement>
44     void LookupProperty(GateRef glue, Variable *holder, GateRef key, Label *isJSProxy, Label *ifFound, Label *notFound,
45                         GateRef hir = Circuit::NullGate());
46     template <bool keyIsElement>
47     void TryLookupInProtoChain(GateRef glue, Variable *holder, GateRef key, Label *ifFound, Label *notFound,
48                                Label *isJSProxy, GateRef hir = Circuit::NullGate());
49     GateRef LookupPropertyInlinedProps(GateRef glue, GateRef obj, GateRef key, GateRef hir = Circuit::NullGate());
50     GateRef LookupElementInlinedProps(GateRef glue, GateRef obj, GateRef key, GateRef hir = Circuit::NullGate());
51 };
52 }  // namespace panda::ecmascript::kungfu
53 #endif  // ECMASCRIPT_COMPILER_OBJECT_OPERATOR_STUB_BUILDER_H
54