• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024 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 "abc2program_compiler.h"
17 #include <iostream>
18 #include "abc_file_processor.h"
19 
20 namespace ark::abc2program {
21 
OpenAbcFile(const std::string & filePath)22 bool Abc2ProgramCompiler::OpenAbcFile(const std::string &filePath)
23 {
24     file_ = panda_file::File::Open(filePath);
25     if (file_ == nullptr) {
26         std::cerr << "Unable to open specified abc file " << filePath << std::endl;
27         return false;
28     }
29     stringTable_ = std::make_unique<AbcStringTable>(*file_);
30     return true;
31 }
32 
GetAbcFile() const33 const panda_file::File &Abc2ProgramCompiler::GetAbcFile() const
34 {
35     return *file_;
36 }
37 
GetAbcStringTable() const38 AbcStringTable &Abc2ProgramCompiler::GetAbcStringTable() const
39 {
40     return *stringTable_;
41 }
42 
FillProgramData(pandasm::Program & program)43 bool Abc2ProgramCompiler::FillProgramData(pandasm::Program &program)
44 {
45     keyData_ = std::make_unique<Abc2ProgramKeyData>(*file_, *stringTable_, program);
46     AbcFileProcessor fileProcessor(*keyData_);
47     bool success = fileProcessor.ProcessFile();
48     return success;
49 }
50 
51 }  // namespace ark::abc2program
52