• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_JSARGUMENTS_H
17 #define ECMASCRIPT_JSARGUMENTS_H
18 
19 #include "ecmascript/js_object.h"
20 #include "ecmascript/tagged_array.h"
21 
22 namespace panda::ecmascript {
23 class JSThread;
24 
25 class JSArguments : public JSObject {
26 public:
27     static constexpr int LENGTH_OF_INLINE_PROPERTIES = 4;
28     static constexpr int LENGTH_INLINE_PROPERTY_INDEX = 0;
29     static constexpr int ITERATOR_INLINE_PROPERTY_INDEX = 1;
30     static constexpr int CALLER_INLINE_PROPERTY_INDEX = 2;
31     static constexpr int CALLEE_INLINE_PROPERTY_INDEX = 3;
32 
33     CAST_NO_CHECK(JSArguments);
34 
35     // 9.4.4.1 [[GetOwnProperty]] (P)
36     static bool GetOwnProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key,
37                                PropertyDescriptor &desc);
38     // 9.4.4.2 [[DefineOwnProperty]] (P, Desc)
39     static bool DefineOwnProperty(JSThread *thread, const JSHandle<JSArguments> &args,
40                                   const JSHandle<JSTaggedValue> &key, const PropertyDescriptor &desc);
41     // 9.4.4.3 [[Get]] (P, Receiver)
GetProperty(JSThread * thread,const JSHandle<JSObject> & obj,const JSHandle<JSTaggedValue> & key)42     static inline OperationResult GetProperty(JSThread *thread, const JSHandle<JSObject> &obj,
43                                               const JSHandle<JSTaggedValue> &key)
44     {
45         return GetProperty(thread, JSHandle<JSArguments>::Cast(obj), key, JSHandle<JSTaggedValue>::Cast(obj));
46     }
47     static OperationResult GetProperty(JSThread *thread, const JSHandle<JSArguments> &args,
48                                        const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &receiver);
49     // 9.4.4.4 [[Set]] ( P, V, Receiver)
SetProperty(JSThread * thread,const JSHandle<JSObject> & obj,const JSHandle<JSTaggedValue> & key,const JSHandle<JSTaggedValue> & value)50     static inline bool SetProperty(JSThread *thread, const JSHandle<JSObject> &obj, const JSHandle<JSTaggedValue> &key,
51                                    const JSHandle<JSTaggedValue> &value)
52     {
53         return SetProperty(thread, JSHandle<JSArguments>::Cast(obj), key, value, JSHandle<JSTaggedValue>::Cast(obj));
54     }
55     static bool SetProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key,
56                             const JSHandle<JSTaggedValue> &value, const JSHandle<JSTaggedValue> &receiver);
57     // 9.4.4.5 [[Delete]] (P)
58     static bool DeleteProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key);
59     // 9.4.4.6 CreateUnmappedArgumentsObject(argumentsList)
60     // 9.4.4.7 CreateMappedArgumentsObject ( func, formals, argumentsList, env )
61 };
62 }  // namespace panda::ecmascript
63 
64 #endif  // ECMASCRIPT_JSARGUMENTS_H
65