• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_BUILTINS_ARRAY_STUB_BUILDER_H
17 #define ECMASCRIPT_COMPILER_BUILTINS_ARRAY_STUB_BUILDER_H
18 #include "ecmascript/compiler/circuit_builder.h"
19 #include "ecmascript/compiler/gate.h"
20 #include "ecmascript/compiler/share_gate_meta_data.h"
21 #include "ecmascript/compiler/stub_builder-inl.h"
22 
23 namespace panda::ecmascript::kungfu {
24 class BuiltinsArrayStubBuilder : public BuiltinsStubBuilder {
25 public:
BuiltinsArrayStubBuilder(StubBuilder * parent)26     explicit BuiltinsArrayStubBuilder(StubBuilder *parent)
27         : BuiltinsStubBuilder(parent) {}
28     ~BuiltinsArrayStubBuilder() override = default;
29     NO_MOVE_SEMANTIC(BuiltinsArrayStubBuilder);
30     NO_COPY_SEMANTIC(BuiltinsArrayStubBuilder);
GenerateCircuit()31     void GenerateCircuit() override {}
32 
33     void Concat(GateRef glue, GateRef thisValue, GateRef numArgs,
34         Variable *result, Label *exit, Label *slowPath);
35 
36     void Filter(GateRef glue, GateRef thisValue, GateRef numArgs,
37         Variable *result, Label *exit, Label *slowPath);
38 
39     void Find(GateRef glue, GateRef thisValue, GateRef numArgs,
40         Variable *result, Label *exit, Label *slowPath);
41 
42     void FindIndex(GateRef glue, GateRef thisValue, GateRef numArgs,
43         Variable *result, Label *exit, Label *slowPath);
44 
45     void ForEach(GateRef glue, GateRef thisValue, GateRef numArgs,
46         Variable *result, Label *exit, Label *slowPath);
47 
48     void IndexOf(GateRef glue, GateRef thisValue, GateRef numArgs,
49         Variable *result, Label *exit, Label *slowPath);
50 
51     void LastIndexOf(GateRef glue, GateRef thisValue, GateRef numArgs,
52         Variable *result, Label *exit, Label *slowPath);
53 
54     void Pop(GateRef glue, GateRef thisValue, GateRef numArgs,
55         Variable *result, Label *exit, Label *slowPath);
56 
57     void Slice(GateRef glue, GateRef thisValue, GateRef numArgs,
58         Variable *result, Label *exit, Label *slowPath);
59 
60     void Sort(GateRef glue, GateRef thisValue,
61         GateRef numArgs, Variable *result, Label *exit, Label *slowPath);
62 
63     void Values(GateRef glue, GateRef thisValue, GateRef numArgs,
64         Variable *result, Label *exit, Label *slowPath);
65 
66     void Reduce(GateRef glue, GateRef thisValue, GateRef numArgs,
67         Variable *result, Label *exit, Label *slowPath);
68 
69     void Reverse(GateRef glue, GateRef thisValue, GateRef numArgs,
70         Variable *result, Label *exit, Label *slowPath);
71 
72     void From(GateRef glue, GateRef thisValue, GateRef numArgs, Variable *result, Label *exit, Label *slowPath);
73     void Splice(GateRef glue, GateRef thisValue, GateRef numArgs, Variable *result, Label *exit, Label *slowPath);
74 
75     void Push(GateRef glue, GateRef thisValue, GateRef numArgs,
76         Variable *result, Label *exit, Label *slowPath);
77 
78     void Includes(GateRef glue, GateRef thisValue, GateRef numArgs, Variable *result, Label *exit, Label *slowPath);
79 
80     GateRef IsConcatSpreadable(GateRef glue, GateRef obj);
81 
82     GateRef NewArray(GateRef glue, GateRef count);
83 private:
84     static constexpr uint32_t MAX_LENGTH_ZERO = 0;
85     static constexpr uint32_t MAX_LENGTH_ONE = 1;
86     struct JsArrayRequirements {
87         bool stable = false;
88         bool defaultConstructor = false;
89     };
90     GateRef IsJsArrayWithLengthLimit(GateRef glue, GateRef object,
91         uint32_t maxLength, JsArrayRequirements requirements);
92     GateRef CreateSpliceDeletedArray(GateRef glue, GateRef thisValue, GateRef actualDeleteCount,
93         GateRef intialHClass, GateRef start);
94 };
95 }  // namespace panda::ecmascript::kungfu
96 #endif  // ECMASCRIPT_COMPILER_BUILTINS_ARRAY_STUB_BUILDER_H
97