elna/gcc/elna-diagnostic.cc

84 lines
2.1 KiB
C++
Raw Normal View History

/* 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
<http://www.gnu.org/licenses/>. */
2024-12-27 23:38:25 +01:00
#include "elna/gcc/elna-diagnostic.h"
2024-12-29 22:28:53 +01:00
#include "elna/gcc/elna-tree.h"
2025-02-11 01:37:55 +01:00
#include "elna/gcc/elna1.h"
2024-12-27 23:38:25 +01:00
2024-12-28 14:33:35 +01:00
namespace elna
2024-12-27 23:38:25 +01:00
{
2024-12-28 14:33:35 +01:00
namespace gcc
2024-12-27 23:38:25 +01:00
{
2025-01-31 09:46:17 +01:00
location_t get_location(const boot::position *position)
2024-12-27 23:38:25 +01:00
{
2024-12-28 14:33:35 +01:00
linemap_line_start(line_table, position->line, 0);
return linemap_position_for_column(line_table, position->column);
2024-12-27 23:38:25 +01:00
}
2024-12-28 14:33:35 +01:00
std::string print_type(tree type)
2024-12-27 23:38:25 +01:00
{
2024-12-28 14:33:35 +01:00
gcc_assert(TYPE_P(type));
2025-02-11 01:37:55 +01:00
if (type == elna_int_type_node)
2024-12-28 14:33:35 +01:00
{
return "Int";
}
2025-02-11 01:37:55 +01:00
else if (type == elna_word_type_node)
{
return "Word";
}
2025-02-11 01:37:55 +01:00
else if (type == elna_bool_type_node)
2024-12-28 14:33:35 +01:00
{
2024-12-31 18:10:34 +01:00
return "Bool";
2024-12-28 14:33:35 +01:00
}
2025-02-11 01:37:55 +01:00
else if (type == elna_byte_type_node)
{
return "Byte";
}
else if (type == elna_float_type_node)
2024-12-29 22:28:53 +01:00
{
2024-12-31 18:10:34 +01:00
return "Float";
2024-12-29 22:28:53 +01:00
}
2025-02-11 01:37:55 +01:00
else if (type == elna_char_type_node)
2025-01-01 23:02:19 +01:00
{
return "Char";
}
2025-01-10 23:17:18 +01:00
else if (is_pointer_type(type))
{
return std::string("\"pointer to " + print_type(TREE_TYPE(type)) + "\"");
2025-01-10 23:17:18 +01:00
}
2025-01-18 21:30:11 +01:00
else if (TREE_CODE(type) == ARRAY_TYPE)
2025-01-07 14:37:30 +01:00
{
return "array";
}
2025-01-18 21:30:11 +01:00
else if (TREE_CODE(type) == RECORD_TYPE)
{
return "record";
}
else if (TREE_CODE(type) == UNION_TYPE)
{
return "union";
}
2024-12-28 14:33:35 +01:00
else
{
return "<<unknown-type>>";
}
2024-12-27 23:38:25 +01:00
}
}
2024-12-28 14:33:35 +01:00
}