1 /* 2 * Copyright (c) 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 TS2PANDA_TS2ABC_TS2ABC_H_ 17 #define TS2PANDA_TS2ABC_TS2ABC_H_ 18 19 #include <codecvt> 20 #include <cstdarg> 21 #include <iostream> 22 #include <locale> 23 #include <string> 24 #include <unistd.h> 25 26 #include "assembly-type.h" 27 #include "assembly-program.h" 28 #include "assembly-emitter.h" 29 #include "json/json.h" 30 31 namespace panda::ts2abc { 32 enum class JsonType { 33 FUNCTION = 0, 34 RECORD, 35 STRING, 36 LITERALBUFFER, 37 MODULE, 38 OPTIONS, 39 TYPEINFO, 40 RECORDNAME, 41 OUTPUTFILENAME, 42 INPUTJSONFILECONTENT 43 }; 44 45 constexpr int RETURN_SUCCESS = 0; 46 constexpr int RETURN_FAILED = 1; 47 48 enum class OptLevel { 49 O_LEVEL0 = 0, 50 O_LEVEL1, 51 O_LEVEL2 52 }; 53 54 bool HandleJsonFile(const std::string &input, std::string &data); 55 bool GenerateProgram(const std::string &data, const std::string &output, panda::ts2abc::Options options); 56 bool GenerateProgramsFromPipe(const panda::ts2abc::Options &options); 57 bool CompileNpmEntries(const std::string &input, const std::string &output); 58 bool GetDebugLog(); 59 void ParseLogEnable(const Json::Value &rootValue); 60 bool GetDebugModeEnabled(); 61 void ParseDebugMode(const Json::Value &rootValue); 62 std::string ParseString(const std::string &data); 63 int ParseJson(const std::string &data, Json::Value &rootValue); 64 panda::pandasm::Function GetFunctionDefintion(const Json::Value &function); 65 } // namespace panda::ts2abc 66 67 #endif // TS2PANDA_TS2ABC_TS2ABC_H_ 68