Files
elna/include/elna/boot/dependency.h

56 lines
1.7 KiB
C++

/* 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 <filesystem>
#include <fstream>
#include "elna/boot/result.h"
#include "elna/boot/ast.h"
#include "elna/boot/symbol.h"
namespace elna::boot
{
class dependency : public error_container
{
error_list m_errors;
public:
std::unique_ptr<unit> tree;
std::unordered_map<std::string, std::shared_ptr<alias_type>> unresolved;
explicit dependency(const char *path);
};
dependency read_source(std::istream& entry_point, const char *entry_path);
std::filesystem::path build_path(const std::vector<std::string>& segments);
error_list analyze_semantics(const char *path, std::unique_ptr<unit>& tree, symbol_bag bag);
template<typename T>
struct dependency_state
{
const std::shared_ptr<symbol_table> globals;
T custom;
std::unordered_map<std::filesystem::path, symbol_bag> cache;
explicit dependency_state(T custom)
: globals(elna::boot::builtin_symbol_table()), custom(custom)
{
}
};
}