Translate position to a GCC location
This commit is contained in:
75
gcc/elna1.cc
75
gcc/elna1.cc
@ -10,15 +10,14 @@
|
||||
#include "fold-const.h"
|
||||
#include "stor-layout.h"
|
||||
#include "debug.h"
|
||||
#include "convert.h"
|
||||
#include "langhooks.h"
|
||||
#include "langhooks-def.h"
|
||||
#include "common/common-target.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <elna/source/driver.h>
|
||||
#include "elna/source/semantic.h"
|
||||
#include "elna/gcc/generic-visitor.h"
|
||||
#include "elna/gcc/elna-generic.h"
|
||||
#include "elna/gcc/elna-diagnostic.h"
|
||||
#include "parser.hh"
|
||||
|
||||
/* Language-dependent contents of a type. */
|
||||
@ -61,72 +60,50 @@ struct GTY (()) language_function
|
||||
int dummy;
|
||||
};
|
||||
|
||||
/* Creates an expression whose value is that of EXPR, converted to type TYPE.
|
||||
This function implements all reasonable scalar conversions. */
|
||||
|
||||
tree
|
||||
convert (tree type, tree expr)
|
||||
{
|
||||
return expr;
|
||||
}
|
||||
|
||||
/* Language hooks. */
|
||||
|
||||
static bool
|
||||
elna_langhook_init (void)
|
||||
static bool elna_langhook_init(void)
|
||||
{
|
||||
/* NOTE: Newer versions of GCC use only:
|
||||
build_common_tree_nodes (false);
|
||||
See Eugene's comment in the comments section. */
|
||||
build_common_tree_nodes (false);
|
||||
build_common_tree_nodes (false);
|
||||
|
||||
/* I don't know why this has to be done explicitly. */
|
||||
void_list_node = build_tree_list (NULL_TREE, void_type_node);
|
||||
/* I don't know why this has to be done explicitly. */
|
||||
void_list_node = build_tree_list (NULL_TREE, void_type_node);
|
||||
|
||||
build_common_builtin_nodes ();
|
||||
build_common_builtin_nodes ();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr std::size_t pointer_size = 4;
|
||||
|
||||
static void
|
||||
elna_parse_file (const char *filename)
|
||||
static void elna_parse_file (const char *filename)
|
||||
{
|
||||
std::ifstream file{ filename, std::ios::in };
|
||||
std::ifstream file{ filename, std::ios::in };
|
||||
|
||||
if (!file)
|
||||
if (!file)
|
||||
{
|
||||
fatal_error (UNKNOWN_LOCATION, "cannot open filename %s: %m", filename);
|
||||
fatal_error(UNKNOWN_LOCATION, "cannot open filename %s: %m", filename);
|
||||
}
|
||||
|
||||
elna::source::driver driver{ filename };
|
||||
elna::source::lexer lexer(file);
|
||||
yy::parser parser(lexer, driver);
|
||||
elna::source::driver driver{ filename };
|
||||
elna::source::lexer lexer(file);
|
||||
yy::parser parser(lexer, driver);
|
||||
|
||||
if (auto result = parser())
|
||||
linemap_add(line_table, LC_ENTER, 0, filename, 1);
|
||||
if (auto result = parser())
|
||||
{
|
||||
for (const auto& error : driver.errors())
|
||||
for (const auto& error : driver.errors())
|
||||
{
|
||||
linemap_add (line_table, LC_ENTER, 0, filename, 1);
|
||||
auto gcc_location = elna_gcc_location(&error->position);
|
||||
|
||||
linemap_line_start (line_table, error->line (), 0);
|
||||
auto gcc_location = linemap_position_for_column (line_table, error->column ());
|
||||
linemap_add (line_table, LC_LEAVE, 0, NULL, 0);
|
||||
|
||||
error_at (gcc_location, error->what ().c_str ());
|
||||
error_at(gcc_location, error->what().c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
auto symbol_table = elna::source::add_builtin_symbols();
|
||||
elna::source::name_analysis_visitor name_analysis_visitor{ symbol_table, filename, pointer_size };
|
||||
elna::source::type_analysis_visitor type_analysis_visitor{ symbol_table, filename, pointer_size };
|
||||
elna::gcc::generic_visitor generic_visitor;
|
||||
else
|
||||
{
|
||||
elna::gcc::generic_visitor generic_visitor;
|
||||
|
||||
name_analysis_visitor.visit(driver.tree.get());
|
||||
type_analysis_visitor.visit(driver.tree.get());
|
||||
generic_visitor.visit(driver.tree.get());
|
||||
generic_visitor.visit(driver.tree.get());
|
||||
}
|
||||
linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user