Blocks, Scope, Buffers, Transactions, Variables, Calls

There are two projects in the queue which I have been looking at and I am having some trouble identifying all the right pieces, so I'm wondering if you can provide some hints.

I have an existing function which reads the block summary at the end of COMPILE LISTING to create tables for the blocks in a compile unit, whether there is a transaction scoped to the block, the buffers scoped to the block, and the frames scoped to the block.

Is Block in org.prorefactor.treeparser going to correspond to these same blocks I see in COMPILE LISTING or are there going to be more or fewer for some reason?

I can see the links Block => BufferScope => TableBuffer => Table which I am guessing will tell me about the scoping of buffers to blocks.

Likewise, I can see Block => SymbolScope => Variable and Block => Frame.

I am not seeing where I would identify the transaction scope.

I am seeing Call and RunHandle ... but not where I am going to get a list of Calls.

FWIW, I have sucked Proparse into Enterprise Architect, but one still has to track down the connections.


Comment viewing options

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

Re: Blocks, Scope, Buffers, Transactions, Variables, Calls

I think the blocks you find in Proparse should be pretty close to what you get from a compile-list, but I can't tell you how close.
Proparse does figure out symbol scope (buffers and variables) but it does not attempt to sort out transaction scopes. Nor does it provide a list of calls. SymbolScope provides methods like getChildScopes.


tamhas's picture

OK, but how does one get the

OK, but how does one get the top level? So far, I am not finding a path to get a top level list of scopes or blocks nor am I having any luck walking the parse tree and getting a scope or block for each statement.


tamhas's picture

Mostly, I keep not finding a

Mostly, I keep not finding a way to get from anywhere to somewhere that looks promising. But, I am also getting places where I am not seeing what I expect. E.g.,

mobSymbol = cast( mobIterator:next(), Symbol ).
mchSymbolType = NodeTypes:getTypeName(mobSymbol:getProgressType()).
mchSymbolName = mobSymbol:getName().
mobSymbolScope = mobSymbol:getScope().
minDepth = mobSymbolScope:depth().
mobRootBlock = mobSymbolScope:getRootBlock().
mobBlockDefineNode = mobRootBlock:getNode().
mchBlockTokenType = NodeTypes:getTypeName(mobBlockDefineNode:firstChild():GetType()).
minBlockLine = mobBlockDefineNode:getLine().

Is giving me a bunch of references of token type BLOCKLEVEL at line 0. I presume this means they are scoped to the procedure?

And then I get:

prIP (PROCEDURE) at depth of 0 in a BLOCKLEVEL block at line 0
_Field (BUFFER) at depth of 0 in a BLOCKLEVEL block at line 0
fnFunction (FUNCTION) at depth of 0 in a BLOCKLEVEL block at line 0
ipchInput (VARIABLE) at depth of 1 in a ID block at line 15
opchOutput (VARIABLE) at depth of 1 in a ID block at line 15
iinCount (VARIABLE) at depth of 1 in a ID block at line 15
bf_Field (BUFFER) at depth of 1 in a ID block at line 15

from this code:

procedure prIP:
define input parameter ipchInput as character no-undo.
define output parameter opchOutput as character no-undo.
define variable iinCount as integer no-undo.
define buffer bf_Field for _Field.
opchOutput = ipchInput.
for each bf_Field no-lock:
iinCount = iinCount + 1.
end.
return.
end.

function fnFunction returns character:
return "test".
end.

Does that make sense or am I doing something wrong?


tamhas's picture

Let me restate a couple of

Let me restate a couple of issues and see if that brings forth any hints.

Does org.prorefactor.treeparser.Block correspond to the same blocks listed in COMPILE LIST at the end?

What relation does Block have to Scope?

Is there a way to get the tree of Blocks or Scopes directly in the way that I can get the set of all Symbols so as to navigate from the top down instead of navigating the whole tree looking for scopes?

I see there is TRANSACTION among the keywords, but not a method on anything that tells me whether a transaction is active.

I see LOCKED among the keywords, but not a method on anything that tells me whether there is a lock and what type it is.

Being able to navigate the symbols from the top was a nice discovery. I am hoping I can do the same with blocks, scopes, and calls.


tamhas's picture

Attempting to poke around

Attempting to poke around and see if I can find anything that helps, one specific problem I seem to have is finding way to reference Block or BlockNode based on JPNode. getLink() seems to be the indicated method, but I can find no arguments which it will accept for parameters.