Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Compiler_Module_Metadata.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
41#ifndef COMPILER_MODULE_METADATA_H
42#define COMPILER_MODULE_METADATA_H
43
44#include <sstream>
45#include <string>
46
47#include <ah-source.H>
48#include <tpl_dynArray.H>
49
50namespace Aleph {
53{
55 Global,
56 Type
57};
58
61{
62 switch (kind)
63 {
65 return "Function";
67 return "Global";
69 return "Type";
70 }
71
72 return "Unknown";
73}
74
82
90
93{
94 std::ostringstream out;
95 out << "ModuleMetadata\n";
96 for (size_t i = 0; i < modules.size(); ++i)
97 {
98 const auto &module = modules.access(i);
99 out << " Module(" << module.name << ")";
100 if (module.span.is_valid())
101 out << " @" << module.span.to_string();
102 out << '\n';
103
104 for (size_t j = 0; j < module.exports.size(); ++j)
105 {
106 const auto &item = module.exports.access(j);
107 out << " " << compiler_module_export_kind_name(item.kind) << "(" << item.name << ")";
108 if (item.declaration_span.is_valid())
109 out << " @" << item.declaration_span.to_string();
110 out << '\n';
111 }
112 }
113 return out.str();
114}
115} // namespace Aleph
116
117#endif
Source file and span management utilities for compiler-style tooling.
size_t size_t int32_t * out
Definition ca-c-api.h:120
size_t size() const noexcept
Return the current dimension of array.
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Compiler_Module_Export_Kind
Export kinds currently modeled by reusable module metadata.
std::string compiler_render_module_metadata(const DynArray< Compiler_Module_Metadata > &modules)
Renders one deterministic text artifact for module metadata.
const char * compiler_module_export_kind_name(const Compiler_Module_Export_Kind kind) noexcept
Returns the stable debug name for one module-export kind.
@ Function
Function type such as fn(Int) -> Bool.
One reusable top-level declaration exposed by a module surface.
Compiler_Module_Export_Kind kind
Reusable metadata describing one parsed or analyzed module surface.
DynArray< Compiler_Module_Export > exports
Visible top-level declarations contributed by the module.
Source_Span span
Full module span when available.
std::string name
Stable module/source name.
Half-open byte range inside a source file.
Definition ah-source.H:100
Lazy and scalable dynamic array implementation.