-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to get reflifc::Module from any reflifc object. #27
Comments
If I understand your suggestion correctly, you are talking about method like |
For me, it's to check if the given Declaration is fully visible from ModuleA where I'm generating code for. Lets say there is a function like this: bool is_module_imported_in_module(reflifc::Module to_check, reflifc::Module module_, ifc::Environment& environment, bool use_imported = true)
{
if (to_check == module_) {
return true;
}
if (use_imported) {
for (auto imported_module : module_.imported_modules(environment)) {
if (to_check == imported_module) {
return true;
}
}
}
for (auto exported_module : module_.exported_modules(environment)) {
if (is_module_imported_in_module(to_check, exported_module, environment, false)) {
return true;
}
}
return false;
} With the added API bool is_decl_visible(reflifc::Declaration my_decl, reflifc::Module root_module) {
const bool owning_module_visible = is_module_imported_in_module(my_decl.owning_module(), root_module, g_environment);
const bool decl_self_visible = my_decl.specifiers() & yadayada;
return owning_module_visible && self_visible;
} This is my use case at the moment. |
Firstly, |
Maybe the wording is a bit confusing. But my understanding is that a ifc::File stores the types/decls & everything for 1 .ixx file. The global module fragments are still declared/included in that .ixx file and ends up in the ifc::File. This is what I wanted to expose, which ifc::File the Decl/Type index belongs to. In this sense I was under the impression it made sense to also add Why do you say Types don't make sense to have a owning module? |
Right, but let's consider the following example
The only sort of types for which |
I think you are right on the types point. It only makes sense for Declarations. From all of the related code I've written thus far that's the final thing I need to check for. The Global Module fragment I'm not really worried about. It's still part of the same .ifc file as all the other declarations, they just have the BasicSpecifiers::IsMemberOfGlobalModule flag set. To illustrate, say you have a So my question now would be, would you be okay |
Ok, let's add
|
All reflifc types combine the
ifc::File
and some pointer/index, however the file is never exposed.This might be partly a design decision, but for my current use case I need to check if a certain type/declaration from a certain module (so
ifc::File
, orreflifc::Module
). To determine if a type is visibility or reachable.Do you have any concerns with adding this to the API?
The text was updated successfully, but these errors were encountered: