• 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 
GetInlinedPropertyOffset(uint32_t index)35     static constexpr uint32_t GetInlinedPropertyOffset(uint32_t index)
36     {
37         return JSObject::SIZE + index * JSTaggedValue::TaggedTypeSize();
38     }
39 
40     // 9.4.4.1 [[GetOwnProperty]] (P)
41     static bool GetOwnProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key,
42                                PropertyDescriptor &desc);
43     // 9.4.4.2 [[DefineOwnProperty]] (P, Desc)
44     static bool DefineOwnProperty(JSThread *thread, const JSHandle<JSArguments> &args,
45                                   const JSHandle<JSTaggedValue> &key, const PropertyDescriptor &desc);
46     // 9.4.4.3 [[Get]] (P, Receiver)
GetProperty(JSThread * thread,const JSHandle<JSObject> & obj,const JSHandle<JSTaggedValue> & key)47     static inline OperationResult GetProperty(JSThread *thread, const JSHandle<JSObject> &obj,
48                                               const JSHandle<JSTaggedValue> &key)
49     {
50         return GetProperty(thread, JSHandle<JSArguments>::Cast(obj), key, JSHandle<JSTaggedValue>::Cast(obj));
51     }
52     static OperationResult GetProperty(JSThread *thread, const JSHandle<JSArguments> &args,
53                                        const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &receiver);
54     // 9.4.4.4 [[Set]] ( P, V, Receiver)
SetProperty(JSThread * thread,const JSHandle<JSObject> & obj,const JSHandle<JSTaggedValue> & key,const JSHandle<JSTaggedValue> & value)55     static inline bool SetProperty(JSThread *thread, const JSHandle<JSObject> &obj, const JSHandle<JSTaggedValue> &key,
56                                    const JSHandle<JSTaggedValue> &value)
57     {
58         return SetProperty(thread, JSHandle<JSArguments>::Cast(obj), key, value, JSHandle<JSTaggedValue>::Cast(obj));
59     }
60     static bool SetProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key,
61                             const JSHandle<JSTaggedValue> &value, const JSHandle<JSTaggedValue> &receiver);
62     // 9.4.4.5 [[Delete]] (P)
63     static bool DeleteProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key);
64     // 9.4.4.6 CreateUnmappedArgumentsObject(argumentsList)
65     // 9.4.4.7 CreateMappedArgumentsObject ( func, formals, argumentsList, env )
66 };
67 }  // namespace panda::ecmascript
68 
69 #endif  // ECMASCRIPT_JSARGUMENTS_H
70