/*
 * $Id$
 *
 * JSDAI(TM), a way to implement STEP, ISO 10303
 * Copyright (C) 1997-2008, LKSoftWare GmbH, Germany
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License
 * version 3 as published by the Free Software Foundation (AGPL v3).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * JSDAI is a registered trademark of LKSoftWare GmbH, Germany
 * This software is also available under commercial licenses.
 * See also http://www.jsdai.net/
 */

// %modified: 1016210366380 %

/* Generated By:JJTree: Do not edit this line. X_CaseAction.java */
package jsdai.expressCompiler;

import java.util.*;


public class X_CaseAction
  extends StatementNode { // is it correct?

  // public class X_CaseAction extends SimpleNode {
  Vector labels;
  String statement = "unset";
  int number_of_labels; // may need to know in advance when constructing a compound if in action node.

  public X_CaseAction(int id) {
    super(id);
  }

  public X_CaseAction(Compiler2 p, int id) {
    super(p, id);
  }

  /** Accept the visitor. **/
  public Object jjtAccept(Compiler2Visitor visitor, Object data)
                   throws jsdai.lang.SdaiException {
    return visitor.visit(this, data);
  }

  public Object childrenAccept(Compiler2Visitor visitor, Object data)
                        throws jsdai.lang.SdaiException {
    JavaClass jc = ( JavaClass )data;
    boolean first_time_if = true;
    boolean first_time_else = true;
    number_of_labels = 0;

    if (children != null) {

      // jc.java_str4 = "";
      statement = "";
      labels = new Vector();

      for (int i = 0; i < children.length; ++i) {
        children[i].jjtAccept(visitor, data);

        if (jc != null) {
          if (jc.active) {

            //      System.out.println("<><> if count: " + if_count + ", else count: " + else_count);
            if (children[i] instanceof X_CaseLabel) {

              //                     labels.addElement(jc.print_string);
              labels.addElement(jc.generated_java);
              jc.generated_java = "";

              // jc.print_string = "";
              number_of_labels++;
            } else {

              // must be action statement
              // seems that according to the grammar - only one statement.
              // probably need to make a compound statement BEGIN-END if more than one needed.
              // maybe worth counting to catch an error
//              statement = jc.print_string;
              statement = ((SimpleNode)children[i]).forwarded_java;
              statement += ((SimpleNode)children[i]).generated_java;
							printDDebug("OOXXOO 1: " + ((SimpleNode)children[i]).generated_java, jc);
							printDDebug("OOXXOO 2: " + jc.print_string, jc);
							printDDebug("OOXXOO 2: " + jc.generated_java, jc);
							((SimpleNode)children[i]).forwarded_java = "";
							((SimpleNode)children[i]).generated_java = "";
              jc.print_string = "";
            }
          }
        }
      }
    }

    return data;
  }
}
