mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 23:47:51 +01:00
write function lazy to the output to hold space free for more meta informations
This commit is contained in:
parent
11b8dcb3be
commit
0e02db9985
@ -76,6 +76,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
output.append( methodOutput );
|
||||||
inset--;
|
inset--;
|
||||||
newline( output );
|
newline( output );
|
||||||
output.append( ')' );
|
output.append( ')' );
|
||||||
@ -87,8 +88,8 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
@Override
|
@Override
|
||||||
protected void prepareImport( FunctionName name, String importModule, String importName ) throws IOException {
|
protected void prepareImport( FunctionName name, String importModule, String importName ) throws IOException {
|
||||||
if( importName != null ) {
|
if( importName != null ) {
|
||||||
newline( output );
|
newline( methodOutput );
|
||||||
output.append( "(import \"" ).append( importModule ).append( "\" \"" ).append( importName ).append( "\" (func $" ).append( name.fullName );
|
methodOutput.append( "(import \"" ).append( importModule ).append( "\" \"" ).append( importName ).append( "\" (func $" ).append( name.fullName );
|
||||||
isImport = true;
|
isImport = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +108,6 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void writeMethodStart( FunctionName name ) throws IOException {
|
protected void writeMethodStart( FunctionName name ) throws IOException {
|
||||||
methodOutput.setLength( 0 );
|
|
||||||
newline( methodOutput );
|
newline( methodOutput );
|
||||||
methodOutput.append( "(func $" );
|
methodOutput.append( "(func $" );
|
||||||
methodOutput.append( name.fullName );
|
methodOutput.append( name.fullName );
|
||||||
@ -133,7 +133,7 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
protected void writeMethodParamFinish( ) throws IOException {
|
protected void writeMethodParamFinish( ) throws IOException {
|
||||||
if( isImport ) {
|
if( isImport ) {
|
||||||
isImport = false;
|
isImport = false;
|
||||||
output.append( "))" );
|
methodOutput.append( "))" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,10 +142,9 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void writeMethodFinish() throws IOException {
|
protected void writeMethodFinish() throws IOException {
|
||||||
output.append( methodOutput );
|
|
||||||
inset--;
|
inset--;
|
||||||
newline( output );
|
newline( methodOutput );
|
||||||
output.append( ')' );
|
methodOutput.append( ')' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,8 @@ public class WatParserTest {
|
|||||||
instruction.writeTo( writer );
|
instruction.writeTo( writer );
|
||||||
}
|
}
|
||||||
writer.writeMethodFinish();
|
writer.writeMethodFinish();
|
||||||
String expected = normalize( "(module " + wat + " )" );
|
writer.close();
|
||||||
|
String expected = normalize( "(module " + wat + " ) )" );
|
||||||
String actual = normalize( builder );
|
String actual = normalize( builder );
|
||||||
assertEquals( expected, actual );
|
assertEquals( expected, actual );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user