1 /* 2 * Copyright (c) 2021-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 16 #ifndef ECMASCRIPT_BUILTINS_BUILTINS_ARRAY_H 17 #define ECMASCRIPT_BUILTINS_BUILTINS_ARRAY_H 18 19 #include "ecmascript/base/builtins_base.h" 20 21 namespace panda::ecmascript::builtins { 22 static constexpr uint8_t INDEX_TWO = 2; 23 static constexpr uint8_t INDEX_THREE = 3; 24 static const CString STRING_SEPERATOR = ","; 25 class BuiltinsArray : public base::BuiltinsBase { 26 public: 27 // 22.1.1 28 static JSTaggedValue ArrayConstructor(EcmaRuntimeCallInfo *argv); 29 30 // 22.1.2.1 31 static JSTaggedValue From(EcmaRuntimeCallInfo *argv); 32 // 22.1.2.2 33 static JSTaggedValue IsArray(EcmaRuntimeCallInfo *argv); 34 // 22.1.2.3 35 static JSTaggedValue Of(EcmaRuntimeCallInfo *argv); 36 // 22.1.2.5 37 static JSTaggedValue Species(EcmaRuntimeCallInfo *argv); 38 39 // prototype 40 // 22.1.3.1 41 static JSTaggedValue Concat(EcmaRuntimeCallInfo *argv); 42 // 22.1.3.3 43 static JSTaggedValue CopyWithin(EcmaRuntimeCallInfo *argv); 44 // 22.1.3.4 45 static JSTaggedValue Entries(EcmaRuntimeCallInfo *argv); 46 // 22.1.3.5 47 static JSTaggedValue Every(EcmaRuntimeCallInfo *argv); 48 // 22.1.3.6 49 static JSTaggedValue Fill(EcmaRuntimeCallInfo *argv); 50 // 22.1.3.7 51 static JSTaggedValue Filter(EcmaRuntimeCallInfo *argv); 52 // 22.1.3.8 53 static JSTaggedValue Find(EcmaRuntimeCallInfo *argv); 54 // 22.1.3.9 55 static JSTaggedValue FindIndex(EcmaRuntimeCallInfo *argv); 56 // 22.1.3.10 57 static JSTaggedValue ForEach(EcmaRuntimeCallInfo *argv); 58 // 22.1.3.11 59 static JSTaggedValue IndexOf(EcmaRuntimeCallInfo *argv); 60 // 22.1.3.12 61 static JSTaggedValue Join(EcmaRuntimeCallInfo *argv); 62 // 22.1.3.13 63 static JSTaggedValue Keys(EcmaRuntimeCallInfo *argv); 64 // 22.1.3.14 65 static JSTaggedValue LastIndexOf(EcmaRuntimeCallInfo *argv); 66 // 22.1.3.15 67 static JSTaggedValue Map(EcmaRuntimeCallInfo *argv); 68 // 22.1.3.16 69 static JSTaggedValue Pop(EcmaRuntimeCallInfo *argv); 70 // 22.1.3.17 71 static JSTaggedValue Push(EcmaRuntimeCallInfo *argv); 72 // 22.1.3.18 73 static JSTaggedValue Reduce(EcmaRuntimeCallInfo *argv); 74 // 22.1.3.19 75 static JSTaggedValue ReduceRight(EcmaRuntimeCallInfo *argv); 76 // 22.1.3.20 77 static JSTaggedValue Reverse(EcmaRuntimeCallInfo *argv); 78 // 22.1.3.21 79 static JSTaggedValue Shift(EcmaRuntimeCallInfo *argv); 80 // 22.1.3.22 81 static JSTaggedValue Slice(EcmaRuntimeCallInfo *argv); 82 // 22.1.3.23 83 static JSTaggedValue Some(EcmaRuntimeCallInfo *argv); 84 // 22.1.3.24 85 static JSTaggedValue Sort(EcmaRuntimeCallInfo *argv); 86 // 22.1.3.25 87 static JSTaggedValue Splice(EcmaRuntimeCallInfo *argv); 88 // 22.1.3.26 89 static JSTaggedValue ToLocaleString(EcmaRuntimeCallInfo *argv); 90 // 22.1.3.27 91 static JSTaggedValue ToString(EcmaRuntimeCallInfo *argv); 92 // 22.1.3.28 93 static JSTaggedValue Unshift(EcmaRuntimeCallInfo *argv); 94 // 22.1.3.29 95 static JSTaggedValue Values(EcmaRuntimeCallInfo *argv); 96 // 22.1.3.31 97 static JSTaggedValue Unscopables(EcmaRuntimeCallInfo *argv); 98 // es12 23.1.3.13 99 static JSTaggedValue Includes(EcmaRuntimeCallInfo *argv); 100 // es12 23.1.3.10 101 static JSTaggedValue Flat(EcmaRuntimeCallInfo *argv); 102 // es12 23.1.3.11 103 static JSTaggedValue FlatMap(EcmaRuntimeCallInfo *argv); 104 // 23.1.3.1 Array.prototype.at ( index ) 105 static JSTaggedValue At(EcmaRuntimeCallInfo *argv); 106 // 23.1.3.33 Array.prototype.toReversed ( ) 107 static JSTaggedValue ToReversed(EcmaRuntimeCallInfo *argv); 108 // 23.1.3.39 Array.prototype.with ( index, value ) 109 static JSTaggedValue With(EcmaRuntimeCallInfo *argv); 110 // 23.1.3.34 Array.prototype.toSorted ( comparefn ) 111 static JSTaggedValue ToSorted(EcmaRuntimeCallInfo *argv); 112 // 23.1.3.11 113 static JSTaggedValue FindLast(EcmaRuntimeCallInfo *argv); 114 // 23.1.3.12 115 static JSTaggedValue FindLastIndex(EcmaRuntimeCallInfo *argv); 116 // 23.1.3.35 Array.prototype.toSpliced ( start, skipCount, ...items ) 117 static JSTaggedValue ToSpliced(EcmaRuntimeCallInfo *argv); 118 }; 119 } // namespace panda::ecmascript::builtins 120 121 #endif // ECMASCRIPT_BUILTINS_BUILTINS_ARRAY_H 122