elna/gcc/elna-diagnostic.cc

38 lines
747 B
C++
Raw Normal View History

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"
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
{
2024-12-28 14:33:35 +01:00
location_t get_location(const elna::source::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
const char *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));
if (type == integer_type_node)
{
return "Int";
}
else if (type == boolean_type_node)
{
2024-12-31 18:10:34 +01:00
return "Bool";
2024-12-28 14:33:35 +01:00
}
2024-12-31 18:10:34 +01:00
else if (type == double_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
}
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
}