pass through FunctionName object

This commit is contained in:
Volker Berlin 2018-11-24 16:14:52 +01:00
parent 2c792f4a4f
commit d8de454a3f
4 changed files with 12 additions and 10 deletions

View File

@ -699,17 +699,18 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
* {@inheritDoc}
*/
@Override
protected void writeFunctionCall( String name ) throws IOException {
protected void writeFunctionCall( FunctionName name ) throws IOException {
String signatureName = name.signatureName;
int id;
Function func = functions.get( name );
Function func = functions.get( signatureName );
if( func != null ) {
id = func.id;
} else {
ImportFunction entry = imports.get( name );
ImportFunction entry = imports.get( signatureName );
if( entry != null ) {
id = entry.id;
} else {
throw new WasmException( "Call to unknown function: " + name, null, null, -1 );
throw new WasmException( "Call to unknown function: " + signatureName, null, null, -1 );
}
}
codeStream.writeOpCode( CALL );

View File

@ -186,11 +186,11 @@ public abstract class ModuleWriter implements Closeable {
* Write a call to a function.
*
* @param name
* the full qualified method name
* the function name
* @throws IOException
* if any I/O error occur
*/
protected abstract void writeFunctionCall( String name ) throws IOException;
protected abstract void writeFunctionCall( FunctionName name ) throws IOException;
/**
* Write a block/branch code

View File

@ -53,7 +53,7 @@ class WasmCallInstruction extends WasmInstruction {
* {@inheritDoc}
*/
public void writeTo( @Nonnull ModuleWriter writer ) throws IOException {
writer.writeFunctionCall( new FunctionName( method ).signatureName );
writer.writeFunctionCall( new FunctionName( method ) );
}
/**

View File

@ -285,10 +285,11 @@ public class TextModuleWriter extends ModuleWriter {
* {@inheritDoc}
*/
@Override
protected void writeFunctionCall( String name ) throws IOException {
protected void writeFunctionCall( FunctionName name ) throws IOException {
newline( methodOutput );
name = name.substring( 0, name.indexOf( '(' ) );
methodOutput.append( "call $" ).append( name );
String signatureName = name.signatureName;
signatureName = signatureName.substring( 0, signatureName.indexOf( '(' ) );
methodOutput.append( "call $" ).append( signatureName );
}
/**