A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
module.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef A11_FLOW_MODULE_H_
16#define A11_FLOW_MODULE_H_
17
18#include <functional>
19#include <string>
20#include <string_view>
21#include <vector>
22
23#include <absl/container/flat_hash_map.h>
24#include <absl/status/statusor.h>
25
26#include "a11/flow/catalogue.h"
27#include "a11/flow/limits.h"
28#include "a11/flow/parser.h"
29
30namespace a11::flow {
33 std::string identity;
34 std::string source;
35};
36
37using ModuleSources = absl::flat_hash_map<std::string, std::string>;
38using ModuleResolver = std::function<absl::StatusOr<ModuleSource>(
39 std::string_view reference, std::string_view importer)>;
40
43
46 std::string identity;
47 size_t start = 0;
48 size_t end = 0;
49};
50
53 std::string name;
54 std::string target;
55 std::string source;
57 size_t scope_start = 0;
58 size_t scope_end = 0;
59 bool scoped = false;
60 bool type = false;
61 bool selection = false;
62 std::string intrinsic = {};
63 bool module = false;
64};
65
67 size_t start = 0;
68 size_t end = 0;
69};
70
73 std::string source;
75 std::vector<ModuleRange> documents;
76 std::vector<ModuleMember> members;
77 std::vector<ImportSelection> selections;
78
79 bool SelectingImport(size_t offset) const;
80
83 size_t offset, bool import_selection = true,
85 CompilationBudget* absl_nullable budget = nullptr) const;
86
88 void Locate(std::vector<Diagnostic>& diagnostics) const;
89};
90
92LinkedModule LinkModules(std::string source, std::string identity,
93 const ModuleSources& sources = {},
94 ModuleResolver resolver = {}, ModuleLimits limits = {},
95 CompilationBudget* absl_nullable budget = nullptr);
96} // namespace a11::flow
97#endif // A11_FLOW_MODULE_H_
One cooperative deadline and work counter for a compilation request.
Definition limits.h:36
Everything the tools know about the world, in one place.
Definition catalogue.h:91
CompilationLimits limits
Definition main.cc:148
CompilationBudget budget
Definition lsp.cc:289
Definition catalogue.cc:29
LinkedModule LinkModules(std::string source, std::string identity, const ModuleSources &sources, ModuleResolver resolver, ModuleLimits limits, CompilationBudget *budget)
Definition module.cc:392
CompilationLimits ModuleLimits
Limits applied before imported source is parsed or linked.
Definition module.h:42
std::function< absl::StatusOr< ModuleSource >(std::string_view reference, std::string_view importer)> ModuleResolver
Definition module.h:39
absl::flat_hash_map< std::string, std::string > ModuleSources
Definition module.h:37
std::uint32_t offset
Definition runtime_streams.cc:36
Host-controlled bounds shared by parsing, linking and semantic analysis.
Definition limits.h:24
Definition module.h:66
size_t end
Definition module.h:68
size_t start
Definition module.h:67
Owning syntax and source snapshot for a linked module graph.
Definition module.h:72
bool SelectingImport(size_t offset) const
Definition module.cc:1190
catalogue::Catalogue CatalogueAt(size_t offset, bool import_selection=true, CompilationLimits limits={}, CompilationBudget *absl_nullable budget=nullptr) const
Public namespace members visible at an offset in the root document.
Definition module.cc:1197
std::vector< ImportSelection > selections
Definition module.h:77
void Locate(std::vector< Diagnostic > &diagnostics) const
Rebase linked diagnostics to their original source documents.
Definition module.cc:1319
std::vector< ModuleMember > members
Definition module.h:76
std::vector< ModuleRange > documents
Definition module.h:75
std::string source
Definition module.h:73
ParseResult parsed
Definition module.h:74
One visible namespace member and its linked identity.
Definition module.h:52
syntax::Location location
Definition module.h:56
bool selection
Definition module.h:61
bool type
Definition module.h:60
size_t scope_start
Definition module.h:57
std::string name
Definition module.h:53
std::string source
Definition module.h:55
std::string intrinsic
Definition module.h:62
bool scoped
Definition module.h:59
std::string target
Definition module.h:54
size_t scope_end
Definition module.h:58
One original document's interval in linked analysis source.
Definition module.h:45
std::string identity
Definition module.h:46
size_t end
Definition module.h:48
size_t start
Definition module.h:47
Source supplied by a host, with its canonical identity.
Definition module.h:32
std::string source
Definition module.h:34
std::string identity
Definition module.h:33
The flows a file declares, and everything wrong with it.
Definition parser.h:34
The start token's byte span, line, and code-point column.
Definition syntax.h:39
const std::string identity
Definition webrtc_wire_stream.cc:107