corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/Util.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
/*
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
 * COMPONENT_NAME: idl.toJava
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
 * ORIGINS: 27
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
 * Licensed Materials - Property of IBM
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
 * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
 * RMI-IIOP v1.0
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
package com.sun.tools.corba.se.idl.toJavaPortable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
// Notes:
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
// -F46838.4<klr> Ported -td option from toJava.
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
// -10/17/98  KLR Ported fix for d48911 from toJava
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
// -10/18/98  KLR Ported fix from toJava for "unsigned long" constants
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
// -F46082.51<daz> Removed code to collect makefile list generation inforamtion
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
//  from getStream(); see f46830.
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
// -F46082.51<daz> Removed -stateful feature: methods javaStatefulName(String)
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
//  and javaStatefulName(SymtabEntry) are obsolete, supplanted by javaName().
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
// -D54640<daz> Represent unsigned long long expressions with their computed
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
//  value rather than their actual representation (see notes in method
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
//  parseTerminal(), parseBinary(), and parseUnary().)
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
// -D58319<daz> Add getVersion() method.
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
// -D48034<daz> Import Helper classes for typedef struct members when generating
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
//  helper.  See method addImportLines().
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
// -D59851<daz> Modify to enable QuickTest build. (pending)
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
// -D42256<daz> Determine import lines for template types, which may specify any
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
//  positive int., constant expression for a boundary. Such expression containing
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
//  non-literal contansts previously caused problems when appearing in constructs
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
//  structs, unions, exceptions, typedefs, operation types and parameters,
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
//  attributes; and of course, sequences, strings.
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
// -D59063<daz> Add helper for global exception to stub import list.
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
// -D58951<daz> Publicise members for QuickTest.
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
// -D59421<klr> Change ValueBaseHolder to SerializableHolder
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
// -D59596<klr> Prevent accesses to elements of empty Vectors.
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
// -D59771<daz> Add import stmt for Helper of global type in stubs.
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
// -D59355<daz> Remove target dir. from filename when writing to prolog.
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
// -D59437<daz> Fill typename information for value boxes.
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
// -D62023<klr> Don't import ValueBase*
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
// -D62023<klr> Add corbaLevel
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
import java.io.File;
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
import java.io.PrintWriter;
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
import java.math.BigInteger;
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
import java.text.DateFormat;
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
import java.util.Date;
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
import java.util.Enumeration;
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
import java.util.Hashtable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
import java.util.Locale;
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
import java.util.Vector;
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
import com.sun.tools.corba.se.idl.ConstEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
import com.sun.tools.corba.se.idl.EnumEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
import com.sun.tools.corba.se.idl.ExceptionEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
import com.sun.tools.corba.se.idl.GenFileStream;
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
import com.sun.tools.corba.se.idl.InterfaceEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
import com.sun.tools.corba.se.idl.MethodEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
import com.sun.tools.corba.se.idl.NativeEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
import com.sun.tools.corba.se.idl.ParameterEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
import com.sun.tools.corba.se.idl.PrimitiveEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
import com.sun.tools.corba.se.idl.SequenceEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
import com.sun.tools.corba.se.idl.StringEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
import com.sun.tools.corba.se.idl.StructEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
import com.sun.tools.corba.se.idl.SymtabEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
import com.sun.tools.corba.se.idl.TypedefEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
import com.sun.tools.corba.se.idl.UnionBranch;
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
import com.sun.tools.corba.se.idl.UnionEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
import com.sun.tools.corba.se.idl.ValueEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
import com.sun.tools.corba.se.idl.ValueBoxEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
import com.sun.tools.corba.se.idl.InterfaceState;
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
import com.sun.tools.corba.se.idl.constExpr.*;
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
 * Class Util is a repository of static members available for general
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
 * use by the IDL parser framework and any generator extensions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
 **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
public class Util extends com.sun.tools.corba.se.idl.Util
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
{
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
  // <d58319>
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
   * Fetch the version number of this build of the IDL-to-Java (portable)
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
   * compiler from the appropriate properties file.
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
   * @return the version number of this compiler build.
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
  public static String getVersion ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
    return com.sun.tools.corba.se.idl.Util.getVersion ("com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable.prp");
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
  } // getVersion
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
   * This method is called by Setup.preEmit, so
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
   * symbolTable is available for all Util methods.
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
  static void setSymbolTable (Hashtable symtab)
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
    symbolTable = symtab;
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
  } // setSymbolTable
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
  public static void setPackageTranslation( Hashtable pkgtrans )
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
    packageTranslation = pkgtrans ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
  public static boolean isInterface (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
    return isInterface (name, symbolTable);
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
  } // isInterface
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
  static String arrayInfo (Vector arrayInfo)
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
    int         arrays = arrayInfo.size ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
    String      info   = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
    Enumeration e      = arrayInfo.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
    while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
      info = info + '[' + parseExpression ((Expression)e.nextElement ()) + ']';
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
    return info;
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
  } // arrayInfo
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
  // <d58951> static String sansArrayInfo (Vector arrayInfo)
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
  public static String sansArrayInfo (Vector arrayInfo)
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
    int    arrays   = arrayInfo.size ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
    String brackets = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
    for (int i = 0; i < arrays; ++i)
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
      brackets = brackets + "[]";
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
    return brackets;
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
  } // sansArrayInfo
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
  // <d58951> static String sansArrayInfo (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
  static public String sansArrayInfo (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
    int index = name.indexOf ('[');
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
    if (index >= 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
      String array = name.substring (index);
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
      name = name.substring (0, index);
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
      while (!array.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
        name = name + "[]";
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
        array = array.substring (array.indexOf (']') + 1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
    return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
  } // sansArrayInfo
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
   * Given a symbol table entry, return the name of
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
   * the file which should be created.
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
  public static String fileName (SymtabEntry entry, String extension )
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
    NameModifier nm = new NameModifierImpl() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
    return fileName( entry, nm, extension ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
  } // fileName
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
  public static String fileName (SymtabEntry entry, NameModifier modifier, String extension )
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
    // This may not be the most appropriate place for
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
    // the mkdir calls, but it's common to everything:
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
    String pkg = containerFullName (entry.container ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
    if (pkg != null && !pkg.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
      mkdir (pkg);
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
    String name = entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
    name = modifier.makeName( name ) + extension ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
    if (pkg != null && !pkg.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
      name = pkg + '/' + name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
    return name.replace ('/', File.separatorChar);
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
  } // fileName
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
  public static GenFileStream stream (SymtabEntry entry, String extension)
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
    NameModifier nm = new NameModifierImpl() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
    return stream(entry, nm, extension);
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
  } // stream
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
  public static GenFileStream stream (SymtabEntry entry, NameModifier modifier, String extension )
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
    return getStream ( fileName (entry,modifier,extension), entry ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
  public static GenFileStream getStream (String name, SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
    // <f46838.4>
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
    String absPathName = ((Arguments)Compile.compiler.arguments).targetDir + name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
    if (Compile.compiler.arguments.keepOldFiles && new File (absPathName).exists ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
      return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
      // Write the data to the file stream
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
      return new GenFileStream (absPathName);
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
  } // getStream
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
  public static String containerFullName( SymtabEntry container)
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
      String name = doContainerFullName( container ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
      if (packageTranslation.size() > 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
          name = translate( name ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
      return name ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
  public static String translate( String name )
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
      String head = name ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
      String tail = "" ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
      int index ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
      String trname ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
      // Check for package name translations, starting with the
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
      // most specific match.
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
      do {
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
          trname = (String)(packageTranslation.get( head )) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
          if (trname != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
              return trname + tail ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
          index = head.lastIndexOf( '/' ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
          if (index >= 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
              tail = head.substring( index ) + tail ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
              head = head.substring( 0, index ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
      } while (index >= 0) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
      return name ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
  private static String doContainerFullName (SymtabEntry container)
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
    String name = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
    if (container == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
      name = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
      if (container instanceof InterfaceEntry ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
          container instanceof StructEntry ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
          container instanceof UnionEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
        name = container.name () + "Package";
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
        name = container.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
      if (container.container () != null &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
        !container.container ().name ().equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
        name = doContainerFullName (container.container ()) + '/' + name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
    return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
  } // doContainerFullName
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
   * Given a SymtabEntry, return the string which should be used
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
   * for this entry. Enums are converted to ints, typedefs and
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
   * sequences are converted to their info types. javaQualifiedName
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
   * does not do any of these conversions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
  public static String javaName (SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
    // First get the real name of this type
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
    String name = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
    if (entry instanceof TypedefEntry || entry instanceof SequenceEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
      try
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
        name = sansArrayInfo ((String)entry.dynamicVariable (Compile.typedefInfo));
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
      catch (NoSuchFieldException e)
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
        name = entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
    else if (entry instanceof PrimitiveEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
      name = javaPrimName (entry.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
    else if (entry instanceof StringEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
      name = "String";
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
    else if (entry instanceof NativeEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
      name = javaNativeName (entry.name());
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
    else if (entry instanceof ValueEntry && entry.name ().equals ("ValueBase"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
        name = "java.io.Serializable";
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
    else if (entry instanceof ValueBoxEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
      ValueBoxEntry v = (ValueBoxEntry) entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
      TypedefEntry member = ((InterfaceState) v.state ().elementAt (0)).entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
      SymtabEntry mType = member.type ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
      if (mType instanceof PrimitiveEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
         name = containerFullName (entry.container ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
         if (!name.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
           name = name + '.';
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
         name = name + entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
         name = javaName (mType);
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
      name = containerFullName (entry.container ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
      if (name.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
        name = entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
        name = name + '.' + entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
    // Make it a fully package-qualified name
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
    return name.replace ('/', '.');
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
  } // javaName
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
  public static String javaPrimName (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
    if (name.equals ("long") || name.equals ("unsigned long"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
      name = "int";
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
    else if (name.equals ("octet"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
      name = "byte";
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
    // "unisigned long long" exceeds Java long.
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
    else if (name.equals ("long long") || name.equals ("unsigned long long"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
      name = "long";
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
    else if (name.equals ("wchar"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
      name = "char";
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
    else if (name.equals ("unsigned short"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
      name = "short";
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
    else if (name.equals ("any"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
      name = "org.omg.CORBA.Any";
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
    else if (name.equals ("TypeCode"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
      name = "org.omg.CORBA.TypeCode";
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
    else if (name.equals ("Principal")) // <d61961>
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
      name = "org.omg.CORBA.Principal";
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
    return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
  } // javaPrimName
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
  public static String javaNativeName (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   355
02bb8761fcce Initial load
duke
parents:
diff changeset
   356
    // translations for Native declarations according to CORBA 2.3 spec
02bb8761fcce Initial load
duke
parents:
diff changeset
   357
02bb8761fcce Initial load
duke
parents:
diff changeset
   358
    if (name.equals ("AbstractBase") || name.equals ("Cookie"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   359
      name = "java.lang.Object";
02bb8761fcce Initial load
duke
parents:
diff changeset
   360
    else if (name.equals ("Servant"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   361
      name = "org.omg.PortableServer.Servant";
02bb8761fcce Initial load
duke
parents:
diff changeset
   362
    else if (name.equals ("ValueFactory"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   363
      name = "org.omg.CORBA.portable.ValueFactory";
02bb8761fcce Initial load
duke
parents:
diff changeset
   364
    return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   365
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   366
02bb8761fcce Initial load
duke
parents:
diff changeset
   367
02bb8761fcce Initial load
duke
parents:
diff changeset
   368
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   369
   * Given a symtabEntry, return the name of this entry. This
02bb8761fcce Initial load
duke
parents:
diff changeset
   370
   * method does not do any conversions like javaName does.
02bb8761fcce Initial load
duke
parents:
diff changeset
   371
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   372
  public static String javaQualifiedName (SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   373
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   374
    String name = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   375
    if (entry instanceof PrimitiveEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   376
      name = javaPrimName (entry.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   377
    else if (entry instanceof StringEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   378
      name = "String";
02bb8761fcce Initial load
duke
parents:
diff changeset
   379
    else if (entry instanceof ValueEntry && entry.name ().equals ("ValueBase"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   380
      name = "java.io.Serializable";
02bb8761fcce Initial load
duke
parents:
diff changeset
   381
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   382
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   383
      SymtabEntry container = entry.container ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   384
      if (container != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   385
        name = container.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   386
      if (name.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   387
        name = entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   388
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   389
        name = containerFullName (entry.container ()) + '.' + entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   390
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   391
    return name.replace ('/', '.');
02bb8761fcce Initial load
duke
parents:
diff changeset
   392
  } // javaQualifiedName
02bb8761fcce Initial load
duke
parents:
diff changeset
   393
02bb8761fcce Initial load
duke
parents:
diff changeset
   394
  // <f46082.03> Publicize for extensions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   395
  //static String collapseName (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   396
02bb8761fcce Initial load
duke
parents:
diff changeset
   397
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   398
   * Collapse primitive type names.
02bb8761fcce Initial load
duke
parents:
diff changeset
   399
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   400
  public static String collapseName (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   401
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   402
    if (name.equals ("unsigned short"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   403
      name = "ushort";
02bb8761fcce Initial load
duke
parents:
diff changeset
   404
    else if (name.equals ("unsigned long"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   405
      name = "ulong";
02bb8761fcce Initial load
duke
parents:
diff changeset
   406
    else if (name.equals ("unsigned long long"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   407
      name = "ulonglong";
02bb8761fcce Initial load
duke
parents:
diff changeset
   408
    else if (name.equals ("long long"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   409
      name = "longlong";
02bb8761fcce Initial load
duke
parents:
diff changeset
   410
    return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   411
  } // collapseName
02bb8761fcce Initial load
duke
parents:
diff changeset
   412
02bb8761fcce Initial load
duke
parents:
diff changeset
   413
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   414
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   415
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   416
  public static SymtabEntry typeOf (SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   417
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   418
    while (entry instanceof TypedefEntry && ((TypedefEntry)entry).arrayInfo ().isEmpty () && !(entry.type () instanceof SequenceEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   419
      entry = entry.type ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   420
    return entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   421
  } // typeOf
02bb8761fcce Initial load
duke
parents:
diff changeset
   422
02bb8761fcce Initial load
duke
parents:
diff changeset
   423
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   424
   * Fill the info field with the full name (with array info) of the type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   425
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   426
  static void fillInfo (SymtabEntry infoEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   427
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   428
    String      arrayInfo   = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   429
    SymtabEntry entry       = infoEntry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   430
    boolean     alreadyHave = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   431
02bb8761fcce Initial load
duke
parents:
diff changeset
   432
    do
02bb8761fcce Initial load
duke
parents:
diff changeset
   433
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   434
      try
02bb8761fcce Initial load
duke
parents:
diff changeset
   435
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   436
        alreadyHave = entry.dynamicVariable (Compile.typedefInfo) != null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   437
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   438
      catch (NoSuchFieldException e)
02bb8761fcce Initial load
duke
parents:
diff changeset
   439
      {}
02bb8761fcce Initial load
duke
parents:
diff changeset
   440
      // If this entry's info has already been processed
02bb8761fcce Initial load
duke
parents:
diff changeset
   441
      // don't bother processing it again, just take it.
02bb8761fcce Initial load
duke
parents:
diff changeset
   442
      if (!alreadyHave)
02bb8761fcce Initial load
duke
parents:
diff changeset
   443
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   444
        if (entry instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   445
          arrayInfo = arrayInfo + arrayInfo (((TypedefEntry)entry).arrayInfo ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   446
        else if (entry instanceof SequenceEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   447
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   448
          Expression maxSize = ((SequenceEntry)entry).maxSize ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   449
          if (maxSize == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   450
            arrayInfo = arrayInfo + "[]";
02bb8761fcce Initial load
duke
parents:
diff changeset
   451
          else
02bb8761fcce Initial load
duke
parents:
diff changeset
   452
            arrayInfo = arrayInfo + '[' + parseExpression (maxSize) + ']';
02bb8761fcce Initial load
duke
parents:
diff changeset
   453
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   454
        if (entry.type () == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   455
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   456
          // <d59437> Suppress this message.  It tells the developer nothing, and
02bb8761fcce Initial load
duke
parents:
diff changeset
   457
          // this path does not cause the algorithm to fail.  Value boxes may
02bb8761fcce Initial load
duke
parents:
diff changeset
   458
          // contain anonymous types, like a struct or enum.
02bb8761fcce Initial load
duke
parents:
diff changeset
   459
          //System.err.println (getMessage ("PreEmit.indeterminateTypeInfo", entry.typeName ()));
02bb8761fcce Initial load
duke
parents:
diff changeset
   460
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   461
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   462
          entry = entry.type ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   463
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   464
    } while (!alreadyHave && entry != null &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   465
        (entry instanceof TypedefEntry || entry instanceof SequenceEntry));
02bb8761fcce Initial load
duke
parents:
diff changeset
   466
    // <d59437> Value boxes may contain types lacking typename info., which
02bb8761fcce Initial load
duke
parents:
diff changeset
   467
    // causes the 2nd case, below, to fail with exception when retrieving the
02bb8761fcce Initial load
duke
parents:
diff changeset
   468
    // javaName().
02bb8761fcce Initial load
duke
parents:
diff changeset
   469
    if (entry instanceof ValueBoxEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   470
      fillValueBoxInfo ((ValueBoxEntry)entry);
02bb8761fcce Initial load
duke
parents:
diff changeset
   471
    try
02bb8761fcce Initial load
duke
parents:
diff changeset
   472
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   473
      if (alreadyHave)
02bb8761fcce Initial load
duke
parents:
diff changeset
   474
        infoEntry.dynamicVariable (Compile.typedefInfo, (String)entry.dynamicVariable (Compile.typedefInfo) + arrayInfo);
02bb8761fcce Initial load
duke
parents:
diff changeset
   475
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   476
        infoEntry.dynamicVariable (Compile.typedefInfo, javaName (entry) + arrayInfo);
02bb8761fcce Initial load
duke
parents:
diff changeset
   477
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   478
    catch (NoSuchFieldException e)
02bb8761fcce Initial load
duke
parents:
diff changeset
   479
    {}
02bb8761fcce Initial load
duke
parents:
diff changeset
   480
  } // fillInfo
02bb8761fcce Initial load
duke
parents:
diff changeset
   481
02bb8761fcce Initial load
duke
parents:
diff changeset
   482
  // <d59437>
02bb8761fcce Initial load
duke
parents:
diff changeset
   483
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   484
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   485
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   486
  static void fillValueBoxInfo (ValueBoxEntry vb)
02bb8761fcce Initial load
duke
parents:
diff changeset
   487
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   488
    SymtabEntry stateMember = (((InterfaceState) vb.state ().elementAt (0)).entry);
02bb8761fcce Initial load
duke
parents:
diff changeset
   489
    if (stateMember.type() != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   490
      Util.fillInfo (stateMember.type ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   491
    Util.fillInfo (stateMember);
02bb8761fcce Initial load
duke
parents:
diff changeset
   492
  } // fillValueBoxInfo
02bb8761fcce Initial load
duke
parents:
diff changeset
   493
02bb8761fcce Initial load
duke
parents:
diff changeset
   494
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   495
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   496
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   497
  public static String holderName (SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   498
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   499
    String name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   500
    if (entry instanceof PrimitiveEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   501
      if (entry.name ().equals ("any"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   502
        name = "org.omg.CORBA.AnyHolder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   503
      else if (entry.name ().equals ("TypeCode"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   504
        name = "org.omg.CORBA.TypeCodeHolder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   505
      else if (entry.name ().equals ("Principal")) // <d61961>
02bb8761fcce Initial load
duke
parents:
diff changeset
   506
        name = "org.omg.CORBA.PrincipalHolder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   507
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   508
        name = "org.omg.CORBA." + capitalize (javaQualifiedName (entry)) + "Holder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   509
    else if (entry instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   510
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   511
      TypedefEntry td = (TypedefEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   512
      if (!td.arrayInfo ().isEmpty () || td.type () instanceof SequenceEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   513
        name = javaQualifiedName (entry) + "Holder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   514
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   515
        name = holderName (entry.type ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   516
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   517
    else if (entry instanceof StringEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   518
      name = "org.omg.CORBA.StringHolder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   519
    else if (entry instanceof ValueEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   520
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   521
      if (entry.name ().equals ("ValueBase"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   522
          name = "org.omg.CORBA.ValueBaseHolder"; // <d59421>, <d60929>
02bb8761fcce Initial load
duke
parents:
diff changeset
   523
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
   524
          name = javaName (entry) + "Holder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   525
    } else if (entry instanceof NativeEntry) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   526
      // do not attach holder to the translation for Native Entries, e.g.
02bb8761fcce Initial load
duke
parents:
diff changeset
   527
      // for Cookie it should be CookieHolder instead of java.lang.ObjectHolder
02bb8761fcce Initial load
duke
parents:
diff changeset
   528
      // returns the complete name for the package, etc.
02bb8761fcce Initial load
duke
parents:
diff changeset
   529
      name = javaQualifiedName(entry) + "Holder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   530
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   531
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   532
      name = javaName (entry) + "Holder";
02bb8761fcce Initial load
duke
parents:
diff changeset
   533
    return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   534
  } // holderName
02bb8761fcce Initial load
duke
parents:
diff changeset
   535
02bb8761fcce Initial load
duke
parents:
diff changeset
   536
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   537
   * <d61056>
02bb8761fcce Initial load
duke
parents:
diff changeset
   538
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   539
  public static String helperName (SymtabEntry entry, boolean qualifiedName)
02bb8761fcce Initial load
duke
parents:
diff changeset
   540
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   541
    if (entry instanceof ValueEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   542
      if (entry.name ().equals ("ValueBase"))
02bb8761fcce Initial load
duke
parents:
diff changeset
   543
          return "org.omg.CORBA.ValueBaseHelper";
02bb8761fcce Initial load
duke
parents:
diff changeset
   544
02bb8761fcce Initial load
duke
parents:
diff changeset
   545
    if (qualifiedName)
02bb8761fcce Initial load
duke
parents:
diff changeset
   546
      return javaQualifiedName (entry) + "Helper";
02bb8761fcce Initial load
duke
parents:
diff changeset
   547
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   548
      return javaName (entry) + "Helper";
02bb8761fcce Initial load
duke
parents:
diff changeset
   549
  } // helperName
02bb8761fcce Initial load
duke
parents:
diff changeset
   550
02bb8761fcce Initial load
duke
parents:
diff changeset
   551
  public static final short
02bb8761fcce Initial load
duke
parents:
diff changeset
   552
      TypeFile   = 0,
02bb8761fcce Initial load
duke
parents:
diff changeset
   553
      StubFile   = 1,
02bb8761fcce Initial load
duke
parents:
diff changeset
   554
      HelperFile = 2,
02bb8761fcce Initial load
duke
parents:
diff changeset
   555
      HolderFile = 3,
02bb8761fcce Initial load
duke
parents:
diff changeset
   556
      StateFile  = 4;
02bb8761fcce Initial load
duke
parents:
diff changeset
   557
02bb8761fcce Initial load
duke
parents:
diff changeset
   558
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   559
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   560
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   561
  public static void writePackage (PrintWriter stream, SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   562
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   563
    writePackage (stream, entry, TypeFile);
02bb8761fcce Initial load
duke
parents:
diff changeset
   564
  } // writePackage
02bb8761fcce Initial load
duke
parents:
diff changeset
   565
02bb8761fcce Initial load
duke
parents:
diff changeset
   566
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   567
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   568
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   569
  public static void writePackage (PrintWriter stream, SymtabEntry entry, String name, short type)
02bb8761fcce Initial load
duke
parents:
diff changeset
   570
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   571
    if (name != null && !name.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   572
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   573
      stream.println ("package " + name.replace ('/', '.') + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
   574
02bb8761fcce Initial load
duke
parents:
diff changeset
   575
      // This type is in a module.  Just in case it refers to types
02bb8761fcce Initial load
duke
parents:
diff changeset
   576
      // in the unnamed module, add an import statement for each of
02bb8761fcce Initial load
duke
parents:
diff changeset
   577
      // those types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   578
      if (!Compile.compiler.importTypes.isEmpty ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   579
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   580
        stream.println ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   581
        Vector v = addImportLines (entry, Compile.compiler.importTypes, type);
02bb8761fcce Initial load
duke
parents:
diff changeset
   582
        printImports (v, stream);
02bb8761fcce Initial load
duke
parents:
diff changeset
   583
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   584
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   585
  } // writePackage
02bb8761fcce Initial load
duke
parents:
diff changeset
   586
02bb8761fcce Initial load
duke
parents:
diff changeset
   587
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   588
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   589
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   590
  public static void writePackage (PrintWriter stream, SymtabEntry entry, short type)
02bb8761fcce Initial load
duke
parents:
diff changeset
   591
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   592
    String fullName = containerFullName (entry.container ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   593
    if (fullName != null && !fullName.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   594
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   595
      stream.println ("package " + fullName.replace ('/', '.') + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
   596
       // This type is in a module.  Just in case it refers to types
02bb8761fcce Initial load
duke
parents:
diff changeset
   597
      // in the unnamed module, add an import statement for each of
02bb8761fcce Initial load
duke
parents:
diff changeset
   598
      // those types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   599
      if ((type != HolderFile || entry instanceof TypedefEntry) && !Compile.compiler.importTypes.isEmpty ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   600
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   601
        stream.println ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   602
        Vector v = addImportLines (entry, Compile.compiler.importTypes, type);
02bb8761fcce Initial load
duke
parents:
diff changeset
   603
        printImports (v, stream);
02bb8761fcce Initial load
duke
parents:
diff changeset
   604
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   605
      /*
02bb8761fcce Initial load
duke
parents:
diff changeset
   606
      Enumeration e = Compile.compiler.importTypes.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   607
      while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   608
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   609
        SymtabEntry i = (SymtabEntry)e.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   610
        // Write import for type
02bb8761fcce Initial load
duke
parents:
diff changeset
   611
        if (!(i instanceof TypedefEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   612
          stream.println ("import " + i.name () + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
   613
02bb8761fcce Initial load
duke
parents:
diff changeset
   614
        // Write import for Helper
02bb8761fcce Initial load
duke
parents:
diff changeset
   615
        if (!(i instanceof ConstEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   616
          stream.println ("import " + i.name () + "Helper;");
02bb8761fcce Initial load
duke
parents:
diff changeset
   617
02bb8761fcce Initial load
duke
parents:
diff changeset
   618
        // Write import for Holder
02bb8761fcce Initial load
duke
parents:
diff changeset
   619
        if (!(i instanceof ConstEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   620
          if (!(i instanceof TypedefEntry) || (i.type () instanceof SequenceEntry || !((TypedefEntry)i).arrayInfo ().isEmpty ()))
02bb8761fcce Initial load
duke
parents:
diff changeset
   621
            stream.println ("import " + i.name () + "Holder;");
02bb8761fcce Initial load
duke
parents:
diff changeset
   622
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   623
      */
