Skip to content

Format if statements in generated Java files #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
yutaro-sakamoto opened this issue Oct 7, 2024 · 0 comments
Open

Format if statements in generated Java files #496

yutaro-sakamoto opened this issue Oct 7, 2024 · 0 comments

Comments

@yutaro-sakamoto
Copy link
Contributor

EVALUATE COUNTER
   WHEN 1
     DISPLAY "1"
   WHEN 2
     DISPLAY "2"
   WHEN 3
     DISPLAY "3"
   WHEN OTHER
     DISPLAY "OTHER"
END-EVALUATE

The compiler converts the above evaluate statement to the following code

/* prog.cbl:17: EVALUATE */
{
  if (((long)b_COUNTER.cmpNumdisp (2, 1) == 0L))
    {
      /* prog.cbl:19: DISPLAY */
      {
        CobolTerminal.display (0, 1, 1, c_2_1);
      }
    }
  else
    if (((long)b_COUNTER.cmpNumdisp (2, 2) == 0L))
      {
        /* prog.cbl:21: DISPLAY */
        {
          CobolTerminal.display (0, 1, 1, c_3_2);
        }
      }
    else
      if (((long)b_COUNTER.cmpNumdisp (2, 3) == 0L))
        {
          /* prog.cbl:23: DISPLAY */
          {
            CobolTerminal.display (0, 1, 1, c_4_3);
          }
        }
      else
        {
          /* prog.cbl:25: DISPLAY */
          {
            CobolTerminal.display (0, 1, 1, c_5_OTHER);
          }
        }
}

This Java code should be changed to the following code.

/* prog.cbl:17: EVALUATE */
{
  if (((long)b_COUNTER.cmpNumdisp (2, 1) == 0L)) {
    /* prog.cbl:19: DISPLAY */
    {
      CobolTerminal.display (0, 1, 1, c_2_1);
    }
  } else if (((long)b_COUNTER.cmpNumdisp (2, 2) == 0L)) {
    /* prog.cbl:21: DISPLAY */
    {
      CobolTerminal.display (0, 1, 1, c_3_2);
    }
  } else if (((long)b_COUNTER.cmpNumdisp (2, 3) == 0L)) {
    /* prog.cbl:23: DISPLAY */
    {
      CobolTerminal.display (0, 1, 1, c_4_3);
    }
  } else {
    /* prog.cbl:25: DISPLAY */
    {
      CobolTerminal.display (0, 1, 1, c_5_OTHER);
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant