mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
use declared local names for local.set/get
This commit is contained in:
parent
40d61c56a8
commit
0b49204793
@ -16,6 +16,7 @@
|
|||||||
package de.inetsoftware.jwebassembly.text;
|
package de.inetsoftware.jwebassembly.text;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -49,6 +50,8 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
|
|
||||||
private final boolean debugNames;
|
private final boolean debugNames;
|
||||||
|
|
||||||
|
private final ArrayList<String> methodParamNames = new ArrayList<>();
|
||||||
|
|
||||||
private StringBuilder methodOutput = new StringBuilder();
|
private StringBuilder methodOutput = new StringBuilder();
|
||||||
|
|
||||||
private int inset;
|
private int inset;
|
||||||
@ -164,6 +167,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
methodOutput.append( "(func $" );
|
methodOutput.append( "(func $" );
|
||||||
methodOutput.append( name.fullName );
|
methodOutput.append( name.fullName );
|
||||||
inset++;
|
inset++;
|
||||||
|
methodParamNames.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,8 +176,13 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
@Override
|
@Override
|
||||||
protected void writeMethodParam( String kind, AnyType valueType, @Nullable String name ) throws IOException {
|
protected void writeMethodParam( String kind, AnyType valueType, @Nullable String name ) throws IOException {
|
||||||
methodOutput.append( " (" ).append( kind );
|
methodOutput.append( " (" ).append( kind );
|
||||||
if( debugNames && name != null ) {
|
if( debugNames ) {
|
||||||
methodOutput.append( " $" ).append( name );
|
if( name != null ) {
|
||||||
|
methodOutput.append( " $" ).append( name );
|
||||||
|
}
|
||||||
|
if( kind != "result" ) {
|
||||||
|
methodParamNames.add( name );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
methodOutput.append( ' ' ).append( valueType.toString() ).append( ')' );
|
methodOutput.append( ' ' ).append( valueType.toString() ).append( ')' );
|
||||||
}
|
}
|
||||||
@ -214,7 +223,13 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
@Override
|
@Override
|
||||||
protected void writeLocal( VariableOperator op, int idx ) throws IOException {
|
protected void writeLocal( VariableOperator op, int idx ) throws IOException {
|
||||||
newline( methodOutput );
|
newline( methodOutput );
|
||||||
methodOutput.append( "local." ).append( op ).append( ' ' ).append( Integer.toString( idx ) );
|
methodOutput.append( "local." ).append( op ).append( ' ' );
|
||||||
|
String name = idx < methodParamNames.size() ? methodParamNames.get( idx ) : null;
|
||||||
|
if( name == null ) {
|
||||||
|
methodOutput.append( Integer.toString( idx ) );
|
||||||
|
} else {
|
||||||
|
methodOutput.append( '$' ).append( name );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user