1 /* 2 * Copyright (c) 2021-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 #ifndef PANDA_ASSEMBLER_PANDASM_H 17 #define PANDA_ASSEMBLER_PANDASM_H 18 19 #include "utils/pandargs.h" 20 21 namespace ark::pandasm { 22 23 void PrintError(const ark::pandasm::Error &e, const std::string &msg); 24 25 void PrintErrors(const ark::pandasm::ErrorList &warnings, const std::string &msg); 26 27 // CC-OFFNXT(G.FUN.01-CPP) solid logic 28 bool PrepareArgs(ark::PandArgParser &paParser, const ark::PandArg<std::string> &inputFile, 29 const ark::PandArg<std::string> &outputFile, const ark::PandArg<std::string> &logFile, 30 const ark::PandArg<bool> &help, const ark::PandArg<bool> &verbose, std::ifstream &inputfile, int argc, 31 char **argv); 32 33 bool Tokenize(ark::pandasm::Lexer &lexer, std::vector<std::vector<ark::pandasm::Token>> &tokens, 34 std::ifstream &inputfile); 35 36 bool ParseProgram(ark::pandasm::Parser &parser, std::vector<std::vector<ark::pandasm::Token>> &tokens, 37 const ark::PandArg<std::string> &inputFile, 38 ark::Expected<ark::pandasm::Program, ark::pandasm::Error> &res); 39 40 bool DumpProgramInJson(ark::pandasm::Program &program, const ark::PandArg<std::string> &scopesFile); 41 42 bool EmitProgramInBinary(ark::pandasm::Program &program, ark::PandArgParser &paParser, 43 const ark::PandArg<std::string> &outputFile, ark::PandArg<bool> &optimize, 44 ark::PandArg<bool> &sizeStat); 45 46 // CC-OFFNXT(G.FUN.01-CPP) solid logic 47 bool BuildFiles(ark::pandasm::Program &program, ark::PandArgParser &paParser, 48 const ark::PandArg<std::string> &outputFile, ark::PandArg<bool> &optimize, ark::PandArg<bool> &sizeStat, 49 ark::PandArg<std::string> &scopesFile); 50 51 } // namespace ark::pandasm 52 53 #endif // PANDA_ASSEMBLER_PANDASM_H 54