mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
add signature to WasmTextCode to support more as one return value
This commit is contained in:
parent
8d018f8f04
commit
03b8e68ccb
@ -127,7 +127,7 @@ public class ModuleGenerator {
|
|||||||
String impoarModule = (String)annotationValues.get( "module" );
|
String impoarModule = (String)annotationValues.get( "module" );
|
||||||
String importName = (String)annotationValues.get( "name" );
|
String importName = (String)annotationValues.get( "name" );
|
||||||
writer.prepareImport( name, impoarModule, importName );
|
writer.prepareImport( name, impoarModule, importName );
|
||||||
writeMethodSignature( method, null, null );
|
writeMethodSignature( method.getType(), method, null, null );
|
||||||
} else {
|
} else {
|
||||||
writer.prepareFunction( name );
|
writer.prepareFunction( name );
|
||||||
}
|
}
|
||||||
@ -152,12 +152,18 @@ public class ModuleGenerator {
|
|||||||
}
|
}
|
||||||
WasmCodeBuilder codeBuilder;
|
WasmCodeBuilder codeBuilder;
|
||||||
Code code = method.getCode();
|
Code code = method.getCode();
|
||||||
|
String signature;
|
||||||
if( method.getAnnotation( JWebAssembly.TEXTCODE_ANNOTATION ) != null ) {
|
if( method.getAnnotation( JWebAssembly.TEXTCODE_ANNOTATION ) != null ) {
|
||||||
Map<String, Object> wat = method.getAnnotation( JWebAssembly.TEXTCODE_ANNOTATION );
|
Map<String, Object> wat = method.getAnnotation( JWebAssembly.TEXTCODE_ANNOTATION );
|
||||||
String watCode = (String)wat.get( "value" );
|
String watCode = (String)wat.get( "value" );
|
||||||
|
signature = (String)wat.get( "signature" );
|
||||||
|
if( signature == null ) {
|
||||||
|
signature = method.getType();
|
||||||
|
}
|
||||||
watParser.parse( watCode, code == null ? -1 : code.getFirstLineNr() );
|
watParser.parse( watCode, code == null ? -1 : code.getFirstLineNr() );
|
||||||
codeBuilder = watParser;
|
codeBuilder = watParser;
|
||||||
} else if( code != null ) { // abstract methods and interface methods does not have code
|
} else if( code != null ) { // abstract methods and interface methods does not have code
|
||||||
|
signature = method.getType();
|
||||||
javaCodeBuilder.buildCode( code, !method.getType().endsWith( ")V" ) );
|
javaCodeBuilder.buildCode( code, !method.getType().endsWith( ")V" ) );
|
||||||
codeBuilder = javaCodeBuilder;
|
codeBuilder = javaCodeBuilder;
|
||||||
} else {
|
} else {
|
||||||
@ -167,7 +173,7 @@ public class ModuleGenerator {
|
|||||||
writeExport( name, method );
|
writeExport( name, method );
|
||||||
writer.writeMethodStart( name );
|
writer.writeMethodStart( name );
|
||||||
|
|
||||||
writeMethodSignature( method, code.getLocalVariableTable(), codeBuilder );
|
writeMethodSignature( signature, method, code.getLocalVariableTable(), codeBuilder );
|
||||||
|
|
||||||
for( WasmInstruction instruction : codeBuilder.getInstructions() ) {
|
for( WasmInstruction instruction : codeBuilder.getInstructions() ) {
|
||||||
instruction.writeTo( writer );
|
instruction.writeTo( writer );
|
||||||
@ -204,6 +210,8 @@ public class ModuleGenerator {
|
|||||||
/**
|
/**
|
||||||
* Write the parameter and return signatures
|
* Write the parameter and return signatures
|
||||||
*
|
*
|
||||||
|
* @param signature
|
||||||
|
* the Java signature, typical method.getType();
|
||||||
* @param method
|
* @param method
|
||||||
* the method
|
* the method
|
||||||
* @param variables
|
* @param variables
|
||||||
@ -215,8 +223,7 @@ public class ModuleGenerator {
|
|||||||
* @throws WasmException
|
* @throws WasmException
|
||||||
* if some Java code can't converted
|
* if some Java code can't converted
|
||||||
*/
|
*/
|
||||||
private void writeMethodSignature( MethodInfo method, @Nullable LocalVariableTable variables, WasmCodeBuilder codeBuilder ) throws IOException, WasmException {
|
private void writeMethodSignature( String signature, MethodInfo method, @Nullable LocalVariableTable variables, WasmCodeBuilder codeBuilder ) throws IOException, WasmException {
|
||||||
String signature = method.getType();
|
|
||||||
String kind = "param";
|
String kind = "param";
|
||||||
int paramCount = 0;
|
int paramCount = 0;
|
||||||
ValueType type = null;
|
ValueType type = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user