ID => Symbol

John, you have previously suggested in broad terms that when walking the AST and I ran into symbols that linking to the Symbol would provide useful information.

Is it correct that I should expect a node of type ID to have a valid Symbol. i.e.,
if NodeTypes:getTypeName(mobToken:GetType()) = "ID"
then mobCurrentSymbol = mobToken:getSymbol().

Is it also correct that, having obtained such symbol for a shared variable, for example, that
mobCurrentSymbol:getNumReads()
mobCurrentSymbol:getNumWrites()
would tell me whether that shared variable was assigned from or assigned to in that particular compile unit?
I.e., without having to parse all the assignments and look for the references to the shared variable?

Is there a way to loop through the Symbols without walking the tree of the program? I.e., instead of walking the tree looking for DEFINE statements and then checking to see if they are buffers, could I loop through the Symbols and check for type Buffer or for type Variable and IsImported or IsExported?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tamhas's picture

And, poking around some of

And, poking around some of the old code from OE Hive, I see a construct like:

parseUnit.getRootScope().getAllSymbolsDeep(Frame)

and I see that there are getBufferSet and getVariables methods on SymbolScope as well. Can one of these be used to get all the buffers or shared variables without walking the AST looking for the defines?


john's picture

Yes that's right - lots of

Yes that's right - lots of goodies in TreeParser.SymbolScope. You can get lists of Symbols like Variables or TableBuffers, and examine the properties of each of those.


tamhas's picture

So, those return either a

So, those return either a java.util.ArrayList or java.util.Set or java.util.Collection . What does one define as an OpenEdge datatype to receive this and how does one iterate through it? Being Java types, the .NET docs aren't easy to query on this.


john's picture

I think the ikvm DLL

I think the ikvm DLL provides .Net classes derived from those java classes.


tamhas's picture

Well, yes, it is likely that

Well, yes, it is likely that it does since I can do things like
define variable mobJavaFile as class java.io.File no-undo.
and the java.io.File is clearly not a standard .NET class.

But, so I define a variable as one of those classes and return into it, how does one then walk through the individual entries?


tamhas's picture

OK, I've been doing some

OK, I've been doing some experimenting. It appears that the link between the ID node and the Symbol only happens where it is defined? Not, for example, in an assignment statement where the variable is used.

It also appears that a Symbol doesn't exist for every ID even in a definition, e.g., the name of an index in a temp-table.

It appears that defining a dataset reference to a buffer makes the buffer read once.


john's picture

Try the Field_ref node

Try the Field_ref node


tamhas's picture

OK, try it for what? For

OK, try it for what? For finding out what the ID node in an assignment actually points to? That sounds like what the name might be but that leaves me with two big questions.

1) How does one get from the the node of type ID to the FieldRefNode (don't see any Field_Ref class)? I see no getFieldRef method or the like in JPNode.

2) At the moment, my issue is not trying to parse the actual assignment, but rather to collect a list of buffers and a list of shared variables and other shared objects. For buffers, I would like to know if it is created or deleted (I am currently doing that from the XREF as well as columns and whether they are updated ... may convert that to Proparse later). For shared objects, I want to know if they are on the left or right side of assignments in that particular compile unit (haven't written that yet).