mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
interface call, WIP
This commit is contained in:
parent
691d8986df
commit
43b41d4fad
@ -577,6 +577,7 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
||||
case 182: // invokevirtual
|
||||
case 183: // invokespecial, invoke a constructor
|
||||
case 184: // invokestatic
|
||||
case 185: // invokeinterface
|
||||
idx = byteCode.readUnsignedShort();
|
||||
ref = (ConstantRef)constantPool.get( idx );
|
||||
FunctionName funcName = new FunctionName( ref );
|
||||
@ -591,9 +592,11 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
||||
case 184:
|
||||
addCallInstruction( funcName, codePos, lineNumber );
|
||||
break;
|
||||
case 185:
|
||||
addCallInterfaceInstruction( funcName, codePos, lineNumber );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
//TODO case 185: // invokeinterface
|
||||
case 186: // invokedynamic
|
||||
idx = byteCode.readUnsignedShort();
|
||||
ConstantInvokeDynamic dynamic = (ConstantInvokeDynamic)constantPool.get( idx );
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright 2020 Volker Berlin (i-net software)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
package de.inetsoftware.jwebassembly.module;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import de.inetsoftware.jwebassembly.WasmException;
|
||||
|
||||
/**
|
||||
* WasmInstruction for a function call.
|
||||
*
|
||||
* @author Volker Berlin
|
||||
*
|
||||
*/
|
||||
class WasmCallInterfaceInstruction extends WasmCallInstruction {
|
||||
|
||||
/**
|
||||
* Create an instance of a function call instruction
|
||||
*
|
||||
* @param name
|
||||
* the function name that should be called
|
||||
* @param javaCodePos
|
||||
* the code position/offset in the Java method
|
||||
* @param lineNumber
|
||||
* the line number in the Java source code
|
||||
* @param types
|
||||
* the type manager
|
||||
*/
|
||||
WasmCallInterfaceInstruction( FunctionName name, int javaCodePos, int lineNumber, TypeManager types ) {
|
||||
super( name, javaCodePos, lineNumber, types, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
Type getType() {
|
||||
return Type.CallInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void writeTo( @Nonnull ModuleWriter writer ) throws IOException {
|
||||
throw new WasmException( "Interface calls not supported", getLineNumber() );
|
||||
}
|
||||
}
|
@ -502,6 +502,21 @@ public abstract class WasmCodeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add interface function call
|
||||
* @param name
|
||||
* the function name that should be called
|
||||
* @param javaCodePos
|
||||
* the code position/offset in the Java method
|
||||
* @param lineNumber
|
||||
* the line number in the Java source code
|
||||
*/
|
||||
protected void addCallInterfaceInstruction( FunctionName name, int javaCodePos, int lineNumber ) {
|
||||
WasmCallInterfaceInstruction interfaceCall = new WasmCallInterfaceInstruction( name, javaCodePos, lineNumber, types );
|
||||
|
||||
instructions.add( interfaceCall );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a block operation.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 - 2019 Volker Berlin (i-net software)
|
||||
Copyright 2018 - 2020 Volker Berlin (i-net software)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -35,7 +35,7 @@ abstract class WasmInstruction {
|
||||
* Type of instruction to faster differ as with instanceof.
|
||||
*/
|
||||
static enum Type {
|
||||
Const, Convert, Local, Global, Table, Memory, Block, Numeric, Nop, Call, CallIndirect, Array, Struct, Dup, DupThis;
|
||||
Const, Convert, Local, Global, Table, Memory, Block, Numeric, Nop, Call, CallIndirect, CallInterface, Array, Struct, Dup, DupThis;
|
||||
}
|
||||
|
||||
private int javaCodePos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user