Extracting a heat map.. #581
Replies: 3 comments
-
I'm not entirely sure what you're asking for. If you want to find all referenced class names, you can search through the syntax tree(s) for all ClassDeclarationSyntax nodes and then look through all data declarations and see if they match a class name. If you want something more involved, like walking the AST from the top instances and finding all classes that could ever be instantiated, you can do that too by starting from the Compilation RootSymbol and traversing through all expressions, finding ones that create a new class, and then from each of those classes traversing through their expressions, recursively. GenericClassDef is for tracking generic classes (i.e. classes that are parameterized) as they have extra processing required to implement all language rules. I'm not sure it's useful to you. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. Could you possibly confirm my understanding of what you said:
Then use list to get a list of files. Can you possibly correct my understanding if I got you wrong? Again, Thank you for writing this library in such an Intutive way with variable names that match the intention. |
Beta Was this translation helpful? Give feedback.
-
If you have a compilation then you can traverse the elaborated tree, which is made up of symbols. ClassDeclarationSyntax is a SyntaxNode, which is from the unelaborated syntax tree. You can find all the class declarations that way as well, of course, so either way that part should be no problem. I'm not sure what you mean in the last step though. Can you post an example of input and the output you want to see? Are you looking for classes that inherit from the base class? Are you looking for variables that have a type that is of class type? For the latter, if you visit all of the symbols in the AST (starting from compilation.getRoot()) you can look for VariableSymbols and call getType() and then check isClass() to find all of the variables with class type. |
Beta Was this translation helpful? Give feedback.
-
HI:
I'm needing to extract a report of the files that may be used in an UVM environment for a given test. Usually, when the uvm environment runs, there is a top level class that instantiates the test environment and all the other classes underneath it.
When I look at the driver example, I see the example extracts the top module of the design and prints it out.
The implementation of Compilation class has code in getRoot() which will attempt to identify the top modules in the design.
Could you suggest if there's a way to do the same for the class hierarchy? I see the GenericClassDef symbol in Compilation.h but it isnt an array/or anything of the sort but a pointer.
How is this GenericClassDef envisioned to be used?
Could you what steps do I take with slang as a library to extract this information I'm looking for.
Any suggestions are welcome. My current approach is parsing the compile log files which is probably not as robust.
Beta Was this translation helpful? Give feedback.
All reactions