diff --git a/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java b/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java index 1f94744..a9c45cc 100644 --- a/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java +++ b/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java @@ -576,15 +576,23 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder { addStructInstruction( StructOperator.SET, ref.getClassName(), new NamedStorageType( ref, getTypeManager() ), codePos, lineNumber ); break; case 182: // invokevirtual - idx = byteCode.readUnsignedShort(); - ref = (ConstantRef)constantPool.get( idx ); - addCallVirtualInstruction( new FunctionName( ref ), codePos, lineNumber ); - break; case 183: // invokespecial, invoke a constructor case 184: // invokestatic idx = byteCode.readUnsignedShort(); ref = (ConstantRef)constantPool.get( idx ); - addCallInstruction( new FunctionName( ref ), codePos, lineNumber ); + FunctionName funcName = new FunctionName( ref ); + switch( op ) { + case 182: + addCallVirtualInstruction( funcName, codePos, lineNumber ); + break; + case 183: + getTypeManager().valueOf( funcName.className ); // TODO pass this as first parameter + addCallInstruction( funcName, codePos, lineNumber ); + break; + case 184: + addCallInstruction( funcName, codePos, lineNumber ); + break; + } break; //TODO case 185: // invokeinterface //TODO case 186: // invokedynamic diff --git a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java index 8754c1e..0126deb 100644 --- a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java +++ b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java @@ -180,6 +180,7 @@ public class ModuleGenerator { } if( functions.needToScan( next ) ) { // function was not found + // search if there is a super class with the same signature ClassFile superClassFile = classFile; while( superClassFile != null ) { MethodInfo method = superClassFile.getMethod( next.methodName, next.signature ); @@ -187,7 +188,7 @@ public class ModuleGenerator { FunctionName name = new FunctionName( method ); functions.markAsNeeded( name ); functions.setAlias( next, name ); - continue NEXT; + continue NEXT; // we have found a super method } ConstantClass superClass = superClassFile.getSuperClass(); superClassFile = superClass == null ? null : ClassFile.get( superClass.getName(), libraries ); @@ -196,6 +197,8 @@ public class ModuleGenerator { } } functions.prepareFinish(); + + types.prepareFinish(); } /** diff --git a/src/de/inetsoftware/jwebassembly/module/TypeManager.java b/src/de/inetsoftware/jwebassembly/module/TypeManager.java index f26a63d..35d08da 100644 --- a/src/de/inetsoftware/jwebassembly/module/TypeManager.java +++ b/src/de/inetsoftware/jwebassembly/module/TypeManager.java @@ -17,6 +17,7 @@ package de.inetsoftware.jwebassembly.module; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -33,7 +34,15 @@ import de.inetsoftware.jwebassembly.wasm.NamedStorageType; */ public class TypeManager { - private final Map map = new LinkedHashMap<>(); + private Map map = new LinkedHashMap<>(); + + + /** + * Finish the prepare. Now no new function should be added. + */ + public void prepareFinish() { + map = Collections.unmodifiableMap( map ); + } /** * Use the type in the output.