• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ES2PANDA_COMPILER_INCLUDE_COMPILER_IMPL_H
17 #define ES2PANDA_COMPILER_INCLUDE_COMPILER_IMPL_H
18 
19 #include <es2panda.h>
20 #include <macros.h>
21 #include <mem/arena_allocator.h>
22 #include <os/thread.h>
23 #include <typescript/extractor/typeExtractor.h>
24 #include <util/patchFix.h>
25 
26 #include <string>
27 
28 namespace panda::pandasm {
29 struct Program;
30 }  // namespace panda::pandasm
31 
32 namespace panda::es2panda::parser {
33 class Program;
34 }  // namespace panda::es2panda::parser
35 
36 namespace panda::es2panda::compiler {
37 class CompileFuncQueue;
38 
39 class CompilerImpl {
40 public:
CompilerImpl(size_t threadCount)41     explicit CompilerImpl(size_t threadCount): threadCount_(threadCount) {}
42     ~CompilerImpl();
43     NO_COPY_SEMANTIC(CompilerImpl);
44     NO_MOVE_SEMANTIC(CompilerImpl);
45 
46     panda::pandasm::Program *Compile(parser::Program *program, const es2panda::CompilerOptions &options,
47                                      const std::string &debugInfoSourceFile, const std::string &pkgName);
48     static void DumpAsm(const panda::pandasm::Program *prog);
49 
AddPatchFixHelper(util::PatchFix * patchFixHelper)50     void AddPatchFixHelper(util::PatchFix *patchFixHelper)
51     {
52         patchFixHelper_ = patchFixHelper;
53     }
54 
55 private:
56     size_t threadCount_ {0};
57     CompileFuncQueue *queue_ {nullptr};
58     util::PatchFix *patchFixHelper_ {nullptr};
59     std::unique_ptr<extractor::TypeExtractor> extractor_ {};
60 };
61 }  // namespace panda::es2panda::compiler
62 
63 #endif
64