mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
handle function call to imported function.
This commit is contained in:
parent
88a584cd63
commit
7d53f8d549
@ -651,12 +651,20 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
*/
|
||||
@Override
|
||||
protected void writeFunctionCall( String name ) throws IOException {
|
||||
codeStream.write( CALL );
|
||||
int id;
|
||||
Function func = functions.get( name );
|
||||
if( func == null ) {
|
||||
throw new WasmException( "Call to unknown function: " + name, null, -1 );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
codeStream.writeVaruint32( func.id );
|
||||
codeStream.write( CALL );
|
||||
codeStream.writeVaruint32( id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user