02bb8761fcce Initial load
duke
parents:
diff changeset
   624
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   625
  } // writePackage
02bb8761fcce Initial load
duke
parents:
diff changeset
   626
02bb8761fcce Initial load
duke
parents:
diff changeset
   627
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   628
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   629
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   630
  static private void printImports (Vector importList, PrintWriter stream)
02bb8761fcce Initial load
duke
parents:
diff changeset
   631
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   632
    Enumeration e = importList.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   633
    while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   634
      stream.println ("import " + (String)e.nextElement () + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
   635
  } // printImport
02bb8761fcce Initial load
duke
parents:
diff changeset
   636
02bb8761fcce Initial load
duke
parents:
diff changeset
   637
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   638
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   639
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   640
  static private void addTo (Vector importList, String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   641
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   642
    // REVISIT - <d62023-klr> was also importing ValueBaseHolder and Helper
02bb8761fcce Initial load
duke
parents:
diff changeset
   643
    if (name.startsWith ("ValueBase"))  // don't import ValueBase*
02bb8761fcce Initial load
duke
parents:
diff changeset
   644
      if ((name.compareTo ("ValueBase") == 0) ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   645
          (name.compareTo ("ValueBaseHolder") == 0) ||
02bb8761fcce Initial load
duke
parents:
diff changeset
   646
              (name.compareTo ("ValueBaseHelper") == 0))
02bb8761fcce Initial load
duke
parents:
diff changeset
   647
        return;
02bb8761fcce Initial load
duke
parents:
diff changeset
   648
    if (!importList.contains (name))
02bb8761fcce Initial load
duke
parents:
diff changeset
   649
      importList.addElement (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   650
  } // addTo
02bb8761fcce Initial load
duke
parents:
diff changeset
   651
02bb8761fcce Initial load
duke
parents:
diff changeset
   652
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   653
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   654
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   655
  static private Vector addImportLines (SymtabEntry entry, Vector importTypes, short type)
02bb8761fcce Initial load
duke
parents:
diff changeset
   656
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   657
    Vector importList = new Vector ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   658
    if (entry instanceof ConstEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   659
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   660
      ConstEntry c      = (ConstEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   661
      Object     cvalue = c.value ().value ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   662
      if (cvalue instanceof ConstEntry && importTypes.contains (cvalue))
02bb8761fcce Initial load
duke
parents:
diff changeset
   663
        addTo (importList, ((ConstEntry)cvalue).name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   664
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   665
    else if (entry instanceof ValueEntry && type == HelperFile) // <d59512>
02bb8761fcce Initial load
duke
parents:
diff changeset
   666
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   667
      // This code inspired by ValueGen.getConcreteBaseTypeCode().  Helper method
02bb8761fcce Initial load
duke
parents:
diff changeset
   668
      // type() could be invoked against a global valuetype.
02bb8761fcce Initial load
duke
parents:
diff changeset
   669
      if (((ValueEntry)entry).derivedFrom ().size () > 0) // <59596> KLR HACK
02bb8761fcce Initial load
duke
parents:
diff changeset
   670
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   671
        ValueEntry base = (ValueEntry)((ValueEntry)entry).derivedFrom ().elementAt (0);
02bb8761fcce Initial load
duke
parents:
diff changeset
   672
        String baseName = base.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   673
        if (!"ValueBase".equals (baseName))
02bb8761fcce Initial load
duke
parents:
diff changeset
   674
          if (importTypes.contains (base))
02bb8761fcce Initial load
duke
parents:
diff changeset
   675
            addTo (importList, baseName + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   676
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   677
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   678
    else if (entry instanceof InterfaceEntry && (type == TypeFile || type == StubFile))
02bb8761fcce Initial load
duke
parents:
diff changeset
   679
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   680
      InterfaceEntry i = (InterfaceEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   681
02bb8761fcce Initial load
duke
parents:
diff changeset
   682
      if (i instanceof ValueEntry) // <d59512>
02bb8761fcce Initial load
duke
parents:
diff changeset
   683
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   684
        // Examine interface parents in supports vector.
02bb8761fcce Initial load
duke
parents:
diff changeset
   685
        Enumeration e = ((ValueEntry)i).supports ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   686
        while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   687
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   688
          SymtabEntry parent = (SymtabEntry)e.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   689
          if (importTypes.contains (parent))
02bb8761fcce Initial load
duke
parents:
diff changeset
   690
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   691
            addTo (importList, parent.name () + "Operations");
02bb8761fcce Initial load
duke
parents:
diff changeset
   692
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   693
          // If this is a stub, then recurse to the parents
02bb8761fcce Initial load
duke
parents:
diff changeset
   694
          if (type == StubFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   695
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   696
            if (importTypes.contains (parent))
02bb8761fcce Initial load
duke
parents:
diff changeset
   697
              addTo (importList, parent.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   698
            Vector subImportList = addImportLines (parent, importTypes, StubFile);
02bb8761fcce Initial load
duke
parents:
diff changeset
   699
            Enumeration en = subImportList.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   700
            while (en.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   701
            {
02bb8761fcce Initial load
duke
parents:
diff changeset
   702
              addTo (importList, (String)en.nextElement ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   703
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   704
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   705
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   706
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   707
      // Interface or valuetype -- Examine interface and valuetype parents,
02bb8761fcce Initial load
duke
parents:
diff changeset
   708
      // Look through derivedFrom vector
02bb8761fcce Initial load
duke
parents:
diff changeset
   709
      Enumeration e = i.derivedFrom ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   710
      while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   711
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   712
        SymtabEntry parent = (SymtabEntry)e.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   713
        if (importTypes.contains (parent))
02bb8761fcce Initial load
duke
parents:
diff changeset
   714
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   715
          addTo (importList, parent.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   716
          // <d59512> Always add both imports, even though superfluous.  Cannot
02bb8761fcce Initial load
duke
parents:
diff changeset
   717
          // tell when writing Operations or Signature interface!
02bb8761fcce Initial load
duke
parents:
diff changeset
   718
          if (!(parent instanceof ValueEntry)) // && parent.name ().equals ("ValueBase")))
02bb8761fcce Initial load
duke
parents:
diff changeset
   719
            addTo (importList, parent.name () + "Operations");
02bb8761fcce Initial load
duke
parents:
diff changeset
   720
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   721
        // If this is a stub, then recurse to the parents
02bb8761fcce Initial load
duke
parents:
diff changeset
   722
        if (type == StubFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   723
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   724
          Vector subImportList = addImportLines (parent, importTypes, StubFile);
02bb8761fcce Initial load
duke
parents:
diff changeset
   725
          Enumeration en = subImportList.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   726
          while (en.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   727
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   728
            addTo (importList, (String)en.nextElement ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   729
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   730
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   731
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   732
      // Look through methods vector
02bb8761fcce Initial load
duke
parents:
diff changeset
   733
      e = i.methods ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   734
      while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   735
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   736
        MethodEntry m = (MethodEntry)e.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   737
02bb8761fcce Initial load
duke
parents:
diff changeset
   738
        // Look at method type
02bb8761fcce Initial load
duke
parents:
diff changeset
   739
        SymtabEntry mtype = typeOf (m.type ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   740
        if (mtype != null && importTypes.contains (mtype))
02bb8761fcce Initial load
duke
parents:
diff changeset
   741
          if (type == TypeFile || type == StubFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   742
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   743
            addTo (importList, mtype.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   744
            addTo (importList, mtype.name () + "Holder");
02bb8761fcce Initial load
duke
parents:
diff changeset
   745
            if (type == StubFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   746
              addTo (importList, mtype.name () + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   747
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   748
        checkForArrays (mtype, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   749
        // <d42256> Print import lines for globals constants and constants
02bb8761fcce Initial load
duke
parents:
diff changeset
   750
        // within global interfaces.
02bb8761fcce Initial load
duke
parents:
diff changeset
   751
        if (type == StubFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   752
          checkForBounds (mtype, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   753
02bb8761fcce Initial load
duke
parents:
diff changeset
   754
        // Look through exceptions
02bb8761fcce Initial load
duke
parents:
diff changeset
   755
        Enumeration exEnum = m.exceptions ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   756
        while (exEnum.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   757
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   758
          ExceptionEntry ex = (ExceptionEntry)exEnum.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   759
          if (importTypes.contains (ex))
02bb8761fcce Initial load
duke
parents:
diff changeset
   760
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   761
            addTo (importList, ex.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   762
            addTo (importList, ex.name () + "Helper"); // <d59063>
02bb8761fcce Initial load
duke
parents:
diff changeset
   763
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   764
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   765
02bb8761fcce Initial load
duke
parents:
diff changeset
   766
        // Look through parameters
02bb8761fcce Initial load
duke
parents:
diff changeset
   767
        Enumeration parms = m.parameters ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   768
        while (parms.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   769
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   770
          ParameterEntry parm = (ParameterEntry)parms.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   771
          SymtabEntry parmType = typeOf (parm.type ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   772
          if (importTypes.contains (parmType))
02bb8761fcce Initial load
duke
parents:
diff changeset
   773
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   774
            // <d59771> Helper needed in stubs.
02bb8761fcce Initial load
duke
parents:
diff changeset
   775
            if (type == StubFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   776
              addTo (importList, parmType.name () + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   777
            if (parm.passType () == ParameterEntry.In)
02bb8761fcce Initial load
duke
parents:
diff changeset
   778
              addTo (importList, parmType.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   779
            else
02bb8761fcce Initial load
duke
parents:
diff changeset
   780
              addTo (importList, parmType.name () + "Holder");
02bb8761fcce Initial load
duke
parents:
diff changeset
   781
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   782
          checkForArrays (parmType, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   783
          // <d42256>
02bb8761fcce Initial load
duke
parents:
diff changeset
   784
          if (type == StubFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   785
            checkForBounds (parmType, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   786
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   787
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   788
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   789
    else if (entry instanceof StructEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   790
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   791
      StructEntry s = (StructEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   792
02bb8761fcce Initial load
duke
parents:
diff changeset
   793
      // Look through the members
02bb8761fcce Initial load
duke
parents:
diff changeset
   794
      Enumeration members = s.members ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   795
      while (members.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   796
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   797
        SymtabEntry member = (TypedefEntry)members.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   798
        // <d48034> Need to add helper name for typedef members.  This name
02bb8761fcce Initial load
duke
parents:
diff changeset
   799
        // is referenced at typecode generation in Helper class.
02bb8761fcce Initial load
duke
parents:
diff changeset
   800
        SymtabEntry memberType = member.type ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   801
        member = typeOf (member);
02bb8761fcce Initial load
duke
parents:
diff changeset
   802
        if (importTypes.contains (member))
02bb8761fcce Initial load
duke
parents:
diff changeset
   803
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   804
          // If this IS a typedef, then there are only Helper/Holder classes.
02bb8761fcce Initial load
duke
parents:
diff changeset
   805
          //if (!(member instanceof TypedefEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   806
          // <d59437>  Valueboxes
02bb8761fcce Initial load
duke
parents:
diff changeset
   807
          if (!(member instanceof TypedefEntry) && !(member instanceof ValueBoxEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   808
            addTo (importList, member.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   809
          // <d48034> Add helper name of alias, too, if member is a typedef.
02bb8761fcce Initial load
duke
parents:
diff changeset
   810
          //if (type == HelperFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   811
          //  addTo (importList, member.name () + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   812
          if (type == HelperFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   813
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
   814
            addTo (importList, member.name () + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   815
            if (memberType instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   816
              addTo (importList, memberType.name () + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   817
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
   818
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   819
        checkForArrays (member, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   820
        checkForBounds (member, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   821
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   822
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   823
    else if (entry instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   824
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   825
      TypedefEntry t = (TypedefEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   826
      String arrays = checkForArrayBase (t, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   827
      if (type == HelperFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   828
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   829
        checkForArrayDimensions (arrays, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   830
        try
02bb8761fcce Initial load
duke
parents:
diff changeset
   831
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   832
          String name = (String)t.dynamicVariable (Compile.typedefInfo);
02bb8761fcce Initial load
duke
parents:
diff changeset
   833
          int index = name.indexOf ('[');
02bb8761fcce Initial load
duke
parents:
diff changeset
   834
          if (index >= 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   835
            name = name.substring (0, index);
02bb8761fcce Initial load
duke
parents:
diff changeset
   836
          // See if the base type should be added to the list.
02bb8761fcce Initial load
duke
parents:
diff changeset
   837
          SymtabEntry typeEntry = (SymtabEntry)symbolTable.get (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   838
          if (typeEntry != null && importTypes.contains (typeEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   839
            addTo (importList, typeEntry.name () + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   840
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   841
        catch (NoSuchFieldException e)
02bb8761fcce Initial load
duke
parents:
diff changeset
   842
        {}
02bb8761fcce Initial load
duke
parents:
diff changeset
   843
02bb8761fcce Initial load
duke
parents:
diff changeset
   844
        // <d42256> Typedefs for global bounded strings need import
02bb8761fcce Initial load
duke
parents:
diff changeset
   845
        // statement when bound expression contains non-literal constants.
02bb8761fcce Initial load
duke
parents:
diff changeset
   846
        checkForBounds (typeOf (t), importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   847
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   848
      Vector subImportList = addImportLines (t.type (), importTypes, type);
02bb8761fcce Initial load
duke
parents:
diff changeset
   849
      Enumeration e = subImportList.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   850
      while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   851
        addTo (importList, (String)e.nextElement ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   852
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   853
    else if (entry instanceof UnionEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   854
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   855
      UnionEntry u = (UnionEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   856
02bb8761fcce Initial load
duke
parents:
diff changeset
   857
      // Look at the discriminant type
02bb8761fcce Initial load
duke
parents:
diff changeset
   858
      SymtabEntry utype = typeOf (u.type ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   859
      if (utype instanceof EnumEntry && importTypes.contains (utype))
02bb8761fcce Initial load
duke
parents:
diff changeset
   860
        addTo (importList, utype.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   861
02bb8761fcce Initial load
duke
parents:
diff changeset
   862
      // Look through the branches
02bb8761fcce Initial load
duke
parents:
diff changeset
   863
      Enumeration branches = u.branches ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   864
      while (branches.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   865
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   866
        UnionBranch branch = (UnionBranch)branches.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   867
        SymtabEntry branchEntry = typeOf (branch.typedef);
02bb8761fcce Initial load
duke
parents:
diff changeset
   868
        if (importTypes.contains (branchEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   869
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
   870
          addTo (importList, branchEntry.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   871
          if (type == HelperFile)
02bb8761fcce Initial load
duke
parents:
diff changeset
   872
            addTo (importList, branchEntry.name () + "Helper");
02bb8761fcce Initial load
duke
parents:
diff changeset
   873
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   874
        checkForArrays (branchEntry, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   875
        // <d42256>
02bb8761fcce Initial load
duke
parents:
diff changeset
   876
        checkForBounds (branchEntry, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   877
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   878
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   879
02bb8761fcce Initial load
duke
parents:
diff changeset
   880
    // If a typedef is not a sequence or an array, only holders and
02bb8761fcce Initial load
duke
parents:
diff changeset
   881
    // helpers are generated for it.  Remove references to such
02bb8761fcce Initial load
duke
parents:
diff changeset
   882
    // class names.
02bb8761fcce Initial load
duke
parents:
diff changeset
   883
    Enumeration en = importList.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   884
    while (en.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   885
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   886
      String name = (String)en.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   887
      SymtabEntry e = (SymtabEntry)symbolTable.get (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   888
      if (e != null && e instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   889
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   890
        TypedefEntry t = (TypedefEntry)e;
02bb8761fcce Initial load
duke
parents:
diff changeset
   891
        if (t.arrayInfo ().size () == 0 || !(t.type () instanceof SequenceEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   892
          importList.removeElement (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   893
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   894
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   895
    return importList;
02bb8761fcce Initial load
duke
parents:
diff changeset
   896
  } // addImportLines
02bb8761fcce Initial load
duke
parents:
diff changeset
   897
02bb8761fcce Initial load
duke
parents:
diff changeset
   898
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   899
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   900
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   901
  static private void checkForArrays (SymtabEntry entry, Vector importTypes, Vector importList)
02bb8761fcce Initial load
duke
parents:
diff changeset
   902
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   903
    if (entry instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   904
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   905
      TypedefEntry t = (TypedefEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   906
      String arrays = checkForArrayBase (t, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   907
      checkForArrayDimensions (arrays, importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   908
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   909
  } // checkForArrays
02bb8761fcce Initial load
duke
parents:
diff changeset
   910
02bb8761fcce Initial load
duke
parents:
diff changeset
   911
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   912
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   913
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   914
  static private String checkForArrayBase (TypedefEntry t, Vector importTypes, Vector importList)
02bb8761fcce Initial load
duke
parents:
diff changeset
   915
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   916
    String arrays = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   917
    try
02bb8761fcce Initial load
duke
parents:
diff changeset
   918
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   919
      String name = (String)t.dynamicVariable (Compile.typedefInfo);
02bb8761fcce Initial load
duke
parents:
diff changeset
   920
      int index = name.indexOf ('[');
02bb8761fcce Initial load
duke
parents:
diff changeset
   921
      if (index >= 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   922
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   923
        arrays = name.substring (index);
02bb8761fcce Initial load
duke
parents:
diff changeset
   924
        name = name.substring (0, index);
02bb8761fcce Initial load
duke
parents:
diff changeset
   925
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   926
02bb8761fcce Initial load
duke
parents:
diff changeset
   927
      // See if the base type should be added to the list.
02bb8761fcce Initial load
duke
parents:
diff changeset
   928
      SymtabEntry typeEntry = (SymtabEntry)symbolTable.get (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   929
      if (typeEntry != null && importTypes.contains (typeEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
   930
        addTo (importList, typeEntry.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   931
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   932
    catch (NoSuchFieldException e)
02bb8761fcce Initial load
duke
parents:
diff changeset
   933
    {}
02bb8761fcce Initial load
duke
parents:
diff changeset
   934
    return arrays;
02bb8761fcce Initial load
duke
parents:
diff changeset
   935
  } // checkForArrayBase
02bb8761fcce Initial load
duke
parents:
diff changeset
   936
02bb8761fcce Initial load
duke
parents:
diff changeset
   937
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   938
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
   939
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   940
  static private void checkForArrayDimensions (String arrays, Vector importTypes, Vector importList)
02bb8761fcce Initial load
duke
parents:
diff changeset
   941
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   942
    // See if any of the arrays contain a constentry.
02bb8761fcce Initial load
duke
parents:
diff changeset
   943
    // If so, see if it should be added to the list.
02bb8761fcce Initial load
duke
parents:
diff changeset
   944
    while (!arrays.equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
   945
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   946
      int index = arrays.indexOf (']');
02bb8761fcce Initial load
duke
parents:
diff changeset
   947
      String dim = arrays.substring (1, index);
02bb8761fcce Initial load
duke
parents:
diff changeset
   948
      arrays = arrays.substring (index + 1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   949
      SymtabEntry constant = (SymtabEntry)symbolTable.get (dim);
02bb8761fcce Initial load
duke
parents:
diff changeset
   950
      if (constant == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   951
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   952
        // A constant expr could be of the form <const> OR
02bb8761fcce Initial load
duke
parents:
diff changeset
   953
        // <interface>.<const>.  This if branch checks for that case.
02bb8761fcce Initial load
duke
parents:
diff changeset
   954
        int i = dim.lastIndexOf ('.');
02bb8761fcce Initial load
duke
parents:
diff changeset
   955
        if (i >= 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   956
          constant = (SymtabEntry)symbolTable.get (dim.substring (0, i));
02bb8761fcce Initial load
duke
parents:
diff changeset
   957
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   958
      if (constant != null && importTypes.contains (constant))
02bb8761fcce Initial load
duke
parents:
diff changeset
   959
        addTo (importList, constant.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   960
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   961
  } // checkForArrayDimensions
02bb8761fcce Initial load
duke
parents:
diff changeset
   962
02bb8761fcce Initial load
duke
parents:
diff changeset
   963
  // <d42256> Call the following method when its necessary to determine the
02bb8761fcce Initial load
duke
parents:
diff changeset
   964
  // the import types for IDL constructs containing arbitrary positive int.
02bb8761fcce Initial load
duke
parents:
diff changeset
   965
  // expressions, which may specify non-literal constants.
02bb8761fcce Initial load
duke
parents:
diff changeset
   966
02bb8761fcce Initial load
duke
parents:
diff changeset
   967
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   968
   * Determine the import lines for template types.
02bb8761fcce Initial load
duke
parents:
diff changeset
   969
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   970
  static private void checkForBounds (SymtabEntry entry, Vector importTypes, Vector importList)
02bb8761fcce Initial load
duke
parents:
diff changeset
   971
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   972
    // Obtain actual type, just to be complete.
02bb8761fcce Initial load
duke
parents:
diff changeset
   973
    SymtabEntry entryType = entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
   974
    while (entryType instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   975
      entryType = entryType.type ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   976
02bb8761fcce Initial load
duke
parents:
diff changeset
   977
    if (entryType instanceof StringEntry && ((StringEntry)entryType).maxSize () != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   978
      checkForGlobalConstants (((StringEntry)entryType).maxSize ().rep (), importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   979
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   980
      if (entryType instanceof SequenceEntry && ((SequenceEntry)entryType).maxSize () != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   981
        checkForGlobalConstants (((SequenceEntry)entryType).maxSize ().rep (), importTypes, importList);
02bb8761fcce Initial load
duke
parents:
diff changeset
   982
  } // checkForBounds
02bb8761fcce Initial load
duke
parents:
diff changeset
   983
02bb8761fcce Initial load
duke
parents:
diff changeset
   984
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   985
   * Extract the global constants from the supplied integer expression
02bb8761fcce Initial load
duke
parents:
diff changeset
   986
   * representation (string) and add them to the supplied import list.
02bb8761fcce Initial load
duke
parents:
diff changeset
   987
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   988
  static private void checkForGlobalConstants (String exprRep, Vector importTypes, Vector importList)
02bb8761fcce Initial load
duke
parents:
diff changeset
   989
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   990
    // NOTE: Do not use '/' as a delimiter. Symbol table names use '/' as a
02bb8761fcce Initial load
duke
parents:
diff changeset
   991
    // delimiter and would not be otherwise properly collected. Blanks and
02bb8761fcce Initial load
duke
parents:
diff changeset
   992
    // arithmetic symbols do not appear in tokens, except for '/'.
02bb8761fcce Initial load
duke
parents:
diff changeset
   993
    java.util.StringTokenizer st = new java.util.StringTokenizer (exprRep, " +-*()~&|^%<>");
02bb8761fcce Initial load
duke
parents:
diff changeset
   994
    while (st.hasMoreTokens ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   995
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   996
      String token = st.nextToken ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   997
      // When token contains '/', it represents the division symbol or
02bb8761fcce Initial load
duke
parents:
diff changeset
   998
      // a nested type (e.g., I/x). Ignore the division symbol, and don't
02bb8761fcce Initial load
duke
parents:
diff changeset
   999
      // forget constants declared within global interfaces!
02bb8761fcce Initial load
duke
parents:
diff changeset
  1000
      if (!token.equals ("/"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1001
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1002
        SymtabEntry typeEntry = (SymtabEntry)symbolTable.get (token);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1003
        if (typeEntry instanceof ConstEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1004
        {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1005
          int slashIdx = token.indexOf ('/');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1006
          if (slashIdx < 0)  // Possible global constant
02bb8761fcce Initial load
duke
parents:
diff changeset
  1007
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1008
            if (importTypes.contains (typeEntry))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1009
              addTo (importList, typeEntry.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1010
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1011
          else  // Possible constant in global interface
02bb8761fcce Initial load
duke
parents:
diff changeset
  1012
          {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1013
            SymtabEntry constContainer = (SymtabEntry)symbolTable.get (token.substring (0, slashIdx));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1014
            if (constContainer instanceof InterfaceEntry && importTypes.contains (constContainer))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1015
              addTo (importList, constContainer.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1016
          }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1017
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1018
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1019
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1020
  } // checkForGlobalConstants
02bb8761fcce Initial load
duke
parents:
diff changeset
  1021
02bb8761fcce Initial load
duke
parents:
diff changeset
  1022
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1023
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1024
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1025
  public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, PrintWriter stream)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1026
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1027
    if (entry instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1028
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1029
      TypedefEntry td = (TypedefEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1030
      writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), stream);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1031
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1032
    else if (entry instanceof SequenceEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1033
      writeInitializer (indent, name, arrayDcl + "[]", entry.type (), stream);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1034
    else if (entry instanceof EnumEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1035
      if (arrayDcl.length () > 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1036
        stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1037
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1038
        stream.println (indent + javaName (entry) + ' ' + name + " = null;");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1039
    else if (entry instanceof PrimitiveEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1040
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1041
      boolean array = arrayDcl.length () > 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1042
      String tname = javaPrimName (entry.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1043
      if (tname.equals ("boolean"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1044
        stream.println (indent + "boolean " + name + arrayDcl + " = " + (array ? "null;" : "false;"));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1045
      else if (tname.equals ("org.omg.CORBA.TypeCode"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1046
        stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = null;");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1047
      else if (tname.equals ("org.omg.CORBA.Any"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1048
        stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = null;");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1049
      else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1050
        stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = null;");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1051
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1052
        stream.println (indent + tname + ' ' + name + arrayDcl + " = " + (array ? "null;" : '(' + tname + ")0;"));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1053
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1054
    // <f46082.51> Remove -stateful feature. This case is identical to next one
02bb8761fcce Initial load
duke
parents:
diff changeset
  1055
    // because javaName() supplants javaStatefulName().
02bb8761fcce Initial load
duke
parents:
diff changeset
  1056
    //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1057
    //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = null;");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1058
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1059
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = null;");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1060
  } // writeInitializer
02bb8761fcce Initial load
duke
parents:
diff changeset
  1061
02bb8761fcce Initial load
duke
parents:
diff changeset
  1062
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1063
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1064
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1065
  public static void writeInitializer (String indent, String name, String arrayDcl, SymtabEntry entry, String initializer, PrintWriter stream)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1066
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1067
    if (entry instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1068
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1069
      TypedefEntry td = (TypedefEntry)entry;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1070
      writeInitializer (indent, name, arrayDcl + sansArrayInfo (td.arrayInfo ()), td.type (), initializer, stream);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1071
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1072
    else if (entry instanceof SequenceEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1073
      writeInitializer (indent, name, arrayDcl + "[]", entry.type (), initializer, stream);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1074
    else if (entry instanceof EnumEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1075
      if (arrayDcl.length () > 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1076
        stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1077
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1078
        stream.println (indent + javaName (entry) + ' ' + name + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1079
    else if (entry instanceof PrimitiveEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1080
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1081
      boolean array = arrayDcl.length () > 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1082
      String tname = javaPrimName (entry.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1083
      if (tname.equals ("boolean"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1084
        stream.println (indent + "boolean " + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1085
      else if (tname.equals ("org.omg.CORBA.TypeCode"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1086
        stream.println (indent + "org.omg.CORBA.TypeCode " + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1087
      else if (tname.equals ("org.omg.CORBA.Any"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1088
        stream.println (indent + "org.omg.CORBA.Any " + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1089
      else if (tname.equals ("org.omg.CORBA.Principal")) // <d61961>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1090
        stream.println (indent + "org.omg.CORBA.Principal " + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1091
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1092
        stream.println (indent + tname + ' ' + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1093
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1094
    // <f46082.51> Remove -stateful feature. This case is identical to next one
02bb8761fcce Initial load
duke
parents:
diff changeset
  1095
    // because javaName() supplants javaStatefulName().
02bb8761fcce Initial load
duke
parents:
diff changeset
  1096
    //else if (entry instanceof InterfaceEntry && ((InterfaceEntry)entry).state () != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1097
    //  stream.println (indent + javaStatefulName ((InterfaceEntry)entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1098
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1099
      stream.println (indent + javaName (entry) + ' ' + name + arrayDcl + " = " + initializer + ';');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1100
  } // writeInitializer
02bb8761fcce Initial load
duke
parents:
diff changeset
  1101
02bb8761fcce Initial load
duke
parents:
diff changeset
  1102
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1103
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1104
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1105
  public static void mkdir (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1106
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1107
    String targetDir = ((Arguments)Compile.compiler.arguments).targetDir; // F46838.4
02bb8761fcce Initial load
duke
parents:
diff changeset
  1108
    name = (targetDir + name).replace ('/', File.separatorChar); // F46838.4
02bb8761fcce Initial load
duke
parents:
diff changeset
  1109
    File pkg = new File (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1110
    if (!pkg.exists ())
02bb8761fcce Initial load
duke
parents:
diff changeset
  1111
      if (!pkg.mkdirs ())
02bb8761fcce Initial load
duke
parents:
diff changeset
  1112
        System.err.println (getMessage ("Util.cantCreatePkg", name));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1113
  } // mkdir
02bb8761fcce Initial load
duke
parents:
diff changeset
  1114
02bb8761fcce Initial load
duke
parents:
diff changeset
  1115
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1116
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1117
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1118
  public static void writeProlog (PrintWriter stream, String filename)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1119
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1120
    // <d59355> Remove target directory
02bb8761fcce Initial load
duke
parents:
diff changeset
  1121
    String targetDir = ((Arguments)Compile.compiler.arguments).targetDir;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1122
    if (targetDir != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1123
      filename = filename.substring (targetDir.length ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1124
    stream.println ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1125
    stream.println ("/**");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1126
    stream.println ("* " + filename.replace (File.separatorChar, '/') +
02bb8761fcce Initial load
duke
parents:
diff changeset
  1127
        " .");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1128
    stream.println ("* " + Util.getMessage ("toJavaProlog1",
02bb8761fcce Initial load
duke
parents:
diff changeset
  1129
        Util.getMessage ("Version.product", Util.getMessage ("Version.number"))));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1130
    // <d48911> Do not introduce invalid escape characters into comment! <daz>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1131
    //stream.println ("* " + Util.getMessage ("toJavaProlog2", Compile.compiler.arguments.file));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1132
    stream.println ("* " + Util.getMessage ("toJavaProlog2", Compile.compiler.arguments.file.replace (File.separatorChar, '/')));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1133
02bb8761fcce Initial load
duke
parents:
diff changeset
  1134
    ///////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
  1135
    // This SHOULD work, but there's a bug in the JDK.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1136
    //    stream.println ("* " + DateFormat.getDateTimeInstance (DateFormat.FULL, DateFormat.FULL, Locale.getDefault ()).format (new Date ()));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1137
    // This gets around the bug:
02bb8761fcce Initial load
duke
parents:
diff changeset
  1138
02bb8761fcce Initial load
duke
parents:
diff changeset
  1139
    DateFormat formatter = DateFormat.getDateTimeInstance (DateFormat.FULL, DateFormat.FULL, Locale.getDefault ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1140
02bb8761fcce Initial load
duke
parents:
diff changeset
  1141
    // Japanese-specific workaround.  JDK bug 4069784 being repaired by JavaSoft.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1142
    // Keep this transient solution until bug fix is reported.cd .
02bb8761fcce Initial load
duke
parents:
diff changeset
  1143
02bb8761fcce Initial load
duke
parents:
diff changeset
  1144
    if (Locale.getDefault () == Locale.JAPAN)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1145
      formatter.setTimeZone (java.util.TimeZone.getTimeZone ("JST"));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1146
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1147
      formatter.setTimeZone (java.util.TimeZone.getDefault ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1148
02bb8761fcce Initial load
duke
parents:
diff changeset
  1149
    stream.println ("* " + formatter.format (new Date ()));
02bb8761fcce Initial load
duke
parents:
diff changeset
  1150
02bb8761fcce Initial load
duke
parents:
diff changeset
  1151
    // <daz>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1152
    ///////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
  1153
02bb8761fcce Initial load
duke
parents:
diff changeset
  1154
    stream.println ("*/");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1155
    stream.println ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1156
  } // writeProlog
02bb8761fcce Initial load
duke
parents:
diff changeset
  1157
02bb8761fcce Initial load
duke
parents:
diff changeset
  1158
  // keywords ending in Holder or Helper or Package have '_' prepended.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1159
  // These prepended underscores must not be part of anything sent
02bb8761fcce Initial load
duke
parents:
diff changeset
  1160
  // across the wire, so these two methods are provided to strip them
02bb8761fcce Initial load
duke
parents:
diff changeset
  1161
  // off.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1162
02bb8761fcce Initial load
duke
parents:
diff changeset
  1163
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1164
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1165
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1166
  public static String stripLeadingUnderscores (String string)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1167
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1168
    while (string.startsWith ("_"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1169
      string = string.substring (1);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1170
    return string;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1171
  } // stripLeadingUnderscores
02bb8761fcce Initial load
duke
parents:
diff changeset
  1172
02bb8761fcce Initial load
duke
parents:
diff changeset
  1173
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1174
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1175
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1176
  public static String stripLeadingUnderscoresFromID (String string)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1177
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1178
    String stringPrefix = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1179
    int slashIndex = string.indexOf (':');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1180
    if (slashIndex >= 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1181
      do
02bb8761fcce Initial load
duke
parents:
diff changeset
  1182
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1183
        stringPrefix = stringPrefix + string.substring (0, slashIndex + 1);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1184
        string = string.substring (slashIndex + 1);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1185
        while (string.startsWith ("_"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1186
          string = string.substring (1);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1187
        slashIndex = string.indexOf ('/');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1188
      } while (slashIndex >= 0);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1189
    return stringPrefix + string;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1190
  } // stripLeadingUnderscoresFromID
02bb8761fcce Initial load
duke
parents:
diff changeset
  1191
02bb8761fcce Initial load
duke
parents:
diff changeset
  1192
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1193
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1194
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1195
  public static String parseExpression (Expression e)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1196
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1197
    if (e instanceof Terminal)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1198
      return parseTerminal ((Terminal)e);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1199
    else if (e instanceof BinaryExpr)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1200
      return parseBinary ((BinaryExpr)e);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1201
    else if (e instanceof UnaryExpr)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1202
      return parseUnary ((UnaryExpr)e);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1203
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1204
      return "(UNKNOWN_VALUE)"; // This shouldn't happen unless someone slips
02bb8761fcce Initial load
duke
parents:
diff changeset
  1205
                                // in another type of expression.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1206
  } // parseExpression
02bb8761fcce Initial load
duke
parents:
diff changeset
  1207
02bb8761fcce Initial load
duke
parents:
diff changeset
  1208
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1209
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1210
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1211
  static String parseTerminal (Terminal e)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1212
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1213
    if (e.value () instanceof ConstEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1214
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1215
      ConstEntry c = (ConstEntry)e.value ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1216
      if (c.container () instanceof InterfaceEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1217
        return javaQualifiedName (c.container ()) + '.' + c.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1218
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1219
        return javaQualifiedName (c) + ".value";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1220
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1221
    else if (e.value () instanceof Expression)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1222
      return '(' + parseExpression ((Expression)e.value ()) + ')';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1223
    else if (e.value () instanceof Character)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1224
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1225
      if (((Character)e.value ()).charValue () == '\013')
02bb8761fcce Initial load
duke
parents:
diff changeset
  1226
        // e.rep is \v.  \v for vertical tab is meaningless in Java.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1227
        return "'\\013'";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1228
      else if (((Character)e.value ()).charValue () == '\007')
02bb8761fcce Initial load
duke
parents:
diff changeset
  1229
        // e.rep is \a.  \a for alert is meaningless in Java.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1230
        return "'\\007'";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1231
      else if (e.rep ().startsWith ("'\\x"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1232
        return hexToOctal (e.rep ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1233
      else if (e.rep ().equals ("'\\?'"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1234
        return "'?'";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1235
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1236
        return e.rep ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1237
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1238
    else if (e.value () instanceof Boolean)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1239
      return e.value ().toString ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1240
02bb8761fcce Initial load
duke
parents:
diff changeset
  1241
    // <d54640> If value is type "unsigned long long" (ull) and its magnitude
02bb8761fcce Initial load
duke
parents:
diff changeset
  1242
    // is greater than the maximal Java long (i.e., IDL long long) value, then
02bb8761fcce Initial load
duke
parents:
diff changeset
  1243
    // return its signed representation rather than its actual representation.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1244
    /*
02bb8761fcce Initial load
duke
parents:
diff changeset
  1245
    // Support long long
02bb8761fcce Initial load
duke
parents:
diff changeset
  1246
    //else if (e.value () instanceof Long)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1247
    else if (e.value () instanceof BigInteger &&
02bb8761fcce Initial load
duke
parents:
diff changeset
  1248
             (e.type ().indexOf ("long long") >= 0 || e.type ().equals ("unsigned long"))) // <klr>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1249
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1250
      String rep   = e.rep ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1251
      int    index = rep.indexOf (')');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1252
      if (index < 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1253
        return rep + 'L';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1254
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1255
        return rep.substring (0, index) + 'L' + rep.substring (index);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1256
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1257
    */
02bb8761fcce Initial load
duke
parents:
diff changeset
  1258
    else if (e.value () instanceof BigInteger)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1259
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1260
      // Get the correct primitive type. Since integer types (octet, short,
02bb8761fcce Initial load
duke
parents:
diff changeset
  1261
      // long, long long, unsigned short, unsigned long, unsigned long long)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1262
      // could be aliased (typedef'ed) to any arbitrary levels, the code
02bb8761fcce Initial load
duke
parents:
diff changeset
  1263
      // below walks up the alias chain to get to the primitive type.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1264
02bb8761fcce Initial load
duke
parents:
diff changeset
  1265
      // Get the symbol table entry corresponding to the 'type'.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1266
      SymtabEntry typeEntry = (SymtabEntry) symbolTable.get(e.type());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1267
02bb8761fcce Initial load
duke
parents:
diff changeset
  1268
      // Get to the primitive type.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1269
      while (typeEntry.type() != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1270
          typeEntry = typeEntry.type();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1271
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1272
      String type = typeEntry.name();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1273
02bb8761fcce Initial load
duke
parents:
diff changeset
  1274
      if (type.equals("unsigned long long") &&
02bb8761fcce Initial load
duke
parents:
diff changeset
  1275
          ((BigInteger)e.value ()).compareTo (Expression.llMax) > 0) // value > long long Max?
02bb8761fcce Initial load
duke
parents:
diff changeset
  1276
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1277
        // Convert to signed value, which will always be negative.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1278
        BigInteger v = (BigInteger)e.value ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1279
        v = v.subtract (Expression.twoPow64);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1280
        int index = e.rep ().indexOf (')');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1281
        if (index < 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1282
          return v.toString () + 'L';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1283
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1284
          return '(' + v.toString () + 'L' + ')';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1285
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1286
      else if ( type.indexOf("long long") >= 0 || type.equals("unsigned long") )
02bb8761fcce Initial load
duke
parents:
diff changeset
  1287
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1288
        String rep   = e.rep ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1289
        int    index = rep.indexOf (')');
02bb8761fcce Initial load
duke
parents:
diff changeset
  1290
        if (index < 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1291
          return rep + 'L';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1292
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1293
          return rep.substring (0, index) + 'L' + rep.substring (index);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1294
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1295
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1296
        return e.rep ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1297
    } // end <d54640>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1298
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1299
      return e.rep ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1300
  } // parseTerminal
02bb8761fcce Initial load
duke
parents:
diff changeset
  1301
02bb8761fcce Initial load
duke
parents:
diff changeset
  1302
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1303
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1304
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1305
  static String hexToOctal (String hex)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1306
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1307
    // The format of hex is '/xXX' where XX is one or two hex digits.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1308
    // This statement pulls off XX.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1309
    hex = hex.substring (3, hex.length () - 1);
02bb8761fcce Initial load
duke
parents:
diff changeset
  1310
    return "'\\" + Integer.toString (Integer.parseInt (hex, 16), 8) + "'";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1311
  } // hexToOctal
02bb8761fcce Initial load
duke
parents:
diff changeset
  1312
02bb8761fcce Initial load
duke
parents:
diff changeset
  1313
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1314
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1315
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1316
  static String parseBinary (BinaryExpr e)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1317
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1318
    String castString = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1319
    if (e.value () instanceof Float || e.value () instanceof Double)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1320
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1321
      castString = "(double)";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1322
      if (!(e instanceof Plus || e instanceof Minus ||
02bb8761fcce Initial load
duke
parents:
diff changeset
  1323
            e instanceof Times || e instanceof Divide))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1324
        System.err.println ("Operator " + e.op () + " is invalid on floating point numbers");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1325
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1326
    else if (e.value () instanceof Number)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1327
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1328
      if (e.type (). indexOf ("long long") >= 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1329
        castString = "(long)";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1330
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1331
        castString = "(int)";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1332
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1333
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1334
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1335
      castString = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1336
      System.err.println ("Unknown type in constant expression");
02bb8761fcce Initial load
duke
parents:
diff changeset
  1337
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1338
02bb8761fcce Initial load
duke
parents:
diff changeset
  1339
    // <d54640> Must emit value rather than representation when type "unsigned
02bb8761fcce Initial load
duke
parents:
diff changeset
  1340
    // long long" (ull) because emitted binary arithmetic expressions containing
02bb8761fcce Initial load
duke
parents:
diff changeset
  1341
    // ull's converted to long (i.e., IDL long long) do not always compute to
02bb8761fcce Initial load
duke
parents:
diff changeset
  1342
    // the correct result.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1343
02bb8761fcce Initial load
duke
parents:
diff changeset
  1344
    //return castString + '(' + parseExpression (e.left ()) + ' ' + e.op () + ' ' + parseExpression (e.right ()) + ')';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1345
    if (e.type ().equals ("unsigned long long"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1346
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1347
      BigInteger value = (BigInteger)e.value ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1348
      if (value.compareTo (Expression.llMax) > 0) // value > long long max?
02bb8761fcce Initial load
duke
parents:
diff changeset
  1349
        value = value.subtract (Expression.twoPow64); // Convert to Java long (signed)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1350
      return castString + '(' + value.toString () + 'L' + ')';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1351
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1352
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1353
      return castString + '(' + parseExpression (e.left ()) + ' ' + e.op () + ' ' + parseExpression (e.right ()) + ')';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1354
    // <d54640> end
02bb8761fcce Initial load
duke
parents:
diff changeset
  1355
  } // parseBinary
02bb8761fcce Initial load
duke
parents:
diff changeset
  1356
02bb8761fcce Initial load
duke
parents:
diff changeset
  1357
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1358
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1359
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1360
  static String parseUnary (UnaryExpr e)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1361
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1362
    if (!(e.value () instanceof Number))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1363
      return "(UNKNOWN_VALUE)"; // This shouldn't happen if the parser checked the expression types correctly.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1364
    else if ((e.value () instanceof Float || e.value () instanceof Double) && e instanceof Not)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1365
      return "(UNKNOWN_VALUE)"; // This shouldn't happen if the parser checked the expression types correctly.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1366
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1367
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1368
      String castString = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1369
      if (e.operand ().value () instanceof Float ||
02bb8761fcce Initial load
duke
parents:
diff changeset
  1370
          e.operand ().value () instanceof Double)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1371
        castString = "(double)";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1372
      // Support long long.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1373
      //else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1374
      //  castString = "(long)";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1375
      else if (e.type (). indexOf ("long long") >= 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1376
        castString = "(long)";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1377
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1378
        castString = "(int)";
02bb8761fcce Initial load
duke
parents:
diff changeset
  1379
02bb8761fcce Initial load
duke
parents:
diff changeset
  1380
      // <d54640> Must emit value rather than representation when type is
02bb8761fcce Initial load
duke
parents:
diff changeset
  1381
      // "unsigned long long" (ull) because emitted unary arithmetic expressions
02bb8761fcce Initial load
duke
parents:
diff changeset
  1382
      // containing a ull converted to long (i.e., IDL long long) do not always
02bb8761fcce Initial load
duke
parents:
diff changeset
  1383
      // compute to the correct result.
02bb8761fcce Initial load
duke
parents:
diff changeset
  1384
02bb8761fcce Initial load
duke
parents:
diff changeset
  1385
      //return castString + e.op () + parseExpression (e.operand ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1386
      if (e.type ().equals ("unsigned long long"))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1387
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1388
        BigInteger value = (BigInteger)e.value ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1389
        if (value.compareTo (Expression.llMax) > 0) // value > long long max?
02bb8761fcce Initial load
duke
parents:
diff changeset
  1390
          value = value.subtract (Expression.twoPow64); // Convert to Java long (signed)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1391
        return castString + '(' + value.toString () + 'L' + ')';
02bb8761fcce Initial load
duke
parents:
diff changeset
  1392
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1393
      else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1394
        return castString + e.op () + parseExpression (e.operand ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1395
      // end <d54640>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1396
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
  1397
  } // parseUnary
02bb8761fcce Initial load
duke
parents:
diff changeset
  1398
02bb8761fcce Initial load
duke
parents:
diff changeset
  1399
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1400
   *
02bb8761fcce Initial load
duke
parents:
diff changeset
  1401
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1402
  public static boolean IDLEntity (SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1403
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1404
    boolean rc = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1405
    if (entry instanceof PrimitiveEntry || entry instanceof StringEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1406
       rc = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1407
    else if (entry instanceof TypedefEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1408
       rc = IDLEntity (entry.type ());
02bb8761fcce Initial load
duke
parents:
diff changeset
  1409
    return rc;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1410
  } // IDLEntity
02bb8761fcce Initial load
duke
parents:
diff changeset
  1411
02bb8761fcce Initial load
duke
parents:
diff changeset
  1412
  // <d62023>
02bb8761fcce Initial load
duke
parents:
diff changeset
  1413
  /**
02bb8761fcce Initial load
duke
parents:
diff changeset
  1414
   * @return true if the current setting of corbaLevel is within delta of
02bb8761fcce Initial load
duke
parents:
diff changeset
  1415
   *    the range min <= corbaLevel <= max
02bb8761fcce Initial load
duke
parents:
diff changeset
  1416
   **/
02bb8761fcce Initial load
duke
parents:
diff changeset
  1417
  public static boolean corbaLevel (float min, float max)
02bb8761fcce Initial load
duke
parents:
diff changeset
  1418
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
  1419
    float level = Compile.compiler.arguments.corbaLevel;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1420
    float delta = 0.001f;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1421
    if ((level - min + delta >= 0.0f) && (max - level + delta >= 0.0f))
02bb8761fcce Initial load
duke
parents:
diff changeset
  1422
        return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1423
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
  1424
        return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1425
  } // corbaLevel
02bb8761fcce Initial load
duke
parents:
diff changeset
  1426
02bb8761fcce Initial load
duke
parents:
diff changeset
  1427
  static Hashtable symbolTable = new Hashtable ();
02bb8761fcce Initial load
duke
parents:
diff changeset
  1428
  static Hashtable packageTranslation = new Hashtable() ;
02bb8761fcce Initial load
duke
parents:
diff changeset
  1429
} // class Util