1 /*
   2  * Copyright 2001 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.debugger.cdbg.basic;
  26 
  27 import java.util.*;
  28 import sun.jvm.hotspot.debugger.*;
  29 import sun.jvm.hotspot.debugger.cdbg.*;
  30 
  31 public class BasicMemberFunctionType extends BasicFunctionType implements MemberFunctionType {
  32   private Type containingClass;
  33   private Type thisType;
  34   private long thisAdjust;
  35 
  36   public BasicMemberFunctionType(String name,
  37                                  int size,
  38                                  Type returnType,
  39                                  Type containingClass,
  40                                  Type thisType,
  41                                  long thisAdjust) {
  42     this(name, size, returnType, containingClass, thisType, thisAdjust, 0);
  43   }
  44 
  45   private BasicMemberFunctionType(String name,
  46                                   int size,
  47                                   Type returnType,
  48                                   Type containingClass,
  49                                   Type thisType,
  50                                   long thisAdjust,
  51                                   int cvAttributes) {
  52     super(name, size, returnType, cvAttributes);
  53     this.containingClass = containingClass;
  54     this.thisType        = thisType;
  55     this.thisAdjust      = thisAdjust;
  56   }
  57 
  58   public MemberFunctionType asMemberFunction() { return this; }
  59 
  60   public Type getContainingClass()       { return containingClass; }
  61   public Type getThisType()              { return thisType; }
  62   public long getThisAdjust()            { return thisAdjust; }
  63 
  64   Type resolveTypes(BasicCDebugInfoDataBase db, ResolveListener listener) {
  65     super.resolveTypes(db, listener);
  66     containingClass = db.resolveType(this, containingClass, listener, "resolving member function class");
  67     thisType        = db.resolveType(this, thisType,        listener, "resolving member function \"this\" type");
  68     return this;
  69   }
  70 
  71   public void iterateObject(Address a, ObjectVisitor v, FieldIdentifier f) {
  72     // FIXME: nothing to do here? Are we going to provide iteration
  73     // mechanisms through member functions, and if so what are the
  74     // types of those functions going to be?
  75   }
  76 
  77   protected Type createCVVariant(int cvAttributes) {
  78     return new BasicMemberFunctionType(getName(),
  79                                        getSize(),
  80                                        getReturnType(),
  81                                        getContainingClass(),
  82                                        getThisType(),
  83                                        getThisAdjust(),
  84                                        cvAttributes);
  85   }
  86 
  87   public void visit(TypeVisitor v) {
  88     v.doMemberFunctionType(this);
  89   }
  90 }