Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Compiler_Module_Name_Table.H
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 version 2.0.0b
6 https://github.com/lrleon/Aleph-w
7
8 This file is part of Aleph-w library
9
10 Copyright (c) 2002-2026 Leandro Rabindranath Leon
11
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files (the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29*/
30
42#ifndef COMPILER_MODULE_NAME_TABLE_H
43#define COMPILER_MODULE_NAME_TABLE_H
44
45#include <sstream>
46#include <string>
47
49
50namespace Aleph {
57
67
73
74namespace Compiler_Module_Name_Table_Detail {
81} // namespace Compiler_Module_Name_Table_Detail
82
89 const Compiler_Module_Binding_Result &bindings)
90{
92
93 for (size_t i = 0; i < bindings.modules.size(); ++i)
94 {
95 const auto &source = bindings.modules.access(i);
97 entry.module_name = source.module_name;
98 entry.module_index = source.module_index;
99 entry.order_index = source.order_index;
100
101 for (size_t j = 0; j < source.names.size(); ++j)
102 entry.names.append(source.names.access(j));
103
104 for (size_t j = 0; j < bindings.issues.size(); ++j)
105 {
106 const auto &issue = bindings.issues.access(j);
107 if (issue.module_name != source.module_name)
108 continue;
111 continue;
112
113 bool duplicate = false;
114 for (size_t k = 0; k < entry.ambiguous_names.size(); ++k)
115 {
116 const auto &current = entry.ambiguous_names.access(k);
117 if (current.name == issue.symbol_name
118 and current.namespace_kind
120 {
121 duplicate = true;
122 break;
123 }
124 }
125 if (duplicate)
126 continue;
127
128 entry.ambiguous_names.append(
130 }
131
132 table.modules.append(std::move(entry));
133 }
134
135 return table;
136}
137
144{
145 std::ostringstream out;
146 out << "ModuleNameTable\n";
147 for (size_t i = 0; i < table.modules.size(); ++i)
148 {
149 const auto &module = table.modules.access(i);
150 out << " Module(" << module.module_name << ") order=" << module.order_index << '\n';
151 for (size_t j = 0; j < module.names.size(); ++j)
152 {
153 const auto &item = module.names.access(j);
154 out << " Name(" << compiler_module_export_kind_name(item.kind) << "(" << item.name
155 << ")) -> " << item.provider_module_name << ' '
156 << (item.imported ? "imported" : "local") << '\n';
157 }
158 for (size_t j = 0; j < module.ambiguous_names.size(); ++j)
159 {
160 const auto &item = module.ambiguous_names.access(j);
161 out << " Ambiguous(" << compiler_module_export_kind_name(item.namespace_kind) << "("
162 << item.name << "))\n";
163 }
164 }
165 return out.str();
166}
167} // namespace Aleph
168
169#endif
Reusable binding helpers for linked module surfaces.
size_t size_t int32_t * out
Definition ca-c-api.h:120
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
Compiler_Module_Export_Kind issue_namespace_kind(const Compiler_Module_Binding_Issue_Kind kind) noexcept
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Compiler_Module_Export_Kind
Export kinds currently modeled by reusable module metadata.
Compiler_Module_Binding_Issue_Kind
Structural issues emitted while binding linked module surfaces.
and
Check uniqueness with explicit hash + equality functors.
Compiler_Module_Name_Table compiler_build_module_name_table(const Compiler_Module_Binding_Result &bindings)
Builds one reusable per-module name table from bindings.
const char * compiler_module_export_kind_name(const Compiler_Module_Export_Kind kind) noexcept
Returns the stable debug name for one module-export kind.
std::string compiler_render_module_name_table(const Compiler_Module_Name_Table &table)
Renders one deterministic text artifact for cached module names.
One ambiguous name tracked in a per-module name table.
Binding result over one linked module-surface view.
DynArray< Compiler_Module_Bindings > modules
DynArray< Compiler_Module_Binding_Issue > issues
Cached top-level names for one module.
DynArray< Compiler_Module_Ambiguous_Name > ambiguous_names
DynArray< Compiler_Module_Bound_Name > names
size_t order_index
std::string module_name
size_t module_index
Cached top-level name table over all visible modules.
DynArray< Compiler_Module_Name_Table_Entry > modules
static int * k