• 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_JSPANDAFILE_PROGRAM_H
17 #define ECMASCRIPT_JSPANDAFILE_PROGRAM_H
18 
19 #include "ecmascript/ecma_macros.h"
20 #include "ecmascript/js_tagged_value-inl.h"
21 
22 namespace panda {
23 namespace ecmascript {
24 class JSThread;
25 class NativeAreaAllocator;
26 
27 class Program : public ECMAObject {
28 public:
29     DECL_CAST(Program)
30 
31     static constexpr size_t MAIN_FUNCTION_OFFSET = ECMAObject::SIZE;
32     ACCESSORS(MainFunction, MAIN_FUNCTION_OFFSET, SIZE)
33 
34     DECL_VISIT_OBJECT(MAIN_FUNCTION_OFFSET, SIZE)
35     DECL_DUMP()
36 };
37 
38 class ConstantPool : public TaggedArray {
39 public:
Cast(ObjectHeader * object)40     static ConstantPool *Cast(ObjectHeader *object)
41     {
42         ASSERT(JSTaggedValue(object).IsTaggedArray());
43         return static_cast<ConstantPool *>(object);
44     }
45 
46     inline JSTaggedValue GetObjectFromCache(uint32_t index) const;
47     DECL_DUMP()
48 };
49 }  // namespace ecmascript
50 }  // namespace panda
51 #endif  // ECMASCRIPT_JSPANDAFILE_PROGRAM_H
52