/* Elna frontend specific diagnostic routines. Copyright (C) 2025 Free Software Foundation, Inc. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ #include "elna/gcc/elna-diagnostic.h" #include "elna/gcc/elna-tree.h" #include "elna/gcc/elna1.h" namespace elna { namespace gcc { location_t get_location(const boot::position *position) { linemap_line_start(line_table, position->line, 0); return linemap_position_for_column(line_table, position->column); } std::string print_type(tree type) { gcc_assert(TYPE_P(type)); if (type == elna_int_type_node) { return "Int"; } else if (type == elna_word_type_node) { return "Word"; } else if (type == elna_bool_type_node) { return "Bool"; } else if (type == elna_byte_type_node) { return "Byte"; } else if (type == elna_float_type_node) { return "Float"; } else if (type == elna_char_type_node) { return "Char"; } else if (is_pointer_type(type)) { return std::string("\"pointer to " + print_type(TREE_TYPE(type)) + "\""); } else if (TREE_CODE(type) == ARRAY_TYPE) { return "array"; } else if (TREE_CODE(type) == RECORD_TYPE) { return "record"; } else if (TREE_CODE(type) == UNION_TYPE) { return "union"; } else { return "<>"; } } } }