nested perform thru

29 views
Skip to first unread message

johannes...@gmx.net

unread,
Mar 20, 2009, 10:37:03 AM3/20/09
to NACA (automated Cobol to Java transcoding)
hi again,

i have a problem with nested "PERFORM THRU". i found this problem
because i had an infinite loop in an application that has already
worked with our own framework. i did some tests and found out the
following:
* "double nested" PERFORM THRU: runs correct until the end of the
second PERFORM THRU, but then the next paragraph of the first PERFORM
THRU ist not executed, but the program continues after the first
PERFORM THRU statement.
* "triple nested" PERFORM THRU: causes an inifnite loop. this is what
happens with my application. you can find a simple example at the end
of my post.

i think the problem is that "m_currentParagraph" in BaseProgramManager
is a simple variable, but should be a stack.

kind regards,
hannes

---------------------------------------
simple example that causes an infinite loop:

package my;

import nacaLib.batchPrgEnv.BatchProgram;
import nacaLib.program.Paragraph;

public class MY extends BatchProgram {

public void procedureDivision() {
display("BEGIN");
performThrough(aaa, aaa_Exit);
display("END");
stopRun();
}

Paragraph aaa = new Paragraph(this) {
@Override
public void run() {
display("AAA");
performThrough(bbb, bbb_Exit);
}
};

Paragraph aaa_Exit = new Paragraph(this) {
public void run() {
display("AAA-EXIT");
};
};

Paragraph bbb = new Paragraph(this) {
public void run() {
display("BBB");
performThrough(ccc , ccc_Exit);
};
};

Paragraph bbb_Exit = new Paragraph(this) {
public void run() {
display("BBB-EXIT");
}
};

Paragraph ccc = new Paragraph(this) {
public void run() {
display("CCC");
};
};

Paragraph ccc_Exit = new Paragraph(this) {
public void run() {
display("CCC-EXIT");
}
};

}

Pierre-Jean Ditscheid

unread,
Mar 20, 2009, 11:55:19 AM3/20/09
to naca-automated-cobol...@googlegroups.com
Hi Johannes,
 
I will look at your code in the next few days, but you are probably right on your diagnostic.
Of course, I'll let you know my conclusions and the correction.
 
Best regards,
 
Pierre-Jean Ditscheid.

Pierre-Jean Ditscheid

unread,
Apr 2, 2009, 1:39:09 AM4/2/09
to NACA (automated Cobol to Java transcoding)
Hi,

Please find below a correction, submit by *CSM*, an open source user

Just replace the method public void performThrough(Paragraph
paragraphBegin, Paragraph paragraphEnd) of BaseProgramManager.java in
NacaRT with this code:

public void performThrough(Paragraph paragraphBegin, Paragraph
paragraphEnd)
{
// Enum all paragraphs that are between functorBegin and functorEnd,
whatever their sections
CJMapRunnable saveCurrentParagraph = m_currentParagraph;

m_currentParagraph = paragraphBegin; // *CSM* Save a reference to
current paragraph; saved in stack, enabling nested perfomthrough
boolean bDone = false ;
while(m_currentParagraph != null && !bDone)
{
try
{
m_currentParagraph.run();
if (m_currentParagraph == paragraphEnd)
{
bDone = true ;
m_currentParagraph = saveCurrentParagraph; // *CSM* Restore the
current paragraph reference member before return
}
else
{
setNextParagraphCurrent();
}
}
catch (CGotoException e)
{
m_currentParagraph = e.m_Paragraph;
}
}
}

Best regards,

PJD
> }- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

johannes...@gmx.net

unread,
Apr 2, 2009, 2:38:26 AM4/2/09
to NACA (automated Cobol to Java transcoding)
thank you very much :)
kind regards,
hannes
Reply all
Reply to author
Forward
0 new messages