Skip to content
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

Question: What is the best way to recursively explore record definitions? #969

Closed
dmt117 opened this issue Nov 8, 2024 · 3 comments
Closed

Comments

@dmt117
Copy link

dmt117 commented Nov 8, 2024

I'm trying to follow embedded record definitions, i.e. a record within a record definition, etc. I want to get all the way to the basic types embedded in the records. There doesn't seem to be a straightforward way to do this in libadlang. There is a component list for a record definition, but if one of those components is itself a record type, I'm not discovering how to reach the record definition for that type. Is there an easy way to do this?

@Roldak
Copy link
Contributor

Roldak commented Nov 12, 2024

Hello!

You're right that this functionality is not built-in, so you'll have to roll your own recursive implementation.

The key of this algorithm would be that once you've managed to retrieve the TypeExpr node of a record component (which IIUC you have), you can find its corresponding type declaration using the P_Designated_Type_Decl property (corresponding documentation).

If this type declares a record as well, you can then recurse on its components, and so on.

I hope this helps!

@dmt117
Copy link
Author

dmt117 commented Nov 12, 2024

thanks!

@Roldak
Copy link
Contributor

Roldak commented Nov 12, 2024

No problem !

@Roldak Roldak closed this as completed Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants