comp.lang.ada
 help / color / mirror / Atom feed
From: "Peter C. Chapin" <pchapin@sover.net>
Subject: ASIS question: How to detect branches of if statments?
Date: Wed, 06 Apr 2005 02:05:42 GMT
Date: 2005-04-06T02:05:42+00:00	[thread overview]
Message-ID: <Xns962FE0C3FAFF9pchapinsovernet@207.106.93.237> (raw)


Hi! I'm attempting to build an ASIS application. In my application I 
need to construct a control flow graph (CFG) of, for example, a 
particular procedure. For now I'm restricting myself to procedures with 
if/else statements and simple loops without internal exit statements. 
This is a class project so complete coverage of Ada is definitely not 
necessary.

I see how to create the CFG for the loops. I provide pre and post 
traversal procedures. For ordinary statements I attach a new node to a 
"working point" in my graph. When I encounter a while loop (say), I 
create a node for the predicate and push the node on a stack. When I 
come to the end of the loop (in my post traversal procedure), I pop the 
stack and connect the last node of the loop body to the header node, 
etc.

I can do something similar to handle an if statement with a single 
clause. But I'm stuck on how to handle if/else statements:

    	if X = Y then
    	  -- Stuff.
    	else
    	  -- Other stuff.
    	end if;

I can see the beginning of the if statement and I can see the end of it 
("end if") but the traversal returns "stuff" and "other stuff" in one 
continuous stream without any obvious indication where the else fits 
into things. Clearly I'm missing something, but I'm not sure what. I saw 
some things about "Statement Paths" in the Asis.Statements package spec, 
but there isn't a lot of explanation about what they are. Is that 
something I should be playing with?

I've looked at a couple of ASIS tutorials and they were helpful in 
getting me started, but it seems like I'm going to need some more 
detailed information now. Does anyone have any suggestions for a good 
tutorial that might fit where I'm at?

Thanks!

Peter



             reply	other threads:[~2005-04-06  2:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-06  2:05 Peter C. Chapin [this message]
2005-04-13  0:56 ` ASIS question: How to detect branches of if statments? Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox