InterfaceMethodTablepublic abstract class InterfaceMethodTable extends Object
Fields Summary |
---|
public ClassClass | parent | public String | name | public InterfaceVector[] | iv |
Methods Summary |
---|
private static components.MethodInfo | findSlot(components.MethodConstant[] t, components.MethodInfo m)
if ( t != null ){
MethodInfo v;
int nt = t.length;
int ID = m.getID();
for( int i = 0; i < nt; i++ ){
if ((v=t[i].find()).getID() == ID )
return v;
}
}
return null;
| public static vm.InterfaceMethodTable | generateInterfaceTable(ClassClass cc, InterfaceMethodFactory imf)
ClassInfo c = cc.ci;
if ( c.allInterfaces == null )
c.findAllInterfaces();
String imtName = c.getGenericNativeName() + "_intfMethodtable";
ClassInfo sup = c.superClassInfo;
int ntotal = c.allInterfaces.size();
int nsuper = 0;
if ( (c.access&Const.ACC_INTERFACE) != 0 ){
return generateTablesForInterface( c, imtName, imf );
}
if ( sup != null ){
nsuper = sup.allInterfaces.size();
if ( nsuper == ntotal ){
// use other class's tables entirely.
// we have nothing further to add.
return sup.vmClass.inf;
}
}
//
// generate the offset tables, or symbolic references
// to them.
InterfaceVector vec[] = new InterfaceVector[ ntotal ];
if ( nsuper != 0 ){
// borrow some from superclass. They are the same.
System.arraycopy( sup.vmClass.inf.iv, 0, vec, 0, nsuper );
}
// compute the rest of the thing ourselves.
for( int i = nsuper; i < ntotal; i++ ){
ClassInfo intf = (ClassInfo)c.allInterfaces.elementAt( i );
MethodConstant mtab[] = intf.refMethodtable;
int nmethods = mtab.length;
short ivec[] = new short[ nmethods ];
for( int j = 0; j < nmethods; j++ ){
MethodInfo target = mtab[j].find();
if ( (target.access&Const.ACC_STATIC) != 0 ){
// should never happen.
System.err.println("Interface "+intf.className+" has a static method in its methodtable:! "+target);
continue;
}
MethodInfo v = findSlot( c.refMethodtable, target );
if ( v == null ){
System.err.println("Class "+c.className+" does not implement interface "+intf.className+" because it lacks "+target);
ivec[ j ] = 0;
} else {
ivec[ j ] = (short)v.methodTableIndex;
}
}
vec[ i ] = new InterfaceVector( cc, intf, ivec );
}
return imf.newInterfaceMethodTable( cc, imtName, vec );
| private static vm.InterfaceMethodTable | generateTablesForInterface(components.ClassInfo c, java.lang.String imtName, InterfaceMethodFactory imf)
//
// We generate a thing like an imethodtable for interfaces, too.
// But its different enough that I'm treating it separately, here.
//
// There is no way to share our imethotable with our superclass,
// as it must at least include ourselves!
//
// struct imethodtable {
// int icount;
// struct {
// ClassClass *classdescriptor;
// unsigned long *offsets = 0;
// } itable[1];
// }
ClassClass me = c.vmClass;
int ntotal = c.allInterfaces.size();
InterfaceVector ivec[] = new InterfaceVector[ ntotal+1 ];
// first the entry for ourselves.
ivec[ 0 ] = new InterfaceVector( me, c, null );
// now all the others (if any)
for( int i = 0; i< ntotal; i++){
ClassInfo intf = (ClassInfo)c.allInterfaces.elementAt( i );
ivec[ i+1 ] = new InterfaceVector( me, intf, null );
}
return imf.newInterfaceMethodTable( me, imtName, ivec );
| public void | indexInterfaceMethods(components.ClassInfo c)
if ( (c.access&Const.ACC_INTERFACE) == 0 ){
System.err.println("InterfaceMethodTable.indexInterfaceMethods: "+c.className
+" is not an interface");
return; // this is bad
}
int j = 0;
MethodInfo m[] = c.methods;
if ( m == null ) return; // no methods here.
int n = m.length;
for( int i =0; i < n; i++ ){
MethodInfo t = m[i];
if ( (t.access&Const.ACC_STATIC) != 0 )
continue; // don't number statics.
if ( (t.access&Const.ACC_ABSTRACT) == 0 ){
System.err.println("InterfaceMethodTable.indexInterfaceMethods: "+t
+" is not abstract");
// but keep going anyway...
}
t.methodTableIndex = j++;
}
|
|