Support one hardcoded import
This commit is contained in:
@ -29,16 +29,14 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "stringpool.h"
|
||||
#include "diagnostic.h"
|
||||
#include "realmpfr.h"
|
||||
#include "stor-layout.h"
|
||||
#include "varasm.h"
|
||||
#include "fold-const.h"
|
||||
#include "langhooks.h"
|
||||
|
||||
namespace elna::gcc
|
||||
{
|
||||
generic_visitor::generic_visitor(std::shared_ptr<symbol_table> symbol_table,
|
||||
std::shared_ptr<boot::symbol_table> info_table)
|
||||
: symbols(symbol_table), info_table(info_table)
|
||||
generic_visitor::generic_visitor(std::shared_ptr<symbol_table> symbol_table, elna::boot::symbol_bag bag)
|
||||
: symbols(symbol_table), bag(bag)
|
||||
{
|
||||
}
|
||||
|
||||
@ -321,7 +319,7 @@ namespace elna::gcc
|
||||
DECL_STRUCT_FUNCTION(fndecl)->language = ggc_cleared_alloc<language_function>();
|
||||
|
||||
enter_scope();
|
||||
this->info_table = this->info_table->lookup(definition->identifier.identifier)->is_procedure()->symbols;
|
||||
this->bag.enter(this->bag.lookup(definition->identifier.identifier)->is_procedure()->symbols);
|
||||
|
||||
tree argument_chain = DECL_ARGUMENTS(fndecl);
|
||||
for (; argument_chain != NULL_TREE; argument_chain = TREE_CHAIN(argument_chain))
|
||||
@ -339,7 +337,7 @@ namespace elna::gcc
|
||||
visit_statements(definition->body.value().body());
|
||||
|
||||
tree mapping = leave_scope();
|
||||
this->info_table = this->info_table->scope();
|
||||
this->bag.leave();
|
||||
|
||||
BLOCK_SUPERCONTEXT(BIND_EXPR_BLOCK(mapping)) = fndecl;
|
||||
DECL_INITIAL(fndecl) = BIND_EXPR_BLOCK(mapping);
|
||||
@ -746,7 +744,7 @@ namespace elna::gcc
|
||||
void generic_visitor::visit(boot::variable_declaration *declaration)
|
||||
{
|
||||
this->current_expression = get_inner_alias(
|
||||
this->info_table->lookup(declaration->identifier.identifier)->is_variable()->symbol,
|
||||
this->bag.lookup(declaration->identifier.identifier)->is_variable()->symbol,
|
||||
this->symbols);
|
||||
|
||||
location_t declaration_location = get_location(&declaration->position());
|
||||
|
49
gcc/elna1.cc
49
gcc/elna1.cc
@ -64,15 +64,17 @@ static bool elna_langhook_init(void)
|
||||
|
||||
static void elna_parse_file(const char *filename)
|
||||
{
|
||||
std::ifstream file{ filename, std::ios::in };
|
||||
|
||||
if (!file)
|
||||
{
|
||||
fatal_error(UNKNOWN_LOCATION, "cannot open filename %s: %m", filename);
|
||||
}
|
||||
elna::boot::dependency_graph outcome = elna::boot::read_sources(file, filename);
|
||||
|
||||
std::shared_ptr<elna::boot::symbol_table> info_table = elna::boot::builtin_symbol_table();
|
||||
auto x = std::make_shared<elna::boot::symbol_table>(info_table);
|
||||
elna::boot::dependency dependency = elna::boot::read_sources("source/Common.elna", x);
|
||||
|
||||
linemap_add(line_table, LC_ENTER, 0, "source/Common.elna", 1);
|
||||
if (dependency.has_errors())
|
||||
{
|
||||
elna::gcc::report_errors(dependency.errors());
|
||||
}
|
||||
auto y = std::make_shared<elna::boot::symbol_table>(info_table);
|
||||
elna::boot::dependency outcome = elna::boot::read_sources(filename, y, x);
|
||||
std::shared_ptr<elna::gcc::symbol_table> symbol_table = elna::gcc::builtin_symbol_table();
|
||||
|
||||
linemap_add(line_table, LC_ENTER, 0, filename, 1);
|
||||
@ -82,34 +84,11 @@ static void elna_parse_file(const char *filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const std::unique_ptr<elna::boot::program>& module_tree : outcome.modules)
|
||||
{
|
||||
elna::boot::declaration_visitor declaration_visitor(filename);
|
||||
declaration_visitor.visit(module_tree.get());
|
||||
elna::gcc::rewrite_symbol_table(x, symbol_table);
|
||||
elna::gcc::rewrite_symbol_table(y, symbol_table);
|
||||
|
||||
if (declaration_visitor.errors().empty())
|
||||
{
|
||||
elna::boot::name_analysis_visitor name_analysis_visitor(filename, info_table,
|
||||
std::move(declaration_visitor.unresolved));
|
||||
name_analysis_visitor.visit(module_tree.get());
|
||||
|
||||
if (name_analysis_visitor.errors().empty())
|
||||
{
|
||||
elna::gcc::rewrite_symbol_table(info_table, symbol_table);
|
||||
|
||||
elna::gcc::generic_visitor generic_visitor{ symbol_table, info_table };
|
||||
generic_visitor.visit(module_tree.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
elna::gcc::report_errors(name_analysis_visitor.errors());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
elna::gcc::report_errors(declaration_visitor.errors());
|
||||
}
|
||||
}
|
||||
elna::gcc::generic_visitor generic_visitor{ symbol_table, outcome.bag };
|
||||
outcome.tree->accept(&generic_visitor);
|
||||
}
|
||||
linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user