Move source reading into a function
This commit is contained in:
41
include/elna/boot/dependency.h
Normal file
41
include/elna/boot/dependency.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* Dependency graph analysis.
|
||||
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/>. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include "elna/boot/result.h"
|
||||
#include "elna/boot/ast.h"
|
||||
|
||||
namespace elna::boot
|
||||
{
|
||||
class dependency_graph
|
||||
{
|
||||
error_list m_errors;
|
||||
|
||||
public:
|
||||
std::vector<std::unique_ptr<program>> modules;
|
||||
|
||||
bool has_errors() const;
|
||||
const error_list& errors() const;
|
||||
|
||||
dependency_graph();
|
||||
explicit dependency_graph(error_list&& errors);
|
||||
};
|
||||
|
||||
dependency_graph read_sources(std::istream& entry_point, const char *entry_path);
|
||||
}
|
@ -61,17 +61,19 @@ namespace elna::boot
|
||||
std::size_t column() const;
|
||||
};
|
||||
|
||||
using error_list = typename std::deque<std::unique_ptr<error>>;
|
||||
|
||||
class error_container
|
||||
{
|
||||
protected:
|
||||
std::deque<std::unique_ptr<error>> m_errors;
|
||||
error_list m_errors;
|
||||
|
||||
error_container(const char *input_file);
|
||||
|
||||
public:
|
||||
const char *input_file;
|
||||
|
||||
std::deque<std::unique_ptr<error>>& errors();
|
||||
error_list& errors();
|
||||
|
||||
template<typename T, typename... Args>
|
||||
void add_error(Args... arguments)
|
||||
@ -102,5 +104,4 @@ namespace elna::boot
|
||||
T proper_type{};
|
||||
bool no_return{ false };
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ 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/>. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
namespace elna::gcc
|
||||
{
|
||||
std::deque<std::unique_ptr<boot::error>> do_semantic_analysis(const char *path,
|
||||
std::unique_ptr<boot::program>& ast, std::shared_ptr<boot::symbol_table> info_table,
|
||||
const std::unique_ptr<boot::program>& ast, std::shared_ptr<boot::symbol_table> info_table,
|
||||
std::shared_ptr<symbol_table> symbols, std::unordered_map<std::string, tree>& unresolved);
|
||||
tree handle_symbol(const std::string& symbol_name, std::shared_ptr<boot::alias_type> reference,
|
||||
std::shared_ptr<symbol_table> symbols, std::unordered_map<std::string, tree>& unresolved,
|
||||
|
Reference in New Issue
Block a user