corba/src/java.corba/share/classes/com/sun/tools/corba/se/idl/InterfaceEntry.java
author avstepan
Tue, 05 May 2015 15:17:13 +0400
changeset 30383 45960fdbe465
parent 25862 a5e25d68f971
permissions -rw-r--r--
8079075: some docs cleanup for CORBA - part 1 Summary: some fix for CORBA docs Reviewed-by: rriggs
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.parser
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;
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
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
import java.io.PrintWriter;
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import java.util.Enumeration;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import java.util.Hashtable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
import java.util.Vector;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
 * This is the symbol table entry for interfaces.
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
 **/
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
public class InterfaceEntry extends SymtabEntry implements InterfaceType
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
  protected InterfaceEntry ()
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
    super ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
  } // ctor
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
  protected InterfaceEntry (InterfaceEntry that)
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
    super (that);
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
    _derivedFromNames = (Vector)that._derivedFromNames.clone ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
    _derivedFrom      = (Vector)that._derivedFrom.clone ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
    _methods          = (Vector)that._methods.clone ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
    _allMethods       = (Vector)that._allMethods.clone ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
    forwardedDerivers = (Vector)that.forwardedDerivers.clone ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
    _contained        = (Vector)that._contained.clone ();
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
    _interfaceType    = that._interfaceType;
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
  } // ctor
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
  protected InterfaceEntry (SymtabEntry that, IDLID clone)
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
    super (that, clone);
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
    if (module ().equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
      module (name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
    else if (!name ().equals (""))
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
      module (module () + "/" + name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
  } // ctor
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
  public boolean isAbstract()
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
      return _interfaceType == ABSTRACT ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
  public boolean isLocal()
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
      return _interfaceType == LOCAL ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
  public boolean isLocalServant()
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
      return _interfaceType == LOCALSERVANT ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
  public boolean isLocalSignature()
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
      return _interfaceType == LOCAL_SIGNATURE_ONLY ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
  public Object clone ()
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
    return new InterfaceEntry (this);
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
  } // clone
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
  /** Invoke the interface generator.
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
      @param symbolTable the symbol table is a hash table whose key is
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
       a fully qualified type name and whose value is a SymtabEntry or
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
       a subclass of SymtabEntry.
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
      @param stream the stream to which the generator should sent its output.
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
      @see SymtabEntry */
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
  public void generate (Hashtable symbolTable, PrintWriter stream)
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
    interfaceGen.generate (symbolTable, this, stream);
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
  } // generate
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
  /** Access the interface generator.
30383
45960fdbe465 8079075: some docs cleanup for CORBA - part 1
avstepan
parents: 25862
diff changeset
   114
      @return an object which implements the InterfaceGen interface.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
      @see InterfaceGen */
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
  public Generator generator ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
    return interfaceGen;
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
  } // generator
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
  /** Add an InterfaceEntry to the list of interfaces which this interface
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
      is derivedFrom.  During parsing, the parameter to this method COULD
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
      be a ForwardEntry, but when parsing is complete, calling derivedFrom
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
      will return a vector which only contains InterfaceEntry's. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
  public void addDerivedFrom (SymtabEntry derivedFrom)
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
    _derivedFrom.addElement (derivedFrom);
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
  } // addDerivedFrom
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
  /** This method returns a vector of InterfaceEntry's. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
  public Vector derivedFrom ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
    return _derivedFrom;
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
  } // derivedFrom
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
  /** Add to the list of derivedFrom names. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
  public void addDerivedFromName (String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
    _derivedFromNames.addElement (name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
  } // addDerivedFromName
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
  /** This method returns a vector of Strings, each of which is a fully
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
      qualified name of an interface. This vector corresponds to the
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
      derivedFrom vector.  The first element of this vector is the name
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
      of the first element of the derivedFrom vector, etc. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
  public Vector derivedFromNames ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
    return _derivedFromNames;
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
  } // derivedFromNames
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
  /** Add a method/attribute to the list of methods. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
  public void addMethod (MethodEntry method)
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
    _methods.addElement (method);
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
  } // addMethod
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
  /** This is a vector of MethodEntry's.  These are the methods and
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
      attributes contained within this Interface. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
  public Vector methods ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
    return _methods;
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
  } // methods
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
  /** Add a symbol table entry to this interface's contained vector. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
  public void addContained (SymtabEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
    _contained.addElement (entry);
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
  } // addContained
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
  /** This is a vector of SymtabEntry's.  Valid entries in this vector are:
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
      AttributeEntry, ConstEntry, EnumEntry, ExceptionEntry, MethodEntry,
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
      StructEntry, NativeEntry, TypedefEntry, UnionEntry.
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
      Note that the methods vector is a subset of this vector. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
  public Vector contained ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
    return _contained;
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
  } // contained
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
  void methodsAddElement (MethodEntry method, Scanner scanner)
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
    if (verifyMethod (method, scanner, false))
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
      addMethod (method);
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
      _allMethods.addElement (method);
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
      // Add this method to the 'allMethods' list of any interfaces
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
      // which may have inherited this one when it was a forward
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
      // reference.
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
      addToForwardedAllMethods (method, scanner);
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
  } // methodsAddElement
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
  void addToForwardedAllMethods (MethodEntry method, Scanner scanner)
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
    Enumeration e = forwardedDerivers.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
    while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
      InterfaceEntry derived = (InterfaceEntry)e.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
      if (derived.verifyMethod (method, scanner, true))
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
        derived._allMethods.addElement (method);
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
  } // addToForwardedAllMethods
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
  // Make sure a method by this name doesn't exist in this class or
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
  // in this class's parents
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
  private boolean verifyMethod (MethodEntry method, Scanner scanner, boolean clash)
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
    boolean unique = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
    String  lcName = method.name ().toLowerCase ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
    Enumeration e  = _allMethods.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
    while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
      MethodEntry emethod = (MethodEntry)e.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
      // Make sure the method doesn't exist either in its
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
      // original name or in all lower case.  In IDL, identifiers
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
      // which differ only in case are collisions.
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
      String lceName = emethod.name ().toLowerCase ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
      if (method != emethod && lcName.equals (lceName))
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
        if (clash)
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
          ParseException.methodClash (scanner, fullName (), method.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
          ParseException.alreadyDeclared (scanner, method.name ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
        unique = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
        break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
    return unique;
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
  } // verifyMethod
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
  void derivedFromAddElement (SymtabEntry e, Scanner scanner)
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
    addDerivedFrom (e);
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
    addDerivedFromName (e.fullName ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
    addParentType( e, scanner );
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
  } // derivedFromAddElement
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
  void addParentType (SymtabEntry e, Scanner scanner)
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
    if (e instanceof ForwardEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
      addToDerivers ((ForwardEntry)e);
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
    else
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
    { // e instanceof InterfaceEntry
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
      InterfaceEntry derivedFrom = (InterfaceEntry)e;
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
      // Compare all of the parent's methods to the methods on this
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
      // interface, looking for name clashes:
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
      for ( Enumeration enumeration = derivedFrom._allMethods.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
            enumeration.hasMoreElements (); )
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
      {
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
        MethodEntry method = (MethodEntry)enumeration.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
        if ( verifyMethod (method, scanner, true))
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
          _allMethods.addElement (method);
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
        // Add this method to the 'allMethods' list of any interfaces
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
        // which may have inherited this one when it was a forward
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
        // reference:
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
        addToForwardedAllMethods (method, scanner);
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
      // If any of the parent's parents are forward entries, make
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
      // sure this interface gets added to their derivers list so
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
      // that when the forward entry is defined, the 'allMethods'
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
      // list of this interface can be updated.
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
      lookForForwardEntrys (scanner, derivedFrom);
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
  }  // addParentType
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
  private void lookForForwardEntrys (Scanner scanner, InterfaceEntry entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
    Enumeration parents = entry.derivedFrom ().elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
    while (parents.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
      SymtabEntry parent = (SymtabEntry)parents.nextElement ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
      if (parent instanceof ForwardEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
        addToDerivers ((ForwardEntry)parent);
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
      else if (parent == entry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
        ParseException.selfInherit (scanner, entry.fullName ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
      else // it must be an InterfaceEntry
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
        lookForForwardEntrys (scanner, (InterfaceEntry)parent);
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
  } // lookForForwardEntrys
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
  public boolean replaceForwardDecl (ForwardEntry oldEntry, InterfaceEntry newEntry)
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
    int index = _derivedFrom.indexOf( oldEntry );
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
    if ( index >= 0 )
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
      _derivedFrom.setElementAt( newEntry, index );
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
    return (index >= 0);
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
  } // replaceForwardDecl
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
  private void addToDerivers (ForwardEntry forward)
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
    // Add this interface to the derivers list on the forward entry
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
    // so that when the forward entry is defined, the 'allMethods'
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
    // list of this interface can be updated.
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
    forward.derivers.addElement (this);
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
    Enumeration e = forwardedDerivers.elements ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
    while (e.hasMoreElements ())
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
      forward.derivers.addElement ((InterfaceEntry)e.nextElement ());
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
  } // addToDerivers
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
  /** This method returns a vector of the elements in the state block.
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
      If it is null, this is not a stateful interface.  If it is non-null,
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
      but of zero length, then it is still stateful; it has no state
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
      entries itself, but it has an ancestor which does. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
  public Vector state ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
    return _state;
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
  } // state
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
  public void initState ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
    _state = new Vector ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
  } // initState
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
  public void addStateElement (InterfaceState state, Scanner scanner)
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
    if (_state == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
      _state = new Vector ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
    String name = state.entry.name ();
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
    for (Enumeration e = _state.elements (); e.hasMoreElements ();)
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
      if (name.equals (((InterfaceState) e.nextElement ()).entry.name ()))
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
        ParseException.duplicateState (scanner, name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
    _state.addElement (state);
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
  } // state
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
  public int getInterfaceType ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
    return _interfaceType;
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
  public void setInterfaceType (int type)
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
    _interfaceType = type;
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
  /** Get the allMethods vector. */
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
  public Vector allMethods ()
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
  {
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
    return _allMethods;
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
  }
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
  private Vector  _derivedFromNames = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
  private Vector  _derivedFrom      = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
  private Vector  _methods          = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
          Vector  _allMethods       = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
          Vector  forwardedDerivers = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
  private Vector  _contained        = new Vector();
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
  private Vector  _state            = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
  private int _interfaceType         = NORMAL;
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
  static  InterfaceGen interfaceGen;
02bb8761fcce Initial load
duke
parents:
diff changeset
   355
} // class InterfaceEntry