How to determine where class members etc are getting resolved from in AST when using multiple packages? #835
Closed
Practical-UVM-Step-By-Step
started this conversation in
General
Replies: 1 comment 1 reply
-
You can call getParentScope() on any symbol to see where it's declared. If that scope differs from your current scope then you know it's a reference to some other package. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Mike:
I have a question about how to determine cross references in the AST tree. I'm trying to use a new rule in the slang-tidy and have a question.
Here is an example:
package mypackage;
int a; // This will be used in another package
endpackage
package mypackage2;
import mypackage::*;
class myclass_new;
int my_new;
// some variables
function new;
my_new = a; // The 'a' is from the mypackage
endfunction
endclass
endpackage
module top;
import mypackage::;
import mypackage2::;
// class created etc.
endmodule
The generated AST has the physical address of the variable 'a'.
here is an extract for the above one from slang-driver for the relevant portion.
"expr": {
"kind": "Assignment",
"type": "int",
"left": {
"kind": "NamedValue",
"type": "int",
"symbol": "2199025930208 my_new"
},
"right": {
"kind": "NamedValue",
"type": "int",
"symbol": "2199025923840 a"
},
"isNonBlocking": false
...
My question is when traversing through a visitor (like you have in your slang-tidy examples) what should I be looking for in the Symbol to help me figure out that this was a cross reference to another package? the SymbolKind in Symbol.h didnt give me any clues. Should I be looking elsewhere inside the implementation of a check or in the compilation for example?
The application I have is about determining if a package/class/method is pulling in variables/defintions from another package because if you're migrating frm one package to another, it would be good to dump out all the cross-package references or flag them.
Ideas and insights are gratefully appreciated
Thank you
Beta Was this translation helpful? Give feedback.
All reactions