mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
use also registered replace methods if does not exists an original in the current search path.
This commit is contained in:
parent
8a24d0b8b8
commit
7247623dc6
@ -185,69 +185,66 @@ public class ModuleGenerator {
|
|||||||
FunctionName next;
|
FunctionName next;
|
||||||
NEXT:
|
NEXT:
|
||||||
while( (next = functions.nextScannLater()) != null ) {
|
while( (next = functions.nextScannLater()) != null ) {
|
||||||
ClassFile classFile = classFileLoader.get( next.className );
|
if( next instanceof SyntheticFunctionName ) {
|
||||||
if( classFile == null ) {
|
JWebAssembly.LOGGER.fine( '\t' + next.methodName + next.signature );
|
||||||
if( next instanceof SyntheticFunctionName ) {
|
SyntheticFunctionName synth = (SyntheticFunctionName)next;
|
||||||
JWebAssembly.LOGGER.fine( '\t' + next.methodName + next.signature );
|
if( synth.hasWasmCode() ) {
|
||||||
SyntheticFunctionName synth = (SyntheticFunctionName)next;
|
scanMethod( synth.getCodeBuilder( watParser ) );
|
||||||
if( synth.hasWasmCode() ) {
|
} else {
|
||||||
scanMethod( synth.getCodeBuilder( watParser ) );
|
functions.markAsImport( synth, synth.getAnnotation() );
|
||||||
} else {
|
|
||||||
functions.markAsImport( synth, synth.getAnnotation() );
|
|
||||||
}
|
|
||||||
functions.markAsScanned( next, false );
|
|
||||||
}
|
}
|
||||||
} else {
|
functions.markAsScanned( next, false );
|
||||||
JWebAssembly.LOGGER.fine( "scan class: " + next.className );
|
continue;
|
||||||
iterateMethods( classFile, method -> {
|
|
||||||
try {
|
|
||||||
FunctionName name = new FunctionName( method );
|
|
||||||
if( functions.needToScan( name ) ) {
|
|
||||||
JWebAssembly.LOGGER.fine( '\t' + name.methodName + name.signature );
|
|
||||||
scanMethod( createInstructions( functions.replace( name, method ) ) );
|
|
||||||
boolean needThisParameter = !method.isStatic() || "<init>".equals( method.getName() );
|
|
||||||
functions.markAsScanned( name, needThisParameter );
|
|
||||||
}
|
|
||||||
} catch (IOException ioex){
|
|
||||||
throw WasmException.create( ioex, sourceFile, className, -1 );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( functions.needToScan( next ) ) { // function was not found
|
JWebAssembly.LOGGER.fine( "scan " + next.signatureName );
|
||||||
// search if there is a super class with the same signature
|
MethodInfo method = null;
|
||||||
ClassFile superClassFile = classFile;
|
ClassFile classFile = classFileLoader.get( next.className );
|
||||||
while( superClassFile != null ) {
|
if( classFile != null ) {
|
||||||
MethodInfo method = superClassFile.getMethod( next.methodName, next.signature );
|
method = classFile.getMethod( next.methodName, next.signature );
|
||||||
|
}
|
||||||
|
if( method == null ) {
|
||||||
|
method = functions.replace( next, null );
|
||||||
|
}
|
||||||
|
if( method != null ) {
|
||||||
|
scanMethod( createInstructions( functions.replace( next, method ) ) );
|
||||||
|
boolean needThisParameter = !method.isStatic() || "<init>".equals( method.getName() );
|
||||||
|
functions.markAsScanned( next, needThisParameter );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// search if there is a super class with the same signature
|
||||||
|
ClassFile superClassFile = classFile;
|
||||||
|
while( superClassFile != null ) {
|
||||||
|
method = superClassFile.getMethod( next.methodName, next.signature );
|
||||||
|
if( method != null ) {
|
||||||
|
FunctionName name = new FunctionName( method );
|
||||||
|
functions.markAsNeeded( name );
|
||||||
|
functions.setAlias( next, name );
|
||||||
|
continue NEXT; // we have found a super method
|
||||||
|
}
|
||||||
|
ConstantClass superClass = superClassFile.getSuperClass();
|
||||||
|
superClassFile = superClass == null ? null : classFileLoader.get( superClass.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// search if there is a default implementation in an interface
|
||||||
|
superClassFile = classFile;
|
||||||
|
while( superClassFile != null ) {
|
||||||
|
for( ConstantClass iface : superClassFile.getInterfaces() ) {
|
||||||
|
ClassFile iClassFile = classFileLoader.get( iface.getName() );
|
||||||
|
method = iClassFile.getMethod( next.methodName, next.signature );
|
||||||
if( method != null ) {
|
if( method != null ) {
|
||||||
FunctionName name = new FunctionName( method );
|
FunctionName name = new FunctionName( method );
|
||||||
functions.markAsNeeded( name );
|
functions.markAsNeeded( name );
|
||||||
functions.setAlias( next, name );
|
functions.setAlias( next, name );
|
||||||
continue NEXT; // we have found a super method
|
continue NEXT; // we have found a super method
|
||||||
}
|
}
|
||||||
ConstantClass superClass = superClassFile.getSuperClass();
|
|
||||||
superClassFile = superClass == null ? null : classFileLoader.get( superClass.getName() );
|
|
||||||
}
|
}
|
||||||
|
ConstantClass superClass = superClassFile.getSuperClass();
|
||||||
// search if there is a default implementation in an interface
|
superClassFile = superClass == null ? null : classFileLoader.get( superClass.getName() );
|
||||||
superClassFile = classFile;
|
|
||||||
while( superClassFile != null ) {
|
|
||||||
for( ConstantClass iface : superClassFile.getInterfaces() ) {
|
|
||||||
ClassFile iClassFile = classFileLoader.get( iface.getName() );
|
|
||||||
MethodInfo method = iClassFile.getMethod( next.methodName, next.signature );
|
|
||||||
if( method != null ) {
|
|
||||||
FunctionName name = new FunctionName( method );
|
|
||||||
functions.markAsNeeded( name );
|
|
||||||
functions.setAlias( next, name );
|
|
||||||
continue NEXT; // we have found a super method
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ConstantClass superClass = superClassFile.getSuperClass();
|
|
||||||
superClassFile = superClass == null ? null : classFileLoader.get( superClass.getName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new WasmException( "Missing function: " + next.signatureName, -1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new WasmException( "Missing function: " + next.signatureName, -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user