mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
compile all implementations of used interfaces.
This commit is contained in:
parent
c4d4bf04be
commit
f277238d14
@ -447,13 +447,9 @@ public class TypeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add all interfaces to the instanceof set
|
// add all interfaces to the instanceof set
|
||||||
for(ConstantClass interClass : classFile.getInterfaces() ) {
|
listInterface( classFile, functions, types, classFileLoader );
|
||||||
StructType type = types.structTypes.get( interClass.getName() );
|
|
||||||
if( type != null ) {
|
|
||||||
instanceOFs.add( type );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// List stuff of super class
|
||||||
ConstantClass superClass = classFile.getSuperClass();
|
ConstantClass superClass = classFile.getSuperClass();
|
||||||
if( superClass != null ) {
|
if( superClass != null ) {
|
||||||
String superClassName = superClass.getName();
|
String superClassName = superClass.getName();
|
||||||
@ -463,6 +459,7 @@ public class TypeManager {
|
|||||||
fields.add( new NamedStorageType( ValueType.i32, className, FIELD_HASHCODE ) );
|
fields.add( new NamedStorageType( ValueType.i32, className, FIELD_HASHCODE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// list all fields
|
||||||
for( FieldInfo field : classFile.getFields() ) {
|
for( FieldInfo field : classFile.getFields() ) {
|
||||||
if( field.isStatic() ) {
|
if( field.isStatic() ) {
|
||||||
continue;
|
continue;
|
||||||
@ -500,6 +497,41 @@ public class TypeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all interfaces and and mark all instance methods of used interfaces.
|
||||||
|
*
|
||||||
|
* @param classFile
|
||||||
|
* the class file
|
||||||
|
* @param functions
|
||||||
|
* the used functions for the vtables of the types
|
||||||
|
* @param types
|
||||||
|
* for types of fields
|
||||||
|
* @param classFileLoader
|
||||||
|
* for loading the class files
|
||||||
|
* @throws IOException
|
||||||
|
* if any I/O error occur on loading or writing
|
||||||
|
*/
|
||||||
|
private void listInterface( ClassFile classFile, FunctionManager functions, TypeManager types, ClassFileLoader classFileLoader ) throws IOException {
|
||||||
|
for( ConstantClass interClass : classFile.getInterfaces() ) {
|
||||||
|
String interName = interClass.getName();
|
||||||
|
StructType type = types.structTypes.get( interName );
|
||||||
|
if( type != null ) {
|
||||||
|
// add all interfaces to the instanceof set
|
||||||
|
instanceOFs.add( type );
|
||||||
|
}
|
||||||
|
ClassFile interClassFile = classFileLoader.get( interName );
|
||||||
|
for( MethodInfo interMethod : interClassFile.getMethods() ) {
|
||||||
|
FunctionName funcName = new FunctionName( interMethod );
|
||||||
|
if( functions.isUsed( funcName ) ) {
|
||||||
|
MethodInfo method = classFile.getMethod( funcName.methodName, funcName.signature );
|
||||||
|
if( method != null ) {
|
||||||
|
functions.markAsNeeded( new FunctionName( method ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -651,7 +651,7 @@ public abstract class WasmCodeBuilder {
|
|||||||
* the line number in the Java source code
|
* the line number in the Java source code
|
||||||
*/
|
*/
|
||||||
protected void addCallInterfaceInstruction( FunctionName name, int javaCodePos, int lineNumber ) {
|
protected void addCallInterfaceInstruction( FunctionName name, int javaCodePos, int lineNumber ) {
|
||||||
//TODO name = functions.markAsNeeded( name );
|
name = functions.markAsNeeded( name );
|
||||||
addCallIndirectInstruction( new WasmCallInterfaceInstruction( name, javaCodePos, lineNumber, types, options ) );
|
addCallIndirectInstruction( new WasmCallInterfaceInstruction( name, javaCodePos, lineNumber, types, options ) );
|
||||||
functions.markClassAsUsed( name.className );
|
functions.markClassAsUsed( name.className );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user