• 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 #include "compilerContext.h"
17 
18 #include <compiler/core/emitter/emitter.h>
19 #include <typescript/extractor/typeRecorder.h>
20 
21 namespace panda::es2panda::compiler {
22 
CompilerContext(binder::Binder * binder,bool isDebug,bool isDebuggerEvaluateExpressionMode,bool isMergeAbc,bool isTypeExtractorEnabled,bool isJsonInputFile,std::string sourceFile,std::string pkgName,util::StringView recordName,util::PatchFix * patchFixHelper)23 CompilerContext::CompilerContext(binder::Binder *binder, bool isDebug, bool isDebuggerEvaluateExpressionMode,
24                                  bool isMergeAbc, bool isTypeExtractorEnabled, bool isJsonInputFile,
25                                  std::string sourceFile, std::string pkgName, util::StringView recordName,
26                                  util::PatchFix *patchFixHelper)
27     : binder_(binder), isDebug_(isDebug), isDebuggerEvaluateExpressionMode_(isDebuggerEvaluateExpressionMode),
28       isMergeAbc_(isMergeAbc), isTypeExtractorEnabled_(isTypeExtractorEnabled), isJsonInputFile_(isJsonInputFile),
29       sourceFile_(sourceFile), pkgName_(pkgName), recordName_(recordName), patchFixHelper_(patchFixHelper),
30       emitter_(std::make_unique<class Emitter>(this))
31 {
32 }
33 
SetTypeRecorder(extractor::TypeRecorder * recorder)34 void CompilerContext::SetTypeRecorder(extractor::TypeRecorder *recorder)
35 {
36     ASSERT(emitter_ != nullptr);
37     emitter_->FillTypeLiteralBuffers(recorder);
38     recorder_ = recorder;
39 }
40 
SetTypeExtractor(extractor::TypeExtractor * extractor)41 void CompilerContext::SetTypeExtractor(extractor::TypeExtractor *extractor)
42 {
43     extractor_ = extractor;
44 }
45 
46 }  // namespace panda::es2panda::compiler
47