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 "abc_file_utils.h" 17 #include <iostream> 18 #include "os/file.h" 19 20 namespace panda::abc2program { 21 IsGlobalTypeName(const std::string & type_name)22bool AbcFileUtils::IsGlobalTypeName(const std::string &type_name) 23 { 24 return (type_name == GLOBAL_TYPE_NAME); 25 } 26 IsArrayTypeName(const std::string & type_name)27bool AbcFileUtils::IsArrayTypeName(const std::string &type_name) 28 { 29 return (type_name.find(ARRAY_TYPE_PREFIX) != std::string::npos); 30 } 31 IsESTypeAnnotationName(const std::string & type_name)32bool AbcFileUtils::IsESTypeAnnotationName(const std::string &type_name) 33 { 34 return (type_name == ES_TYPE_ANNOTATION_NAME); 35 } 36 IsSystemTypeName(const std::string & type_name)37bool AbcFileUtils::IsSystemTypeName(const std::string &type_name) 38 { 39 return (IsGlobalTypeName(type_name) || IsArrayTypeName(type_name)); 40 } 41 GetLabelNameByInstIdx(size_t inst_idx)42std::string AbcFileUtils::GetLabelNameByInstIdx(size_t inst_idx) 43 { 44 std::stringstream name; 45 name << LABEL_PREFIX << inst_idx; 46 return name.str(); 47 } 48 49 } // namespace panda::abc2program 50