handle function call to imported function.

This commit is contained in:
Volker Berlin 2018-05-30 19:26:34 +02:00
parent 88a584cd63
commit 7d53f8d549

View File

@ -651,12 +651,20 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
*/ */
@Override @Override
protected void writeFunctionCall( String name ) throws IOException { protected void writeFunctionCall( String name ) throws IOException {
codeStream.write( CALL ); int id;
Function func = functions.get( name ); Function func = functions.get( name );
if( func == null ) { if( func != null ) {
id = func.id;
} else {
ImportEntry entry = imports.get( name );
if( entry != null ) {
id = entry.id;
} else {
throw new WasmException( "Call to unknown function: " + name, null, -1 ); throw new WasmException( "Call to unknown function: " + name, null, -1 );
} }
codeStream.writeVaruint32( func.id ); }
codeStream.write( CALL );
codeStream.writeVaruint32( id );
} }
/** /**