mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 10:44:47 +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;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import de.inetsoftware.classparser.Member;
|
||||
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||
import de.inetsoftware.jwebassembly.wasm.ValueTypeParser;
|
||||
|
||||
/**
|
||||
* Described the name of WebAssembly function.
|
||||
@ -50,7 +54,7 @@ public class FunctionName {
|
||||
* The signature
|
||||
*/
|
||||
@Nonnull
|
||||
public final String signature;
|
||||
private final String signature;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
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
|
||||
*/
|
||||
private void writeMethodSignature( FunctionName name, boolean isStatic, @Nullable LocalVariableTable variables, WasmCodeBuilder codeBuilder ) throws IOException, WasmException {
|
||||
String signature = name.signature;
|
||||
int paramCount = 0;
|
||||
if( !isStatic ) {
|
||||
writer.writeMethodParam( "param", ValueType.anyref, "this" );
|
||||
}
|
||||
Iterator<AnyType> parser = new ValueTypeParser( signature );
|
||||
Iterator<AnyType> parser = name.getSignature();
|
||||
AnyType type;
|
||||
for( String kind : new String[] {"param","result"}) {
|
||||
while( parser.hasNext() && (type = parser.next()) != null ) {
|
||||
|
@ -24,7 +24,6 @@ import javax.annotation.Nonnull;
|
||||
import de.inetsoftware.classparser.Member;
|
||||
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||
import de.inetsoftware.jwebassembly.wasm.ValueType;
|
||||
import de.inetsoftware.jwebassembly.wasm.ValueTypeParser;
|
||||
|
||||
/**
|
||||
* WasmInstruction for a function call.
|
||||
@ -34,8 +33,6 @@ import de.inetsoftware.jwebassembly.wasm.ValueTypeParser;
|
||||
*/
|
||||
class WasmCallInstruction extends WasmInstruction {
|
||||
|
||||
private final Member method;
|
||||
|
||||
private ValueType valueType;
|
||||
|
||||
private final FunctionName name;
|
||||
@ -52,7 +49,6 @@ class WasmCallInstruction extends WasmInstruction {
|
||||
*/
|
||||
WasmCallInstruction( Member method, int javaCodePos ) {
|
||||
super( javaCodePos );
|
||||
this.method = method;
|
||||
this.name = new FunctionName( method );
|
||||
}
|
||||
|
||||
@ -105,7 +101,7 @@ class WasmCallInstruction extends WasmInstruction {
|
||||
if( paramCount >= 0 ) {
|
||||
return;
|
||||
}
|
||||
Iterator<AnyType> parser = new ValueTypeParser( method.getType() );
|
||||
Iterator<AnyType> parser = name.getSignature();
|
||||
paramCount = 0;
|
||||
while( parser.next() != null ) {
|
||||
paramCount++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user