mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Move the call to ValueTypeParser into the FunctionName
This commit is contained in:
parent
b677355c0f
commit
238a281757
@ -16,9 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
package de.inetsoftware.jwebassembly.module;
|
package de.inetsoftware.jwebassembly.module;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import de.inetsoftware.classparser.Member;
|
import de.inetsoftware.classparser.Member;
|
||||||
|
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||||
|
import de.inetsoftware.jwebassembly.wasm.ValueTypeParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Described the name of WebAssembly function.
|
* Described the name of WebAssembly function.
|
||||||
@ -50,7 +54,7 @@ public class FunctionName {
|
|||||||
* The signature
|
* The signature
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public final String signature;
|
private final String signature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance from the given reference in the ConstantPool or parsed method.
|
* Create a new instance from the given reference in the ConstantPool or parsed method.
|
||||||
@ -116,4 +120,14 @@ public class FunctionName {
|
|||||||
FunctionName other = (FunctionName)obj;
|
FunctionName other = (FunctionName)obj;
|
||||||
return signatureName.equals( other.signatureName );
|
return signatureName.equals( other.signatureName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the method signature iterator for parameter and return values.
|
||||||
|
*
|
||||||
|
* @return the iterator
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public Iterator<AnyType> getSignature() {
|
||||||
|
return new ValueTypeParser( signature );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,12 +350,11 @@ public class ModuleGenerator {
|
|||||||
* if some Java code can't converted
|
* if some Java code can't converted
|
||||||
*/
|
*/
|
||||||
private void writeMethodSignature( FunctionName name, boolean isStatic, @Nullable LocalVariableTable variables, WasmCodeBuilder codeBuilder ) throws IOException, WasmException {
|
private void writeMethodSignature( FunctionName name, boolean isStatic, @Nullable LocalVariableTable variables, WasmCodeBuilder codeBuilder ) throws IOException, WasmException {
|
||||||
String signature = name.signature;
|
|
||||||
int paramCount = 0;
|
int paramCount = 0;
|
||||||
if( !isStatic ) {
|
if( !isStatic ) {
|
||||||
writer.writeMethodParam( "param", ValueType.anyref, "this" );
|
writer.writeMethodParam( "param", ValueType.anyref, "this" );
|
||||||
}
|
}
|
||||||
Iterator<AnyType> parser = new ValueTypeParser( signature );
|
Iterator<AnyType> parser = name.getSignature();
|
||||||
AnyType type;
|
AnyType type;
|
||||||
for( String kind : new String[] {"param","result"}) {
|
for( String kind : new String[] {"param","result"}) {
|
||||||
while( parser.hasNext() && (type = parser.next()) != null ) {
|
while( parser.hasNext() && (type = parser.next()) != null ) {
|
||||||
|
@ -24,7 +24,6 @@ import javax.annotation.Nonnull;
|
|||||||
import de.inetsoftware.classparser.Member;
|
import de.inetsoftware.classparser.Member;
|
||||||
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||||
import de.inetsoftware.jwebassembly.wasm.ValueType;
|
import de.inetsoftware.jwebassembly.wasm.ValueType;
|
||||||
import de.inetsoftware.jwebassembly.wasm.ValueTypeParser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WasmInstruction for a function call.
|
* WasmInstruction for a function call.
|
||||||
@ -34,8 +33,6 @@ import de.inetsoftware.jwebassembly.wasm.ValueTypeParser;
|
|||||||
*/
|
*/
|
||||||
class WasmCallInstruction extends WasmInstruction {
|
class WasmCallInstruction extends WasmInstruction {
|
||||||
|
|
||||||
private final Member method;
|
|
||||||
|
|
||||||
private ValueType valueType;
|
private ValueType valueType;
|
||||||
|
|
||||||
private final FunctionName name;
|
private final FunctionName name;
|
||||||
@ -52,7 +49,6 @@ class WasmCallInstruction extends WasmInstruction {
|
|||||||
*/
|
*/
|
||||||
WasmCallInstruction( Member method, int javaCodePos ) {
|
WasmCallInstruction( Member method, int javaCodePos ) {
|
||||||
super( javaCodePos );
|
super( javaCodePos );
|
||||||
this.method = method;
|
|
||||||
this.name = new FunctionName( method );
|
this.name = new FunctionName( method );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +101,7 @@ class WasmCallInstruction extends WasmInstruction {
|
|||||||
if( paramCount >= 0 ) {
|
if( paramCount >= 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<AnyType> parser = new ValueTypeParser( method.getType() );
|
Iterator<AnyType> parser = name.getSignature();
|
||||||
paramCount = 0;
|
paramCount = 0;
|
||||||
while( parser.next() != null ) {
|
while( parser.next() != null ) {
|
||||||
paramCount++;
|
paramCount++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user