mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 10:44:47 +01:00
add interface calls, WIP
This commit is contained in:
parent
a535c48363
commit
cb71374f57
@ -97,7 +97,7 @@ public class TypeManager {
|
||||
if( isFinish ) {
|
||||
throw new WasmException( "Register needed type after scanning: " + name, -1 );
|
||||
}
|
||||
type = new StructType( name );
|
||||
type = new StructType( name, structTypes.size() );
|
||||
structTypes.put( name, type );
|
||||
}
|
||||
return type;
|
||||
@ -132,6 +132,8 @@ public class TypeManager {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int classIndex;
|
||||
|
||||
private int code = Integer.MAX_VALUE;
|
||||
|
||||
private HashSet<String> neededFields = new HashSet<>();
|
||||
@ -150,9 +152,12 @@ public class TypeManager {
|
||||
*
|
||||
* @param name
|
||||
* the Java class name
|
||||
* @param classIndex
|
||||
* the running index of the class/type
|
||||
*/
|
||||
StructType( String name ) {
|
||||
StructType( String name, int classIndex ) {
|
||||
this.name = name;
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -281,6 +286,15 @@ public class TypeManager {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The running index of the class/type for class meta data, instanceof and interface calls.
|
||||
*
|
||||
* @return the unique index
|
||||
*/
|
||||
public int getClassIndex() {
|
||||
return classIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields of this struct
|
||||
* @return the fields
|
||||
|
@ -37,6 +37,7 @@ class WasmCallInstruction extends WasmInstruction {
|
||||
|
||||
private int paramCount = -1;
|
||||
|
||||
@Nonnull
|
||||
private final TypeManager types;
|
||||
|
||||
private final boolean needThisParameter;
|
||||
@ -55,7 +56,7 @@ class WasmCallInstruction extends WasmInstruction {
|
||||
* @param needThisParameter
|
||||
* true, if this function need additional to the parameter of the signature an extra "this" parameter
|
||||
*/
|
||||
WasmCallInstruction( FunctionName name, int javaCodePos, int lineNumber, TypeManager types, boolean needThisParameter ) {
|
||||
WasmCallInstruction( FunctionName name, int javaCodePos, int lineNumber, @Nonnull TypeManager types, boolean needThisParameter ) {
|
||||
super( javaCodePos, lineNumber );
|
||||
this.name = name;
|
||||
this.types = types;
|
||||
@ -80,6 +81,14 @@ class WasmCallInstruction extends WasmInstruction {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type manager.
|
||||
* @return the manager
|
||||
*/
|
||||
TypeManager getTypeManager() {
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the function as needed in the functions manager and replace the function name with a possible super name.
|
||||
*
|
||||
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import de.inetsoftware.jwebassembly.WasmException;
|
||||
import de.inetsoftware.jwebassembly.module.TypeManager.StructType;
|
||||
|
||||
/**
|
||||
* WasmInstruction for a function call.
|
||||
@ -58,6 +59,8 @@ class WasmCallInterfaceInstruction extends WasmCallInstruction {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void writeTo( @Nonnull ModuleWriter writer ) throws IOException {
|
||||
StructType type = getTypeManager().valueOf( getFunctionName().className );
|
||||
int classIndex = type.getClassIndex();
|
||||
throw new WasmException( "Interface calls are not supported.", getLineNumber() );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user