mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +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
|
@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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user