Java Code Examples for com.sun.tools.corba.se.idl.UnionEntry#defaultBranch()

The following examples show how to use com.sun.tools.corba.se.idl.UnionEntry#defaultBranch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnionGen.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 2
Source File: UnionGen.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 3
Source File: UnionGen.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 4
Source File: UnionGen.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 5
Source File: UnionGen.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 6
Source File: UnionGen.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 7
Source File: UnionGen.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 8
Source File: UnionGen.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private int writeNonBoolean (String disName, int index, String indent, String name, UnionEntry u, PrintWriter stream)
{
  SymtabEntry utype = Util.typeOf (u.type ());
  if (utype instanceof EnumEntry)
    stream.println (indent + "switch (" + name + ".discriminator ().value ())");
  else
    stream.println (indent + "switch (" + name + ".discriminator ())");
  stream.println (indent + "{");
  String typePackage = Util.javaQualifiedName (utype) + '.';
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)e.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression label = (Expression)labels.nextElement ();
      if (utype instanceof EnumEntry)
      {
        String key = Util.parseExpression (label);
        stream.println (indent + "  case " + typePackage + '_' + key + ":");
      }
      else
        stream.println (indent + "  case " + cast (label, utype) + ':');
    }
    if (!branch.typedef.equals (u.defaultBranch ()))
    {
      index = writeBranch (index, indent + "    ", name, branch.typedef, stream);
      stream.println (indent + "    break;");
    }
  }
  if (u.defaultBranch () != null) {
    stream.println (indent + "  default:");
    index = writeBranch (index, indent + "    ", name, u.defaultBranch (), stream);
    stream.println (indent + "    break;");
  }
  stream.println (indent + "}");
  return index;
}
 
Example 9
Source File: UnionGen.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}
 
Example 10
Source File: UnionGen.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}
 
Example 11
Source File: UnionGen.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}
 
Example 12
Source File: UnionGen.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}
 
Example 13
Source File: UnionGen.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}
 
Example 14
Source File: UnionGen.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}
 
Example 15
Source File: UnionGen.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}
 
Example 16
Source File: UnionGen.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private int readNonBoolean (String disName, int index, String indent,
    String name, UnionEntry u, PrintWriter stream)
{
    SymtabEntry utype = Util.typeOf (u.type ());

    if (utype instanceof EnumEntry)
        stream.println (indent + "switch (" + disName + ".value ())");
    else
        stream.println (indent + "switch (" + disName + ')');

    stream.println (indent + '{');
    String typePackage = Util.javaQualifiedName (utype) + '.';

    Enumeration e = u.branches ().elements ();
    while (e.hasMoreElements ()) {
        UnionBranch branch = (UnionBranch)e.nextElement ();
        Enumeration labels = branch.labels.elements ();

        while (labels.hasMoreElements ()) {
            Expression label = (Expression)labels.nextElement ();

            if (utype instanceof EnumEntry) {
                String key = Util.parseExpression (label);
                stream.println (indent + "  case " + typePackage + '_' + key + ':');
            } else
                stream.println (indent + "  case " + cast (label, utype) + ':');
        }

        if (!branch.typedef.equals (u.defaultBranch ())) {
            index = readBranch (index, indent + "    ", branch.typedef.name (),
                branch.labels.size() > 1 ? disName : "" ,
                branch.typedef, stream);
            stream.println (indent + "    break;");
        }
    }

    // We need a default branch unless all of the case of the discriminator type
    // are listed in the case branches.
    if (!coversAll(u)) {
        stream.println( indent + "  default:") ;

        if (u.defaultBranch () == null) {
            // If the union does not have a default branch, we still need to initialize
            // the discriminator.
            stream.println( indent + "    value._default( " + disName + " ) ;" ) ;
        } else {
            index = readBranch (index, indent + "    ", u.defaultBranch ().name (), disName,
                u.defaultBranch (), stream);
        }

        stream.println (indent + "    break;");
    }

    stream.println (indent + '}');

    return index;
}