com.sun.tools.corba.se.idl.UnionBranch Java Examples

The following examples show how to use com.sun.tools.corba.se.idl.UnionBranch. 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 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #2
Source File: UnionGen.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #3
Source File: UnionGen.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #4
Source File: UnionGen.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #5
Source File: UnionGen.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #6
Source File: UnionGen.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #7
Source File: UnionGen.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #8
Source File: UnionGen.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 **/

// Computes the total number of labels in the union, which is the sum
// of the number of labels in each branch of the union.  Note that the
// label for the default branch has size 0, but still counts in the total
// size.
private int unionLabelSize( UnionEntry un )
{
  int size = 0 ;
  Vector branches = un.branches() ;
  for (int i = 0; i < branches.size (); ++i) {
      UnionBranch branch = (UnionBranch)(branches.get(i)) ;
      int branchSize = branch.labels.size() ;
      size += ((branchSize == 0) ? 1 : branchSize) ;
  }
  return size ;
}
 
Example #9
Source File: UnionGen.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}
 
Example #10
Source File: UnionGen.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private String safeName (UnionEntry u, String name)
{
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
    if (((UnionBranch)e.nextElement ()).typedef.name ().equals (name))
    {
      name = '_' + name;
      break;
    }
  return name;
}
 
Example #11
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 #12
Source File: UnionGen.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}
 
Example #13
Source File: UnionGen.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private String safeName (UnionEntry u, String name)
{
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
    if (((UnionBranch)e.nextElement ()).typedef.name ().equals (name))
    {
      name = '_' + name;
      break;
    }
  return name;
}
 
Example #14
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 #15
Source File: UnionGen.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}
 
Example #16
Source File: UnionGen.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private String safeName (UnionEntry u, String name)
{
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
    if (((UnionBranch)e.nextElement ()).typedef.name ().equals (name))
    {
      name = '_' + name;
      break;
    }
  return name;
}
 
Example #17
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 #18
Source File: UnionGen.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}
 
Example #19
Source File: UnionGen.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private String safeName (UnionEntry u, String name)
{
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
    if (((UnionBranch)e.nextElement ()).typedef.name ().equals (name))
    {
      name = '_' + name;
      break;
    }
  return name;
}
 
Example #20
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 #21
Source File: UnionGen.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}
 
Example #22
Source File: UnionGen.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private String safeName (UnionEntry u, String name)
{
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
    if (((UnionBranch)e.nextElement ()).typedef.name ().equals (name))
    {
      name = '_' + name;
      break;
    }
  return name;
}
 
Example #23
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 #24
Source File: UnionGen.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}
 
Example #25
Source File: UnionGen.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private String safeName (UnionEntry u, String name)
{
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
    if (((UnionBranch)e.nextElement ()).typedef.name ().equals (name))
    {
      name = '_' + name;
      break;
    }
  return name;
}
 
Example #26
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 #27
Source File: UnionGen.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}
 
Example #28
Source File: UnionGen.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private String safeName (UnionEntry u, String name)
{
  Enumeration e = u.branches ().elements ();
  while (e.hasMoreElements ())
    if (((UnionBranch)e.nextElement ()).typedef.name ().equals (name))
    {
      name = '_' + name;
      break;
    }
  return name;
}
 
Example #29
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 #30
Source File: UnionGen.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *
 **/
private Vector vectorizeLabels (Vector branchVector, boolean useIntsForEnums )
{
  Vector mergedLabels = new Vector ();
  Enumeration branches = branchVector.elements ();
  while (branches.hasMoreElements ())
  {
    UnionBranch branch = (UnionBranch)branches.nextElement ();
    Enumeration labels = branch.labels.elements ();
    while (labels.hasMoreElements ())
    {
      Expression expr = (Expression)labels.nextElement ();
      String str ;

      if (unionIsEnum)
        if (useIntsForEnums)
          str = typePackage + "_" + Util.parseExpression( expr ) ;
        else
          str = typePackage + Util.parseExpression( expr ) ;
      else
        str = Util.parseExpression( expr ) ;

      mergedLabels.addElement (str);
    }
  }
  return mergedLabels;
}